Clan.patch
dpr/src/Clan.patch · 177.8 KB
From the archive dpr.tgz
Download the archive « Back to the archive contents
diff -c -P -x *.o orig-src/Makefile src/Makefile
*** orig-src/Makefile Mon Feb 24 23:00:32 1997
--- src/Makefile Mon Feb 24 16:28:51 1997
***************
*** 22,28 ****
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \
! spells.o utils.o weather.o
default: .accepted
$(MAKE) ../bin/circle
--- 22,28 ----
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \
! spells.o utils.o weather.o clan.o
default: .accepted
$(MAKE) ../bin/circle
***************
*** 139,152 ****
class.o: class.c conf.h sysdep.h structs.h db.h utils.h spells.h interpreter.h
$(CC) -c $(CFLAGS) class.c
comm.o: comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
! db.h house.h
$(CC) -c $(CFLAGS) comm.c
config.o: config.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) config.c
constants.o: constants.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) constants.c
db.o: db.c conf.h sysdep.h structs.h utils.h db.h comm.h handler.h spells.h mail.h \
! interpreter.h house.h
$(CC) -c $(CFLAGS) db.c
fight.o: fight.c conf.h sysdep.h structs.h utils.h comm.h handler.h interpreter.h \
db.h spells.h screen.h
--- 139,152 ----
class.o: class.c conf.h sysdep.h structs.h db.h utils.h spells.h interpreter.h
$(CC) -c $(CFLAGS) class.c
comm.o: comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
! db.h house.h clan.h
$(CC) -c $(CFLAGS) comm.c
config.o: config.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) config.c
constants.o: constants.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) constants.c
db.o: db.c conf.h sysdep.h structs.h utils.h db.h comm.h handler.h spells.h mail.h \
! interpreter.h house.h clan.h
$(CC) -c $(CFLAGS) db.c
fight.o: fight.c conf.h sysdep.h structs.h utils.h comm.h handler.h interpreter.h \
db.h spells.h screen.h
***************
*** 161,167 ****
utils.h house.h
$(CC) -c $(CFLAGS) house.c
interpreter.o: interpreter.c conf.h sysdep.h structs.h comm.h interpreter.h db.h \
! utils.h spells.h handler.h mail.h screen.h
$(CC) -c $(CFLAGS) interpreter.c
limits.o: limits.c conf.h sysdep.h structs.h utils.h spells.h comm.h db.h \
handler.h
--- 161,167 ----
utils.h house.h
$(CC) -c $(CFLAGS) house.c
interpreter.o: interpreter.c conf.h sysdep.h structs.h comm.h interpreter.h db.h \
! utils.h spells.h handler.h mail.h screen.h clan.h
$(CC) -c $(CFLAGS) interpreter.c
limits.o: limits.c conf.h sysdep.h structs.h utils.h spells.h comm.h db.h \
handler.h
***************
*** 175,181 ****
handler.h spells.h
$(CC) -c $(CFLAGS) mobact.c
modify.o: modify.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h db.h \
! comm.h spells.h mail.h boards.h
$(CC) -c $(CFLAGS) modify.c
objsave.o: objsave.c conf.h sysdep.h structs.h comm.h handler.h db.h \
interpreter.h utils.h spells.h
--- 175,181 ----
handler.h spells.h
$(CC) -c $(CFLAGS) mobact.c
modify.o: modify.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h db.h \
! comm.h spells.h mail.h boards.h clan.h
$(CC) -c $(CFLAGS) modify.c
objsave.o: objsave.c conf.h sysdep.h structs.h comm.h handler.h db.h \
interpreter.h utils.h spells.h
***************
*** 206,208 ****
--- 206,212 ----
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c
+ clan.o: clan.c conf.h sysdep.h structs.h db.h utils.h spells.h \
+ interpreter.h screen.h clan.h
+ $(CC) -c $(CFLAGS) clan.c
+
diff -c -P -x *.o orig-src/act.offensive.c src/act.offensive.c
*** orig-src/act.offensive.c Mon Feb 24 23:00:32 1997
--- src/act.offensive.c Sat Feb 8 13:26:17 1997
***************
*** 25,30 ****
--- 25,33 ----
extern struct descriptor_data *descriptor_list;
extern struct room_data *world;
extern int pk_allowed;
+ extern int summon_allowed;
+ extern int charm_allowed;
+ extern int sleep_allowed;
/* extern functions */
void raw_kill(struct char_data * ch);
diff -c -P -x *.o orig-src/act.wizard.c src/act.wizard.c
*** orig-src/act.wizard.c Mon Feb 24 23:00:32 1997
--- src/act.wizard.c Sun Feb 9 17:07:59 1997
***************
*** 41,46 ****
--- 41,53 ----
extern int top_of_objt;
extern int top_of_p_table;
+ /* (FIDO) Added allowed extern variables here for ACMD(do_world) */
+ extern int pk_allowed;
+ extern int sleep_allowed;
+ extern int charm_allowed;
+ extern int summon_allowed;
+ extern int roomaffect_allowed;
+
/* for objects */
extern char *item_types[];
extern char *wear_bits[];
***************
*** 2480,2483 ****
--- 2487,2601 ----
sprintf(buf, "Your syslog is now %s.\r\n", logtypes[tp]);
send_to_char(buf, ch);
+ }
+
+ /* (FIDO) New command: world <field> <on|off> */
+ /* It modifies the global variables: */
+ /* pk/sleep/charm/summon/roomaffect_allowed */
+ void send_to_imms(char *msg)
+ {
+ struct descriptor_data *pt;
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character && GET_LEVEL(pt->character) >= LVL_GOD)
+ send_to_char(msg, pt->character);
+
+ }
+
+ ACMD(do_world)
+ {
+ char field[MAX_INPUT_LENGTH];
+
+ half_chop(argument, field, buf);
+
+ if (strcmp(field, "pk") == 0)
+ {
+ if (pk_allowed == 1)
+ {
+ pk_allowed = 0;
+ sprintf(buf, "[SYS: %s disallows PKilling]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ else
+ {
+ pk_allowed = 1;
+ sprintf(buf, "[SYS: %s allows PKilling]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ }
+ else if (strcmp(field, "sleep") == 0)
+ {
+ if (sleep_allowed == 1)
+ {
+ sleep_allowed = 0;
+ sprintf(buf, "[SYS: %s disallows players from casting sleep on each other]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ else
+ {
+ sleep_allowed = 1;
+ sprintf(buf, "[SYS: %s allows players to cast sleep on each other]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ }
+ else if (strcmp(field, "summon") == 0)
+ {
+ if (summon_allowed == 1)
+ {
+ summon_allowed = 0;
+ sprintf(buf, "[SYS: %s disallows players from summoning one another]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ else
+ {
+ summon_allowed = 1;
+ sprintf(buf, "[SYS: %s allows players to summon one another]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ }
+ else if (strcmp(field, "charm") == 0)
+ {
+ if (charm_allowed == 1)
+ {
+ charm_allowed = 0;
+ sprintf(buf, "[SYS: %s disallows players from charming one another]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ else
+ {
+ charm_allowed = 1;
+ sprintf(buf, "[SYS: %s allows players to charm one another]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ }
+ else if (strcmp(field, "roomaffect") == 0)
+ {
+ if (roomaffect_allowed == 1)
+ {
+ roomaffect_allowed = 0;
+ sprintf(buf, "[SYS: %s disallows room affect spells from hurting other players]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ else
+ {
+ roomaffect_allowed = 1;
+ sprintf(buf, "[SYS: %s allows room affect spells to hurt other players]\r\n", GET_NAME(ch));
+ send_to_imms(buf);
+ }
+ }
+ else
+ {
+ send_to_char("[Current world status:]\r\n", ch);
+ if (pk_allowed == 1) send_to_char("Pkilling allowed,\r\n", ch);
+ if (pk_allowed == 0) send_to_char("Pkilling not allowed,\r\n", ch);
+ if (sleep_allowed == 1) send_to_char("Casting sleep on other players allowed,\r\n", ch);
+ if (sleep_allowed == 0) send_to_char("Casting sleep on other players not allowed,\r\n", ch);
+ if (summon_allowed == 1) send_to_char("Summoning other players allowed,\r\n", ch);
+ if (summon_allowed == 0) send_to_char("Summoning other players not allowed,\r\n", ch);
+ if (charm_allowed == 1) send_to_char("Charming other players allowed,\r\n", ch);
+ if (charm_allowed == 0) send_to_char("Charming other players not allowed,\r\n", ch);
+ if (roomaffect_allowed == 1) send_to_char("Room affect spells will hurt other players.\r\n", ch);
+ if (roomaffect_allowed == 0) send_to_char("Room affect spells will not hurt other players.\r\n", ch);
+ }
+
}
diff -c -P -x *.o orig-src/clan.c src/clan.c
*** orig-src/clan.c Thu Jan 1 10:00:00 1970
--- src/clan.c Mon Feb 24 22:54:58 1997
***************
*** 0 ****
--- 1,2022 ----
+ /*
+ ************************************************************************
+ * File: clan.c Addition to CircleMUD *
+ * Usage: Source file for clan-specific code *
+ * *
+ * Copyright (c) to Daniel Muller *
+ * *
+ ************************************************************************ */
+
+ /*
+ * This file attempts to concentrate all of the clan specific code for the
+ * implementation of clans in CircleMUD. I've tried to mimic the code
+ * style of the rest of CircleMUD's code, to make it easier for you to
+ * modify as needed.
+ */
+
+
+
+ #include "conf.h"
+ #include "sysdep.h"
+ #include "string.h"
+
+ #include "structs.h"
+ #include "db.h"
+ #include "utils.h"
+ #include "spells.h"
+ #include "interpreter.h"
+ #include "comm.h"
+ #include "screen.h"
+ #include "clan.h"
+ #include "handler.h"
+
+ #define YES 1
+ #define NO 0
+
+ /* external vars */
+ extern struct clan_info *clan_index;
+ extern struct descriptor_data *descriptor_list;
+ extern char *class_abbrevs[];
+ extern FILE *player_fl;
+ extern int clan_top;
+ extern int mini_mud;
+
+ /* Local functions */
+ void prepare_colour_table(struct char_data *ch);
+ void update_clan_cross_reference();
+ void clan_save(int system, struct char_data *ch);
+ void write_clan(FILE *fl, int cnum);
+ void display_menu(struct char_data *ch, int cnum);
+ int is_clannum_already_used(int cnum);
+ void update_cnum(int oldcnum, int newcnum);
+ void setup_new_clan(struct char_data *ch, int cnum);
+ void setup_clan_edit(struct char_data *ch, int cnum);
+ void cleanup_clan_edit(struct descriptor_data *d, int method);
+ void refresh_clan_index();
+ void display_rank_menu(struct descriptor_data *d, int num);
+ void display_colour_menu(struct descriptor_data *d);
+ void fix_illegal_cnum();
+ int debug_clan(char *what, struct char_data *ch);
+ int already_being_edited(int cnum);
+
+ /*
+ * Clan levels
+ */
+ const int CLAN_APPLY = 1;
+ const int CLAN_SOLDIER = 2;
+ const int CLAN_SARGEANT = 3;
+ const int CLAN_CAPTAIN = 4;
+ const int CLAN_RULER = 5;
+
+ /* Define cross reference table */
+ int cross_reference[9999];
+
+ /* Define quick reference for colours (global) */
+ struct clan_colours clan_colour[8];
+
+ /* Define clan editing table */
+ struct clan_editing clan_edit[10];
+
+ /*
+ * General functions go here
+ */
+
+
+
+
+ /*
+ * The general player commands go here
+ */
+ ACMD(do_clan)
+ {
+ char subbcmd[MAX_INPUT_LENGTH], val_arg[MAX_INPUT_LENGTH];
+ int players_clan = 0, players_clannum = 0, ccmd = 0, value = 0, found = 0, temp = 0, temp2 = 0;
+ struct char_data *vict = NULL;
+ struct descriptor_data *pt;
+
+ half_chop(argument, subbcmd, buf);
+ strcpy(val_arg, buf);
+
+ /* if (ch) belongs to a clan, find its number in the index array */
+ if (!((PLAYERCLANNUM(ch) == 0) && (CLANRANK(ch) == 0)))
+ for (ccmd = 0; ccmd <= clan_top; ccmd++)
+ if (CLANNUM(clan_index[ccmd]) == PLAYERCLAN(ch))
+ {
+ players_clannum = ccmd;
+ players_clan = CLANNUM(clan_index[ccmd]);
+ }
+
+ if (players_clan == 0)
+ players_clan = -1;
+
+ /* Prepare the colour table for this player */
+ prepare_colour_table(ch);
+
+ /* Update clan cross reference */
+ update_clan_cross_reference();
+
+ if (strcasecmp(subbcmd, "debug") == 0)
+ {
+
+ if (GET_LEVEL(ch) != LVL_IMPL)
+ {
+ send_to_char("Huh?!\r\n", ch);
+ return;
+ }
+
+ /* Debug clan variables */
+ if (debug_clan(val_arg, ch) == NO)
+ send_to_char("Debug dump not written to disk.\r\n", ch);
+ else
+ send_to_char("Debug dump complete.\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "save") == 0)
+ {
+ /* Save clans */
+ if (!(GET_LEVEL(ch) >= LVL_GOD))
+ {
+ send_to_char("Huh?!", ch);
+ return;
+ }
+ clan_save(NO, ch);
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "edit") == 0)
+ {
+ if (!(GET_LEVEL(ch) == LVL_IMPL))
+ {
+ send_to_char("Huh?!", ch);
+ return;
+ }
+
+ value = atoi(val_arg);
+ if (value == 0)
+ {
+ send_to_char("Zero is an illegal clan number.\r\n", ch);
+ return;
+ }
+
+ if (already_being_edited(value) == YES)
+ {
+ send_to_char("Someone is already editing that clan number.\r\n", ch);
+ return;
+ }
+
+ if (is_clannum_already_used(value) == YES)
+ setup_clan_edit(ch, value);
+ else
+ setup_new_clan(ch, value);
+
+ STATE(ch->desc) = CON_CLAN_EDIT;
+
+ act("$n starts editing clans.", YES, ch, 0, 0, TO_ROOM);
+ SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "list") == 0)
+ {
+ /* Display title for list */
+ send_to_char("[ # Clan Title Clan Owner ]\r\n", ch);
+ /* List all clans and owners */
+ for (ccmd = 0; ccmd < clan_top; ccmd++)
+ {
+ sprintf(buf, " %4d %s%-25s%s %-15s\r\n",
+ CLANNUM(clan_index[ccmd]), CLANCOLOUR(ccmd),
+ CLANNAME(clan_index[ccmd]),
+ CCNRM(ch, C_NRM), CLANOWNER(clan_index[ccmd]));
+ send_to_char(buf, ch);
+ }
+ sprintf(buf, "\r\n[%d clans displayed.]\r\n", (ccmd));
+ send_to_char(buf, ch);
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "info") == 0)
+ {
+ /* Use index to retrieve information on clan */
+ value = atoi(val_arg);
+ if (value != 0)
+ {
+ for (ccmd = 0; ccmd < clan_top; ccmd++)
+ if (CLANNUM(clan_index[ccmd]) == value)
+ {
+ found = 1;
+ temp2 = 0;
+
+ /* Find number of members in clan */
+ temp = CLANPLAYERS(clan_index[ccmd]);
+
+ temp2 = 0;
+ /* Find number of clan members currently online */
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ pt->character->player_specials->saved.clannum == value)
+ temp2++;
+
+ /* Display info header */
+ sprintf(buf, "[%s", CLANCOLOUR(ccmd));
+
+ sprintf(buf, "%s%-25s%s]\r\n", buf, CLANNAME(clan_index[ccmd]), CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ send_to_char("\r\n", ch);
+ sprintf(buf, "Owner: %-15s\r\n", CLANOWNER(clan_index[ccmd]));
+ send_to_char(buf, ch);
+ sprintf(buf, "Clan Gold: %d\r\n", CLANGOLD(clan_index[ccmd]));
+ send_to_char(buf, ch);
+ sprintf(buf, "Members currently online: %-3d\r\nTotal number of members: %-3d\r\n", temp2, temp);
+ send_to_char(buf, ch);
+ send_to_char("\r\n", ch);
+
+ send_to_char(CCGRN(ch, C_NRM), ch);
+ send_to_char(CLANDESC(clan_index[ccmd]), ch);
+ send_to_char(CCNRM(ch, C_NRM), ch);
+
+ send_to_char("\r\n", ch);
+ }
+
+ if (found == 0)
+ {
+ send_to_char("Unable to find a clan with that number.\r\n", ch);
+ return;
+ }
+ }
+ else
+ {
+ send_to_char("Unable to find a clan with that number.\r\n", ch);
+ }
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "resign") == 0)
+ {
+ temp2 = 0;
+
+ /* This handles clan resignations */
+ if ((PLAYERCLANNUM(ch) == 0) && (CLANRANK(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(GET_NAME(ch), CLANOWNER(clan_index[players_clannum])) == 0)
+ {
+ send_to_char("You can't resign from a clan you own!\r\n", ch);
+ return;
+ }
+
+ PLAYERCLAN(ch) = 0;
+ CLANRANK(ch) = 0;
+
+ /* Update number of members in clan */
+ if (CLANRANK(ch) != CLAN_APPLY)
+ CLANPLAYERS(clan_index[players_clannum]) = CLANPLAYERS(clan_index[players_clannum]) - 1;
+
+ send_to_char("You have resigned from your clan.\r\n", ch);
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "apply") == 0)
+ {
+ /* This handles clan applications */
+ if (CLANRANK(ch) != 0)
+ {
+ send_to_char("You must resign from the clan you currently belong to, first.\r\n", ch);
+ return;
+ }
+
+ value = 0;
+ found = 0;
+ value = atoi(val_arg);
+ if (value >= 0)
+ {
+ for (ccmd = 0; ((ccmd < clan_top) && (found != 1)); ccmd++)
+ if (CLANNUM(clan_index[ccmd]) == value)
+ {
+ found = 1;
+
+ PLAYERCLAN(ch) = CLANNUM(clan_index[ccmd]);
+ CLANRANK(ch) = CLAN_APPLY;
+
+ sprintf(buf, "You have applied to the clan '%s'.\r\n",
+ CLANNAME(clan_index[ccmd]));
+ send_to_char(buf, ch);
+ }
+
+ if (found != 1)
+ {
+ send_to_char("Unable to find that clan.\r\n", ch);
+ return;
+ }
+ }
+ else
+ {
+ send_to_char("Which clan number?!\r\n", ch);
+ return;
+ }
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "enlist") == 0)
+ {
+ /* This handles the enlistment of characters who have applied to your
+ * clan.
+ *
+ * Implementors can force an enlistment. So, when creating a new clan,
+ * make sure your owner applies to join it. Then the implementor must
+ * do a 'clan enlist <character>' so that the owner belongs to the clan.
+ */
+
+ if (!(GET_LEVEL(ch) == LVL_IMPL))
+ {
+ if ((CLANRANK(ch) == 0) && (PLAYERCLANNUM(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (!(CLANRANK(ch) >= CLAN_SARGEANT))
+ {
+ send_to_char("You have insufficent rank in your clan to do this.\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) != CLAN_APPLY)
+ {
+ send_to_char("But that person isn't applying to any clan!\r\n", ch);
+ return;
+ }
+
+ if (PLAYERCLAN(vict) != PLAYERCLAN(ch))
+ {
+ send_to_char("But that person isn't applying to your clan!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict) = CLAN_SOLDIER;
+ sprintf(buf, "You have been enlisted into the ranks of the '%s' clan.\r\n",
+ CLANNAME(clan_index[players_clannum]));
+ send_to_char(buf, vict);
+
+ sprintf(buf, "You have enlisted '%s' into your clan.\r\n",
+ GET_NAME(vict));
+ send_to_char(buf, ch);
+
+ SET_BIT(PRF_FLAGS(vict), PRF_CLANTALK);
+
+ /* Update number of clan members */
+
+ CLANPLAYERS(clan_index[players_clannum])++;
+
+ }
+ else
+ {
+ send_to_char("But there is noone here by that name!\r\n", ch);
+ return;
+ }
+ }
+ else
+ {
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) != CLAN_APPLY)
+ {
+ send_to_char("But that person isn't applying to any clan!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(GET_NAME(vict),
+ CLANOWNER(clan_index[PLAYERCLANNUM(vict)])) == 0)
+ CLANRANK(vict) = CLAN_RULER;
+ else
+ CLANRANK(vict) = CLAN_SOLDIER;
+ log("Done forcing enlistment");
+
+ sprintf(buf, "You have forced the enlistment of '%s' into the clan '%s'.\r\n",
+ GET_NAME(vict), CLANNAME(clan_index[PLAYERCLANNUM(vict)]));
+ send_to_char(buf, ch);
+
+ sprintf(buf, "You have been enlisted into the clan '%s'.\r\n",
+ CLANNAME(clan_index[PLAYERCLANNUM(vict)]));
+ send_to_char(buf, vict);
+
+ /* Update number of clan members */
+ CLANPLAYERS(clan_index[PLAYERCLANNUM(vict)])++;
+ }
+ else
+ {
+ send_to_char("Unable to find a character of that name.\r\n", ch);
+ return;
+ }
+
+ }
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "promote") == 0)
+ {
+ /* Clan promotions */
+ if (CLANRANK(ch) < CLAN_CAPTAIN)
+ {
+ send_to_char("You have insufficent rank to do that.\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) > CLANRANK(ch))
+ {
+ send_to_char("You can't promote someone who ranks higher than you!\r\n", ch);
+ return;
+ }
+
+ if ((CLANRANK(vict) < CLAN_SOLDIER) ||
+ (PLAYERCLAN(vict) != PLAYERCLAN(ch)))
+ {
+ send_to_char("You can't promote someone who doesn't belong to your clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(vict) == CLAN_RULER)
+ {
+ send_to_char("You can't promote this person any higher in rank!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict)++;
+ sprintf(buf, "%sYou have been promoted to ", CCRED(vict, C_NRM));
+ if (CLANRANK(vict) == CLAN_SARGEANT)
+ strcat(buf, SARGEANTTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_RULER) strcat(buf, RULERTITLE(clan_index[players_clannum]));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, vict);
+
+ sprintf(buf, "%sYou have promoted '%s' to the rank of ",
+ CCRED(vict, C_NRM), GET_NAME(vict));
+ if (CLANRANK(vict) == CLAN_SARGEANT) strcat(buf, SARGEANTTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_RULER) strcat(buf, RULERTITLE(clan_index[players_clannum]));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+ }
+ else
+ {
+ send_to_char("Promote who?!\r\n", ch);
+ return;
+ }
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "demote") == 0)
+ {
+ /* Clan demotions */
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(ch) < CLAN_CAPTAIN)
+ {
+ send_to_char("You have insufficent rank to do that.\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) > CLANRANK(ch))
+ {
+ send_to_char("You can't demote someone who ranks higher than you!\r\n", ch);
+ return;
+ }
+
+ if ((CLANRANK(vict) < CLAN_SOLDIER) ||
+ (PLAYERCLAN(vict) != PLAYERCLAN(ch)))
+ {
+ send_to_char("You can't demote someone who doesn't belong to your clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(vict) == CLAN_SOLDIER)
+ {
+ send_to_char("You can't demote this person any lower! Try clan boot <person>!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(GET_NAME(vict), CLANOWNER(clan_index[players_clannum])) == 0)
+ {
+ send_to_char("You can't demote the clan owner!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict)--;
+ sprintf(buf, "%sYou have been demoted to ", CCRED(vict, C_NRM));
+ if (CLANRANK(vict) == CLAN_SOLDIER) strcat(buf, SOLDIERTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_SARGEANT) strcat(buf, SARGEANTTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(clan_index[players_clannum]));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, vict);
+
+ sprintf(buf, "%sYou have demoted '%s' to the rank of ",
+ CCRED(vict, C_NRM), GET_NAME(vict));
+ if (CLANRANK(vict) == CLAN_SOLDIER) strcat(buf, SOLDIERTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(clan_index[players_clannum]));
+ if (CLANRANK(vict) == CLAN_SARGEANT) strcat(buf, SARGEANTTITLE(clan_index[players_clannum]));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+ }
+ else
+ {
+ send_to_char("Demote who?!\r\n", ch);
+ return;
+ }
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "who") == 0)
+ {
+ /* List all clan members online, along with their clan rank */
+ if ((PLAYERCLANNUM(ch) == 0) && (CLANRANK(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ sprintf(buf, "Members of the clan '%s' currently online:\r\n",
+ CLANNAME(clan_index[players_clannum]));
+ send_to_char(buf, ch);
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ PLAYERCLAN(pt->character) == PLAYERCLAN(ch))
+ {
+ sprintf(buf, "%s[%2d %s ",
+ (GET_LEVEL(pt->character) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
+ GET_LEVEL(pt->character), CLASS_ABBR(pt->character));
+ if (CLANRANK(pt->character) == CLAN_APPLY) sprintf(buf, "%s%-10s", buf, "(Applying)");
+ if (CLANRANK(pt->character) == CLAN_SOLDIER)
+ sprintf(buf, "%s%-10s", buf, SOLDIERTITLE(clan_index[players_clannum]));
+ if (CLANRANK(pt->character) == CLAN_SARGEANT)
+ sprintf(buf, "%s%-10s", buf, SARGEANTTITLE(clan_index[players_clannum]));
+ if (CLANRANK(pt->character) == CLAN_CAPTAIN)
+ sprintf(buf, "%s%-10s", buf, CAPTAINTITLE(clan_index[players_clannum]));
+ if (CLANRANK(pt->character) == CLAN_RULER)
+ sprintf(buf, "%s%-10s", buf, RULERTITLE(clan_index[players_clannum]));
+ sprintf(buf, "%s] %s %s%s\r\n", buf, GET_NAME(pt->character), GET_TITLE(pt->character), CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+ }
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "say") == 0)
+ {
+ /* Clan say */
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(ch) < CLAN_SOLDIER)
+ {
+ send_to_char("You have insufficent rank to do that!\r\n", ch);
+ return;
+ }
+
+ if (!PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ send_to_char("Try turning your clan talk channel on first, dork!\r\n", ch);
+ return;
+ }
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ PLAYERCLAN(pt->character) == PLAYERCLAN(ch) &&
+ pt->character != ch && PRF_FLAGGED(pt->character, PRF_CLANTALK))
+ {
+ sprintf(buf, "%s%s says to the clan, '%s'%s\r\n", CCRED(pt->character, C_NRM),
+ GET_NAME(ch), val_arg, CCNRM(pt->character, C_NRM));
+ send_to_char(buf, pt->character);
+ }
+ sprintf(buf, "%sYou say to the clan, '%s'%s\r\n", CCRED(ch, C_NRM),
+ val_arg, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "channel") == 0)
+ {
+ if (PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ TOGGLE_BIT(PRF_FLAGS(ch), PRF_CLANTALK);
+ send_to_char("Clan talk channel turned off.\r\n", ch);
+ }
+ else
+ {
+ TOGGLE_BIT(PRF_FLAGS(ch), PRF_CLANTALK);
+ send_to_char("Clan talk channel turned on.\r\n", ch);
+ }
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "deposit") == 0)
+ {
+ /* This handles the process of depositing gold into the clan account */
+ /* This may only be done in the clan room */
+
+ if ((PLAYERCLANNUM(ch) == 0) && (CLANRANK(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(ch) < CLAN_SOLDIER)
+ {
+ send_to_char("You have insufficent rank to do that!\r\n", ch);
+ return;
+ }
+
+ if (ch->in_room != CLANROOM(clan_index[players_clannum]))
+ {
+ send_to_char("You can only do that in clan rooms!\r\n", ch);
+ return;
+ }
+
+ value = atoi(val_arg);
+ if (value != 0)
+ {
+ if (ch->points.gold < value)
+ {
+ send_to_char("But you don't have that much gold!\r\n", ch);
+ return;
+ }
+
+ ch->points.gold = ch->points.gold - value;
+
+ CLANGOLD(clan_index[players_clannum]) = CLANGOLD(clan_index[players_clannum]) + value;
+
+ sprintf(buf, "%d gold deposited into clan account.\r\n", value);
+ send_to_char(buf, ch);
+
+ }
+ else
+ {
+ send_to_char("Huh?\r\n", ch);
+ }
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "withdraw") == 0)
+ {
+ /* This handles withdrawals from the clan account */
+ if ((CLANRANK(ch) == 0) && (PLAYERCLANNUM(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+
+ value = atoi(val_arg);
+ if (value > -1)
+ {
+ if (CLANRANK(ch) < CLAN_RULER)
+ {
+ send_to_char("You have insufficent rank to do that!\r\n", ch);
+ return;
+ }
+
+ if (ch->in_room != CLANROOM(clan_index[players_clannum]))
+ {
+ send_to_char("But you can only do that in your clan room!\r\n", ch);
+ return;
+ }
+
+ if (CLANGOLD(clan_index[players_clannum]) < value)
+ {
+ send_to_char("But your clan doesn't have that much money!\r\n", ch);
+ return;
+ }
+ else
+ {
+ CLANGOLD(clan_index[players_clannum]) = CLANGOLD(clan_index[players_clannum]) - value;
+ ch->points.gold = ch->points.gold + value;
+ sprintf(buf, "%d gold coins withdrawn from the clan account.\r\n", value);
+ send_to_char(buf, ch);
+ }
+
+ }
+ else
+ {
+ send_to_char("Huh?\r\n", ch);
+ return;
+ }
+
+ return;
+ }
+
+ if (strcasecmp(subbcmd, "kick") == 0)
+ {
+ if ((CLANRANK(ch) == 0) && (PLAYERCLANNUM(ch) == 0))
+ {
+ send_to_char("But you do not belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(ch) < CLAN_RULER)
+ {
+ send_to_char("You have insufficent rank to do that!\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (PLAYERCLAN(vict) != PLAYERCLAN(ch))
+ {
+ send_to_char("But that person doesn't belong to your clan!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(CLANOWNER(clan_index[players_clannum]), GET_NAME(vict)) == 0)
+ {
+ send_to_char("You can't kick the clan owner out!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict) = 0;
+ PLAYERCLAN(vict) = 0;
+
+ sprintf(buf, "You have kicked '%s' from your clan.\r\n", GET_NAME(vict));
+ send_to_char(buf, ch);
+ sprintf(buf, "You have been kicked from the clan, '%s'.\r\n", CLANNAME(clan_index[players_clannum]));
+ send_to_char(buf, vict);
+
+ /* Update number of members in clan */
+ if (CLANRANK(vict) != CLAN_APPLY)
+ CLANPLAYERS(clan_index[players_clannum])--;
+
+ }
+ else
+ {
+ send_to_char("Can't find that person.\r\n", ch);
+ return;
+ }
+ return;
+ }
+
+
+ /* If no recognised subcommand given, display help */
+ if (strcasecmp(subbcmd, "help") != 0)
+ {
+ send_to_char("Clan help:\r\n", ch);
+ send_to_char("\r\n", ch);
+ if (CLANRANK(ch) == 0)
+ send_to_char("apply, info, list.\r\n", ch);
+ if (CLANRANK(ch) == CLAN_APPLY)
+ send_to_char("info, list, resign, who.\r\n", ch);
+ if (CLANRANK(ch) == CLAN_SOLDIER)
+ send_to_char("channel, deposit, info, list, resign, say, who.\r\n", ch);
+ if (CLANRANK(ch) == CLAN_SARGEANT)
+ send_to_char("channel, deposit, enlist, info, list, resign, say, who.\r\n", ch);
+ if (CLANRANK(ch) == CLAN_CAPTAIN)
+ send_to_char("channel, demote, deposit, enlist, info, list, promote, resign, say, who.\r\n", ch);
+ if (CLANRANK(ch) == CLAN_RULER)
+ {
+ send_to_char("channel, demote, deposit, enlist, info, kick, list, promote, resign, say,\r\n", ch);
+ send_to_char("withdraw, who.\r\n", ch);
+ }
+ if (GET_LEVEL(ch) == LVL_IMPL)
+ {
+ send_to_char("\r\nImplementor commands:\r\n", ch);
+ send_to_char("debug, edit, save.\r\n", ch);
+ }
+ send_to_char("\r\n", ch);
+ send_to_char("For further help type: clan help <command>\r\n", ch);
+ return;
+ }
+ else
+ {
+ if (strcasecmp(val_arg, "debug") == 0)
+ {
+ send_to_char("CLAN DEBUG <type>\r\n", ch);
+ send_to_char("\r\nDump debug information to debug file.\r\n", ch);
+ send_to_char("Type 'clan debug' for more information.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "save") == 0)
+ {
+ send_to_char("CLAN SAVE\r\n", ch);
+ send_to_char("\r\nSave clan data to clan files.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "edit") == 0)
+ {
+ send_to_char("CLAN EDIT <num>\r\n", ch);
+ send_to_char("\r\nEnter full screen clan editor for clan <num>.\r\n", ch);
+ send_to_char("If <num> doesn't exist, a clan will be created.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "apply") == 0)
+ {
+ send_to_char("CLAN APPLY <num>\r\n", ch);
+ send_to_char("\r\n", ch);
+ send_to_char("Apply to the clan with the number <num>. To find out the number of a\r\n", ch);
+ send_to_char("clan, use the CLAN INFO command.\r\n", ch);
+ send_to_char("\r\nRelated topics: resign, enlist.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "kick") == 0)
+ {
+ send_to_char("CLAN KICK <player>\r\n", ch);
+ send_to_char("\r\nThis kicks <player> from your clan.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "channel") == 0)
+ {
+ send_to_char("CLAN CHANNEL\r\n", ch);
+ send_to_char("\r\nUsed to toggle the clan talk channel. Similar to the gossip channel command.\r\n", ch);
+ send_to_char("\r\nRelated topics: say.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "demote") == 0)
+ {
+ send_to_char("CLAN DEMOTE <player>\r\n", ch);
+ send_to_char("\r\nThis command demotes <player> one rank in your clan.\r\n", ch);
+ send_to_char("\r\nRelated topics: promote.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "deposit") == 0)
+ {
+ send_to_char("CLAN DEPOSIT <amount>\r\n", ch);
+ send_to_char("\r\nThis command deposits <amount> of gold into the clan account.\r\n", ch);
+ send_to_char("This can only be done in the clan room.\r\n", ch);
+ send_to_char("\r\nRelated topics: withdraw.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "enlist") == 0)
+ {
+ send_to_char("CLAN ENLIST <player>\r\n", ch);
+ send_to_char("\r\nThis command enlists <player> into your clan.\r\n", ch);
+ send_to_char("<player> must be applying to your clan first, of course.\r\n", ch);
+ if (GET_LEVEL(ch) == LVL_IMPL)
+ send_to_char("\r\nAs an implementor you can force the enlisting of <player> into\r\nthe clan they are applying for whether you are in that clan or not.\r\n", ch);
+
+ send_to_char("\r\nRelated topics: apply, resign.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "info") == 0)
+ {
+ send_to_char("CLAN INFO <num>\r\n", ch);
+ send_to_char("\r\nThis command gives info on the clan <num>. To get the number of a\r\n", ch);
+ send_to_char("clan, use the CLAN LIST command.\r\n", ch);
+ send_to_char("\r\nRelated topics: list.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "list") == 0)
+ {
+ send_to_char("CLAN LIST\r\n", ch);
+ send_to_char("\r\nThis command lists all the existing clans.\r\n", ch);
+ send_to_char("\r\nRelated topics: info.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "promote") == 0)
+ {
+ send_to_char("CLAN PROMOTE <player>\r\n", ch);
+ send_to_char("\r\nThis command promotes <player> a level in your clan. Provided\r\n", ch);
+ send_to_char("they already belong to your clan.\r\n", ch);
+ send_to_char("\r\nRelated topics: demote, enlist.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "resign") == 0)
+ {
+ send_to_char("CLAN RESIGN\r\n", ch);
+ send_to_char("\r\nThis command resigns you from your clan.\r\n", ch);
+ send_to_char("\r\nRelated topics: apply, enlist.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "say") == 0)
+ {
+ send_to_char("CLAN SAY <message>\r\n", ch);
+ send_to_char("\r\nThis command passes a message onto your fellow clan members.\r\n", ch);
+ send_to_char("Much the same as GOSSIP.\r\n", ch);
+ send_to_char("Abbreviation: | <message>\r\n", ch);
+ send_to_char("\r\nRelated topics: channel.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "withdraw") == 0)
+ {
+ send_to_char("CLAN WITHDRAW <amount>\r\n", ch);
+ send_to_char("\r\nThis withdraws <amount> of gold from the clan account.\r\n", ch);
+ send_to_char("You must be in the clan room to do this.\r\n", ch);
+ send_to_char("\r\nRelated topics: deposit.\r\n", ch);
+ return;
+ }
+ if (strcasecmp(val_arg, "who") == 0)
+ {
+ send_to_char("CLAN WHO\r\n", ch);
+ send_to_char("\r\nThis command is similar to WHO. It displays all the clan members\r\n", ch);
+ send_to_char("currently online. As well as their rank in the clan.\r\n", ch);
+ send_to_char("\r\nRelated topics: list, info.\r\n", ch);
+ return;
+ }
+ send_to_char("Huh?\r\n", ch);
+ }
+
+ };
+
+ ACMD(do_clansay)
+ {
+ struct descriptor_data *pt;
+
+ /* Clan say */
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (!PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ send_to_char("Try turning your clan talk channel on first, dork!\r\n", ch);
+ return;
+ }
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ PLAYERCLAN(pt->character) == PLAYERCLAN(ch) &&
+ pt->character != ch && PRF_FLAGGED(pt->character, PRF_CLANTALK))
+ {
+ sprintf(buf, "%s%s says to the clan, '%s'%s\r\n", CCRED(pt->character, C_NRM),
+ GET_NAME(ch), argument, CCNRM(pt->character, C_NRM));
+ send_to_char(buf, pt->character);
+ }
+ sprintf(buf, "%sYou say to the clan, '%s'%s\r\n", CCRED(ch, C_NRM),
+ argument, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ };
+
+ /*
+ * The following procedures attempt to fit into the db.c load procedures
+ * to allow the dynamic creation, editing, and removal of clans whilst
+ * in game play.
+ *
+ * Most of these functions will be almost direct copies of the db.c
+ * procedures.
+ *
+ */
+
+ void parse_clan(FILE *fl, int virtual_nr)
+ {
+ static int clan_nr = 0;
+ int t[10];
+ char line[256];
+
+ sprintf(buf2, "Parsing clan #%d", virtual_nr);
+ log(buf2);
+
+ clan_index[clan_nr].number = virtual_nr;
+ clan_index[clan_nr].title = fread_string(fl, buf2);
+ clan_index[clan_nr].description = fread_string(fl, buf2);
+ clan_index[clan_nr].owner = fread_string(fl, buf2);
+ clan_index[clan_nr].ranksoldiertitle = fread_string(fl, buf2);
+ clan_index[clan_nr].ranksargeanttitle = fread_string(fl, buf2);
+ clan_index[clan_nr].rankcaptaintitle = fread_string(fl, buf2);
+ clan_index[clan_nr].rankrulertitle = fread_string(fl, buf2);
+
+ if (!get_line(fl,line) || sscanf(line, " %d %d %d %d ", t, t + 1, t + 2, t + 3) != 4) {
+ fprintf(stderr, "Format error in clan #%d\n", virtual_nr);
+ exit(1);
+ }
+
+ clan_index[clan_nr].clanroom = t[0];
+ clan_index[clan_nr].clangold = t[1];
+ clan_index[clan_nr].nummembers = t[2];
+ clan_index[clan_nr].colour = t[3];
+ clan_index[clan_nr].status = CLAN_OLD;
+
+ }
+
+ void prepare_colour_table(struct char_data *ch)
+ {
+ clan_colour[0].colour_string = CCWHT(ch, C_NRM);
+ clan_colour[1].colour_string = CCGRN(ch, C_NRM);
+ clan_colour[2].colour_string = CCRED(ch, C_NRM);
+ clan_colour[3].colour_string = CCBLU(ch, C_NRM);
+ clan_colour[4].colour_string = CCMAG(ch, C_NRM);
+ clan_colour[5].colour_string = CCYEL(ch, C_NRM);
+ clan_colour[6].colour_string = CCCYN(ch, C_NRM);
+ clan_colour[7].colour_string = CCNRM(ch, C_NRM);
+ }
+
+ void update_clan_cross_reference()
+ {
+ int i = 0;
+
+ for (i = 0; i < 9999; i++)
+ cross_reference[i] = -1;
+
+ for (i = 0; i < clan_top; i++)
+ cross_reference[CLANNUM(clan_index[i])] = i;
+
+ }
+
+ void clan_save(int system, struct char_data *ch)
+ {
+ int i = 0, found = 0, last = 0, rec_count = 0, files = 0;
+ FILE *fl, *index;
+ char *index_file;
+ char line[256];
+ int reference[9999];
+
+ if (mini_mud)
+ index_file = MINDEX_FILE;
+ else
+ index_file = INDEX_FILE;
+
+ sprintf(buf, "%s/%s", CLAN_PREFIX, index_file);
+
+ if (!(index = fopen(buf, "r")))
+ {
+ log("FUNCTION(clan_save): Unable to open clan index file");
+ if (system == NO)
+ send_to_char("ClanSave: Unable to open index file (ERROR)\r\n", ch);
+ return;
+ }
+
+ fscanf(index, "%s\n", buf);
+ while (*buf != '$')
+ {
+ sprintf(buf2, "%s/%s", CLAN_PREFIX, buf);
+ if (!(fl = fopen(buf2, "r")))
+ {
+ log("FUNCTION(clan_save): Unable to open sub file from index file");
+ if (system == NO)
+ {
+ sprintf(buf, "ClanSave: Unable to open '%s' (ERROR)\r\n", buf2);
+ send_to_char(buf, ch);
+ }
+ return;
+ }
+ else
+ {
+ rec_count = 0;
+
+ while (found == 0)
+ {
+ if (!get_line(fl, line))
+ {
+ log("FUNCTION(clan_save): Format error encountered");
+ if (system == NO);
+ {
+ sprintf(buf, "ClanSave: Format error after clan #%d (ERROR)\r\n", i);
+ send_to_char(buf, ch);
+ }
+ exit(1);
+ }
+
+ if (*line == '$')
+ found = 1;
+
+ if (*line == '#')
+ {
+ last = i;
+
+ if (sscanf(line, "#%d", &i) != 1)
+ {
+ log("FUNCTION(clan_save): Format error in clan file");
+ if (system == NO)
+ {
+ sprintf(buf, "ClanSave: Format error after clan #%d\r\n", last);
+ send_to_char(buf, ch);
+ }
+ exit(1);
+ }
+
+ if (i >= 99999)
+ return;
+
+ reference[rec_count] = i;
+ rec_count++;
+ }
+ }
+
+ /* Now that we have a list of the clan #'s in this clan file */
+ /* We replace them with the updated records */
+ fclose(fl);
+
+ sprintf(buf2, "%s/%s", CLAN_PREFIX, buf);
+ if (!(fl = fopen(buf2, "w")))
+ {
+ log("FUNCTION(clan_save): Error truncuating clan file for rewrite");
+ if (system == NO)
+ {
+ sprintf(buf, "ClanSave: Unable to truncuate '%s' (ERROR)\r\n", buf2);
+ send_to_char(buf, ch);
+ }
+ return;
+ }
+
+ for (i = 0; i < rec_count; i++)
+ write_clan(fl, reference[i]);
+
+ /* New clan records go at the end of the first file in the index */
+ if (files == 0)
+ for (i = 0; i < clan_top; i++)
+ if (CLANSTATUS(i) == CLAN_NEW)
+ {
+ write_clan(fl, CLANNUM(clan_index[i]));
+ CLANSTATUS(i) = CLAN_OLD;
+ }
+
+ fputs("$~\n", fl);
+ fclose(fl);
+ }
+
+ fscanf(index, "%s\n", buf);
+ files++;
+ }
+
+ log("Successfully saved clan details");
+
+ if (system == NO)
+ send_to_char("Clans saved.\r\n", ch);
+
+ }
+
+ void write_clan(FILE *fl, int cnum)
+ {
+ int j = 0;
+
+ log("Whew! Made it to the 'write_clan' function");
+
+ update_clan_cross_reference();
+ j = cross_reference[cnum];
+
+ if (j == -1) return;
+
+ fprintf(stderr, "Writing clan #%d which is '%s'\n", cnum, clan_index[j].title);
+
+
+ fprintf(fl, "#%d\n", clan_index[j].number);
+ fprintf(fl, "%s~\n", clan_index[j].title);
+ fprintf(fl, "%s\n~\n", clan_index[j].description);
+ fprintf(fl, "%s~\n", clan_index[j].owner);
+ fprintf(fl, "%s~\n", clan_index[j].ranksoldiertitle);
+ fprintf(fl, "%s~\n", clan_index[j].ranksargeanttitle);
+ fprintf(fl, "%s~\n", clan_index[j].rankcaptaintitle);
+ fprintf(fl, "%s~\n", clan_index[j].rankrulertitle);
+ fprintf(fl, "%d %d %d %d\n", clan_index[j].clanroom,
+ clan_index[j].clangold, clan_index[j].nummembers,
+ clan_index[j].colour);
+
+ }
+
+ void display_menu(struct char_data *ch, int cnum)
+ {
+
+ sprintf(buf, "\x1B[H\x1B[J"
+ "%s[Editing clan record]%s\r\n\r\n",
+ CCRED(ch, C_NRM), CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%sClan #%s%4d%s", CCYEL(ch, C_NRM), CCGRN(ch, C_NRM),
+ cnum, CCNRM(ch, C_NRM));
+ sprintf(buf, "%54s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s'%s'%s",
+ CLANCOLOUR(cross_reference[cnum]),
+ CLANNAME(clan_index[cross_reference[cnum]]),
+ CCNRM(ch, C_NRM));
+ sprintf(buf, "%54s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%sClan Gold : %s%d", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ CLANGOLD(clan_index[cross_reference[cnum]]));
+ sprintf(buf, "\r\n%50s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%sClan Room : %s%d", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ CLANROOM(clan_index[cross_reference[cnum]]));
+ sprintf(buf, "%50s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%sClan Owner : %s%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ CLANOWNER(clan_index[cross_reference[cnum]]));
+ sprintf(buf, "%56s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s1. %sChange clan number%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "\r\n%59s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s2. %sChange clan name%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%57s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s3. %sChange clan owner%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%58s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s4. %sChange clan description%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%64s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s5. %sChange clan colour%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%59s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s6. %sChange clan gold%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%57s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s7. %sChange clan room%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%57s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%s8. %sChange clan ranks%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%58s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%sQ. %sQuit editing clan%s", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM), CCNRM(ch, C_NRM));
+ sprintf(buf, "%58s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ sprintf(buf2, "%sD. %sDelete clan%s", CCYEL(ch, C_NRM), CCGRN(ch, C_NRM),
+ CCNRM(ch, C_NRM));
+ sprintf(buf, "\r\n%52s\r\n", buf2);
+ send_to_char(buf, ch);
+
+ }
+
+ /* Some generic tests */
+ int is_clannum_already_used(int cnum)
+ {
+ update_clan_cross_reference();
+
+ if (cross_reference[cnum] >= 0)
+ return YES;
+
+
+ return NO;
+
+ }
+
+ int already_being_edited(int cnum)
+ {
+ int i = 0;
+
+ for (i = 0; i < 10; i ++)
+ if (CLAN_EDIT_CLAN(i) == cnum) return YES;
+
+ return NO;
+ }
+
+ void update_cnum(int oldcnum, int newcnum)
+ {
+ struct descriptor_data *pt;
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ PLAYERCLAN(pt->character) == oldcnum)
+ PLAYERCLAN(pt->character) = newcnum;
+
+ clan_index[cross_reference[oldcnum]].number = newcnum;
+
+ update_clan_cross_reference();
+ }
+
+ void setup_new_clan(struct char_data *ch, int cnum)
+ {
+ int i = 0;
+ int node_assigned = 0;
+
+ for (i = 0; i < 10; i++)
+ if ((CLAN_EDIT_DESC(i) == NULL) && (node_assigned == NO))
+ {
+ CLAN_EDIT_DESC(i) = ch->desc;
+ CLAN_EDIT_CLAN(i) = cnum;
+ CLAN_EDIT_MODE(i) = CLAN_EDIT_MAIN_MENU;
+ node_assigned = YES;
+ }
+
+ if (node_assigned == NO)
+ {
+ send_to_char("Sorry, but all editing slots are full. Try again later.\r\n", ch);
+ cleanup_clan_edit(ch->desc, CLEAN_ALL);
+ return;
+ }
+
+ clan_index[clan_top].number = cnum;
+ clan_index[clan_top].title = str_dup("New Clan");
+ clan_index[clan_top].owner = str_dup(GET_NAME(ch));
+ clan_index[clan_top].description = str_dup("A new clan");
+ clan_index[clan_top].clangold = 0;
+ clan_index[clan_top].clanroom = 0;
+ clan_index[clan_top].colour = CLAN_NORMAL;
+ clan_index[clan_top].ranksoldiertitle = str_dup("Soldier");
+ clan_index[clan_top].ranksargeanttitle = str_dup("Sargeant");
+ clan_index[clan_top].rankcaptaintitle = str_dup("Captain");
+ clan_index[clan_top].rankrulertitle = str_dup("Ruler");
+ clan_index[clan_top].status = CLAN_NEW;
+
+ clan_top++;
+
+ update_clan_cross_reference();
+
+ display_menu(ch, cnum);
+
+ }
+
+ void setup_clan_edit(struct char_data *ch, int cnum)
+ {
+ int i = 0;
+ int node_assigned = 0;
+
+ for (i = 0; i < 10; i++)
+ if ((CLAN_EDIT_DESC(i) == NULL) && (node_assigned == NO))
+ {
+ CLAN_EDIT_DESC(i) = ch->desc;
+ CLAN_EDIT_CLAN(i) = cnum;
+ CLAN_EDIT_MODE(i) = CLAN_EDIT_MAIN_MENU;
+ node_assigned = YES;
+ }
+
+ if (node_assigned == NO)
+ {
+ send_to_char("Sorry, but all editing slots are full. Try again later.\r\n", ch);
+ cleanup_clan_edit(ch->desc, CLEAN_ALL);
+ return;
+ }
+
+ display_menu(ch, cnum);
+
+ }
+
+ void cleanup_clan_edit(struct descriptor_data *d, int method)
+ {
+ int i = 0;
+
+ for (i = 0; i < 10; i++)
+ if (CLAN_EDIT_DESC(i) == d)
+ {
+ CLAN_EDIT_DESC(i) = NULL;
+ CLAN_EDIT_MODE(i) = 0;
+ if (method == CLEAN_ALL)
+ CLANSTATUS(cross_reference[CLAN_EDIT_CLAN(i)]) = CLAN_DELETE;
+ CLAN_EDIT_CLAN(i) = 0;
+ }
+
+ refresh_clan_index();
+
+ if (d->character)
+ {
+ STATE(d) = CON_PLAYING;
+ REMOVE_BIT(PLR_FLAGS(d->character), PLR_WRITING);
+ act("$n stops editing clans.", YES, d->character, 0, 0, TO_ROOM);
+ }
+
+ if (method == CLEAN_ALL)
+ fix_illegal_cnum();
+
+ }
+
+ void fix_illegal_cnum()
+ {
+ /* Search out and destroy cnum's in player's records which no longer */
+ /* exist in the clan_index array */
+ int i = 0, valid = 0;
+ struct descriptor_data *pt;
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ {
+ for (i = 0; i < clan_top; i++)
+ if (clan_index[i].number == PLAYERCLAN(pt->character)) valid = YES;
+ if (valid == NO)
+ {
+ sprintf(buf, "(ILLEGAL CLAN NUMBER FOUND) belonging to '%s' - #%d\n",
+ GET_NAME(pt->character), PLAYERCLAN(pt->character));
+ fprintf(stderr, "%s", buf);
+ PLAYERCLAN(pt->character) = -1;
+ CLANRANK(pt->character) = 0;
+ }
+ valid = NO;
+ }
+
+ log("Done fixing illegal clannum links");
+
+ }
+
+ void refresh_clan_index()
+ {
+ int i = 0;
+ int j = 0;
+ int k = 0;
+
+ for (i = 0; i < clan_top; i++)
+ if (CLANSTATUS(i) == CLAN_DELETE)
+ {
+
+ k = clan_index[i].number;
+ clan_index[i].number = -1;
+ update_cnum(k, -1);
+ if (i != (clan_top - 1))
+ for (j = i; j < (clan_top - 1); j++)
+ clan_index[j] = clan_index[j + 1];
+ clan_top--;
+ }
+
+ update_clan_cross_reference();
+
+ }
+
+ void parse_clan_edit(struct descriptor_data *d, char *arg)
+ {
+ int i = 0;
+ int num = -1;
+
+ for (i = 0; i < 10; i++)
+ if (CLAN_EDIT_DESC(i) == d) num = i;
+
+ if (num == -1) return;
+
+ switch (CLAN_EDIT_MODE(num))
+ {
+ case CLAN_EDIT_MAIN_MENU:
+ switch (*arg)
+ {
+ case 'd':
+ case 'D':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_CONFIRM_DELETE;
+ send_to_char("\r\nAre you sure you wish to delete this clan? [Yy/Nn]", d->character);
+ break;
+ case 'q':
+ case 'Q':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_CONFIRM_SAVE;
+ send_to_char("\r\nDo you wish to save this clan? [Yy/Nn]", d->character);
+ break;
+ case '1':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_NUMBER;
+ send_to_char("\r\nEnter new clan number: ", d->character);
+ break;
+ case '2':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_NAME;
+ send_to_char("\r\nEnter clan name: \r\n", d->character);
+ break;
+ case '3':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_OWNER;
+ send_to_char("\r\nEnter clan owners name: \r\n", d->character);
+ break;
+ case '4':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_DESCRIPTION;
+ SEND_TO_Q("\x1B[H\x1B[J", d);
+ /*
+ * Attempting the impossible - Using the inbuilt text editor */
+ clan_index[cross_reference[CLAN_EDIT_CLAN(num)]].old_description = NULL;
+ clan_index[cross_reference[CLAN_EDIT_CLAN(num)]].old_description =
+ str_dup(CLANDESC(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]));
+ SEND_TO_Q("Old clan description:\r\n\r\n", d);
+ SEND_TO_Q(CLANDESC(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]), d);
+ SEND_TO_Q("\r\n\r\nEnter new description: \r\n\r\n", d);
+ clan_index[cross_reference[CLAN_EDIT_CLAN(num)]].description = NULL;
+ d->str = &clan_index[cross_reference[CLAN_EDIT_CLAN(num)]].description;
+ d->max_str = 1000;
+ break;
+ case '5':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_COLOUR;
+ display_colour_menu(d);
+ break;
+ case '6':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_GOLD;
+ send_to_char("\r\nEnter new gold value: ", d->character);
+ break;
+ case '7':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_CLANROOM;
+ send_to_char("\r\nEnter new clan room: ", d->character);
+ break;
+ case '8':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_RANK_MENU;
+ display_rank_menu(d, num);
+ break;
+ default:
+ send_to_char("r\nInvalid command!", d->character);
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+ }
+ return;
+
+ case CLAN_EDIT_DESCRIPTION_FINISHED:
+ switch (*arg)
+ {
+ case 'S':
+ case 's':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+ default:
+ CLANDESC(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) =
+ str_dup(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]].old_description);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+ }
+ break;
+
+ case CLAN_EDIT_CONFIRM_DELETE:
+ switch (*arg)
+ {
+ case 'Y':
+ case 'y':
+ CLANSTATUS(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_DELETE;
+ refresh_clan_index();
+ cleanup_clan_edit(d, CLEAN_NODE);
+ send_to_char("\r\nClan deleted.\r\n", d->character);
+ break;
+ case 'N':
+ case 'n':
+ send_to_char("\r\nNOT deleted.\r\n", d->character);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+ }
+ break;
+
+ case CLAN_EDIT_CONFIRM_SAVE:
+ switch (*arg)
+ {
+ case 'Y':
+ case 'y':
+ cleanup_clan_edit(d, CLEAN_NODE);
+ send_to_char("\r\nSaved.\r\n", d->character);
+ break;
+ case 'N':
+ case 'n':
+ cleanup_clan_edit(d, CLEAN_ALL);
+ send_to_char("\r\nNOT saved.\r\n", d->character);
+ break;
+ default:
+ send_to_char("\r\nInvalid command!", d->character);
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+ }
+ return;
+
+ case CLAN_EDIT_NUMBER:
+ i = 0;
+ i = atoi(arg);
+ if (!(i <= 0))
+ {
+ if (is_clannum_already_used(i) == NO)
+ {
+ update_cnum(CLAN_EDIT_CLAN(num), i);
+ CLAN_EDIT_CLAN(num) = i;
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ else
+ {
+ send_to_char("\r\nThat number already in use!\r\n", d->character);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ }
+ else
+ {
+ send_to_char("\r\nInvalid number!\r\n", d->character);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ break;
+
+ case CLAN_EDIT_NAME:
+ CLANNAME(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) = str_dup(arg);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+
+ case CLAN_EDIT_OWNER:
+ /* No error checking here */
+ CLANOWNER(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) = str_dup(arg);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+
+ case CLAN_EDIT_GOLD:
+ i = 0;
+ i = atoi(arg);
+ if (!(i <= 0))
+ {
+ CLANGOLD(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) = i;
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ else
+ {
+ send_to_char("\r\nInvalid number!\r\n", d->character);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ break;
+
+ case CLAN_EDIT_CLANROOM:
+ /* No error checking */
+ i = 0;
+ i = atoi(arg);
+ if (!(i <= 0))
+ {
+ CLANROOM(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) = i;
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ else
+ {
+ send_to_char("\r\nInvalid number!\r\n", d->character);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ }
+ break;
+
+ case CLAN_EDIT_COLOUR:
+ switch (*arg)
+ {
+ case 'w':
+ case 'W':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_WHITE;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'n':
+ case 'N':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_NORMAL;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'r':
+ case 'R':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_RED;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'g':
+ case 'G':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_GREEN;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'b':
+ case 'B':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_BLUE;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'y':
+ case 'Y':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_YELLOW;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'm':
+ case 'M':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_MAGENTA;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ case 'c':
+ case 'C':
+ CLANCOLOR(cross_reference[CLAN_EDIT_CLAN(num)]) = CLAN_CYAN;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ default:
+ send_to_char("Invalid colour!\r\n", d->character);
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+ }
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ break;
+
+ case CLAN_EDIT_SOLDIER:
+ SOLDIERTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) =
+ str_dup(arg);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_RANK_MENU;
+ display_rank_menu(d, num);
+ break;
+
+ case CLAN_EDIT_SARGEANT:
+ SARGEANTTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) =
+ str_dup(arg);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_RANK_MENU;
+ display_rank_menu(d, num);
+ break;
+
+ case CLAN_EDIT_CAPTAIN:
+ CAPTAINTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) =
+ str_dup(arg);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_RANK_MENU;
+ display_rank_menu(d, num);
+ break;
+
+ case CLAN_EDIT_RULER:
+ RULERTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]) =
+ str_dup(arg);
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_RANK_MENU;
+ display_rank_menu(d, num);
+ break;
+
+ case CLAN_EDIT_RANK_MENU:
+ switch (*arg)
+ {
+ case '1':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_SOLDIER;
+ send_to_char("\r\nEnter new soldier rank: \r\n", d->character);
+ break;
+ case '2':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_SARGEANT;
+ send_to_char("\r\nEnter new sargeant rank: \r\n", d->character);
+ break;
+ case '3':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_CAPTAIN;
+ send_to_char("\r\nEnter new captain rank: \r\n", d->character);
+ break;
+ case '4':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_RULER;
+ send_to_char("\r\nEnter new ruler rank: \r\n", d->character);
+ break;
+ case 'q':
+ case 'Q':
+ CLAN_EDIT_MODE(num) = CLAN_EDIT_MAIN_MENU;
+ display_menu(d->character, CLAN_EDIT_CLAN(num));
+ break;
+ default:
+ send_to_char("\r\nInvalid command!\r\n", d->character);
+ display_rank_menu(d, num);
+ break;
+ }
+ break;
+
+ }
+
+ }
+
+ void display_colour_menu(struct descriptor_data *d)
+ {
+ struct char_data *ch;
+
+ ch = d->character;
+
+ send_to_char("\r\n\x1B[H\x1B[J", ch);
+ sprintf(buf, "%s(W)hite\r\n", CCWHT(ch, C_NRM));
+ sprintf(buf, "%s%s(R)ed\r\n", buf, CCRED(ch, C_NRM));
+ sprintf(buf, "%s%s(G)reen\r\n", buf, CCGRN(ch, C_NRM));
+ sprintf(buf, "%s%s(B)lue\r\n", buf, CCBLU(ch, C_NRM));
+ sprintf(buf, "%s%s(Y)ellow\r\n", buf, CCYEL(ch, C_NRM));
+ sprintf(buf, "%s%s(M)agenta\r\n", buf, CCMAG(ch, C_NRM));
+ sprintf(buf, "%s%s(C)yan\r\n", buf, CCCYN(ch, C_NRM));
+ sprintf(buf, "%s%s(N)ormal\r\n", buf, CCNRM(ch, C_NRM));
+ sprintf(buf, "%s\r\nSelect a colour: ", buf);
+ send_to_char(buf, ch);
+
+ }
+
+ void display_rank_menu(struct descriptor_data *d, int num)
+ {
+ struct char_data *ch;
+
+ ch = d->character;
+
+ sprintf(buf, "\x1B[H\x1B[J\r\n%sSoldier Rank : %s%s\r\n", CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ SOLDIERTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]));
+ sprintf(buf, "%s%sSargeant Rank: %s%s\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ SARGEANTTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]));
+ sprintf(buf, "%s%sCaptain Rank : %s%s\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ CAPTAINTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]));
+ sprintf(buf, "%s%sRuler Rank: %s%s\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM),
+ RULERTITLE(clan_index[cross_reference[CLAN_EDIT_CLAN(num)]]));
+ sprintf(buf, "%s\r\n%s1. %sEdit Soldier Rank\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM));
+ sprintf(buf, "%s%s2. %sEdit Sargeant Rank\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM));
+ sprintf(buf, "%s%s3. %sEdit Captain Rank\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM));
+ sprintf(buf, "%s%s4. %sEdit Ruler Rank\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM));
+ sprintf(buf, "%s\r\n%sQ. %sReturn to main menu\r\n", buf, CCYEL(ch, C_NRM),
+ CCGRN(ch, C_NRM));
+ send_to_char(buf, ch);
+
+
+ }
+
+ /* Debug stuff goes here */
+ int debug_clan(char *what, struct char_data *ch)
+ {
+ int i = 0, count = 0, debug_type = 0;
+ time_t ct;
+ char *tmstr;
+ FILE *fl = NULL;
+
+ /* Find type of debug request */
+ if (strcasecmp(what, "cref") == 0)
+ debug_type = CLAN_DEBUG_CREF;
+ if (strcasecmp(what, "node") == 0)
+ debug_type = CLAN_DEBUG_NODE;
+ if (strcasecmp(what, "var") == 0)
+ debug_type = CLAN_DEBUG_VAR;
+ if (strcasecmp(what, "all") == 0)
+ debug_type = CLAN_DEBUG_ALL;
+
+ if (debug_type != CLAN_DEBUG_UNKNOWN)
+ {
+ /* Open debug file */
+ sprintf(buf, "%s/DEBUG", CLAN_PREFIX);
+ if (!(fl = fopen(buf, "a")))
+ {
+ fprintf(stderr, "Error opening clan debug file '%s'!\n", buf);
+ return NO;
+ }
+
+ /* DateTime stamp entry */
+ ct = time(0);
+ tmstr = asctime(localtime(&ct));
+ *(tmstr + strlen(tmstr) - 1 ) = '\0';
+ fprintf(fl, "%-19.19s :: Debug requested by user\n", tmstr);
+ fprintf(fl, "\nDebug requested by: %s\n", GET_NAME(ch));
+ }
+
+ if ((debug_type == CLAN_DEBUG_VAR) || (debug_type == CLAN_DEBUG_ALL))
+ {
+ /* Dump relevant global variables */
+ fprintf(fl, "Debug request type: -GLOBAL VARIABLES-\n\n");
+
+ fprintf(fl, "-CLAN STATUS-\n\n");
+ fprintf(fl, "Clan # | Status\n");
+ fprintf(fl, "-------|-------\n");
+
+ for (i = 0; i < clan_top; i++)
+ fprintf(fl, " %-4d | %d \n", clan_index[i].number, CLANSTATUS(i));
+
+
+ fprintf(fl, "\n\n");
+ }
+
+ if ((debug_type == CLAN_DEBUG_CREF) || (debug_type == CLAN_DEBUG_ALL))
+ {
+ i = 0;
+ /* Dump cross reference variable to debug file */
+ fprintf(fl, "Debug request type: -CROSS REFERENCE-\n");
+
+ fprintf(fl, "\nClan # | Index\n");
+ fprintf(fl, "-------|------\n");
+ for (i = 0; i < 9999; i++)
+ if (cross_reference[i] != -1)
+ fprintf(fl, "%-6d | %d\n", i, cross_reference[i]);
+ else
+ count++;
+ fprintf(fl, "\n%d valid records, %d empty records.\n\n",
+ (9999 - count), count);
+ }
+
+ if ((debug_type == CLAN_DEBUG_NODE) || (debug_type == CLAN_DEBUG_ALL))
+ {
+ count = 0;
+ /* Dump clan editing nodes to debug file */
+ fprintf(fl, "Debug request type: -CLAN EDIT NODES-\n");
+
+ fprintf(fl, "\nNode # | Clan # | Mode | Owner\n");
+ fprintf(fl, "-------|--------|--------|-------------------\n");
+ for (i = 0; i < 10; i++)
+ if (CLAN_EDIT_DESC(i) != NULL)
+ {
+ sprintf(buf2, " %-2d | %-4d | ", i, CLAN_EDIT_CLAN(i));
+ switch (CLAN_EDIT_MODE(i))
+ {
+ case CLAN_EDIT_DESCRIPTION_FINISHED:
+ fprintf(fl, "%s-Desc- | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_CONFIRM_SAVE:
+ fprintf(fl, "%sCon-Sv | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_MAIN_MENU:
+ fprintf(fl, "%s-Main- | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_NAME:
+ fprintf(fl, "%sClnNam | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_NUMBER:
+ fprintf(fl, "%sClnNum | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_GOLD:
+ fprintf(fl, "%sClnGld | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_OWNER:
+ fprintf(fl, "%sClnOwn | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_DESCRIPTION:
+ fprintf(fl, "%sClnDsc | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_CLANROOM:
+ fprintf(fl, "%sCln-Rm | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_COLOUR:
+ fprintf(fl, "%sClnClr | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_RANK_MENU:
+ fprintf(fl, "%sRnkMnu | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_SELECT_COLOUR:
+ fprintf(fl, "%sSltClr | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_SOLDIER:
+ fprintf(fl, "%sRnkSld | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_SARGEANT:
+ fprintf(fl, "%sRnkSgt | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_CAPTAIN:
+ fprintf(fl, "%sRnkCpt | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ case CLAN_EDIT_RULER:
+ fprintf(fl, "%sRnkRlr | %s\n", buf2,
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ default:
+ fprintf(fl, "%s%d | %s\n", buf2, CLAN_EDIT_MODE(i),
+ GET_NAME(CLAN_EDIT_DESC(i)->character));
+ break;
+ }
+ }
+ else count++;
+
+ fprintf(fl, "\n%d nodes used, %d free nodes.\n\n", (10 - count), count);
+ }
+
+ if (debug_type == CLAN_DEBUG_UNKNOWN)
+ {
+ send_to_char("clan debug <type>\r\n", ch);
+ send_to_char("\r\nValid types:\r\n", ch);
+ send_to_char(" cref - cross reference variable\r\n", ch);
+ send_to_char(" node - clan edit nodes\r\n", ch);
+ send_to_char(" var - global variables\r\n", ch);
+ send_to_char(" all - all debug reports\r\n", ch);
+ return NO;
+ }
+
+ fclose(fl);
+ return YES;
+ }
+
+
+ /* (FIDO) End */
diff -c -P -x *.o orig-src/clan.ct src/clan.ct
*** orig-src/clan.ct Thu Jan 1 10:00:00 1970
--- src/clan.ct Tue Feb 11 22:15:10 1997
***************
*** 0 ****
--- 1,742 ----
+ /* ************************************************************************
+ * File: clan.c Addition to CircleMUD *
+ * Usage: Source file for clan-specific code *
+ * *
+ * Copyright (c) to Daniel Muller *
+ * *
+ ************************************************************************ */
+
+ /*
+ * This file attempts to concentrate all of the clan specific code for the
+ * implementation of clans in CircleMUD. I've tried to mimic the code
+ * style of the rest of CircleMUD's code, to make it easier for you to
+ * modify as needed.
+ */
+
+
+
+ #include "conf.h"
+ #include "sysdep.h"
+ #include "string.h"
+
+ #include "structs.h"
+ #include "db.h"
+ #include "utils.h"
+ #include "spells.h"
+ #include "interpreter.h"
+ #include "comm.h"
+ #include "screen.h"
+ #include "clan.h"
+ #include "handler.h"
+
+ /* external vars */
+ extern struct descriptor_data *descriptor_list;
+ extern char *class_abbrevs[];
+ extern FILE *player_fl;
+
+ /* external functions */
+ extern int file_to_string(char *name, char *buf);
+
+ /*
+ * Clan names go here.
+ *
+ * Restrictions: A clan title must not be longer than 25 characters.
+ * A Owner's name may not be longer than 15 characters.
+ * Rank titles must not be longer than 10 characters.
+ *
+ * Format: "clan title", "colour of title", "Owner",
+ * "clan description filename", "Title of rank SOLDIER",
+ * "Title of rank SARGEANT", "Title of rank CAPTAIN",
+ * "Title of rank RULER"
+ *
+ * Dialog: For the colour of the title, use valid CircleMUD colour codes
+ * ie. CCBLU
+ *
+ * The "Owner" is the name of the clan owner character. This is
+ * displayed in the clan information command as a reference point
+ *
+ * The "clan description filename" is the filename + path of a
+ * plain textfile with a short clan description. Put "\n" if
+ * you don't want one to display. It goes in the lib/ dir.
+ *
+ * The rank titles are simply the clan names for each rank.
+ *
+ * Feel free to change the two existing clans.
+ *
+ */
+ const struct clan_info clans[] = {
+ { "Da Funky Immortals" , "CCMAG", "Regulator" , "clanimm",
+ "Grunt" , "Sarge" , "Captain", "Ruler" },
+ { "Da Gross Mortals" , "CCBLU", "Regulator" , "clanmort",
+ "Absolum", "Tweekie", "Mr." , "SIR!" },
+
+ /* New clans go here */
+
+ /* This must go at the end */
+ { "\n" , "NULL" , "NULL" , "NULL",
+ "NULL", "NULL", "NULL", "NULL" }
+ };
+
+ /*
+ * Clan levels
+ */
+ const int CLAN_APPLY = 1;
+ const int CLAN_SOLDIER = 2;
+ const int CLAN_SARGEANT = 3;
+ const int CLAN_CAPTAIN = 4;
+ const int CLAN_RULER = 5;
+
+ /*
+ * General functions go here
+ */
+
+
+
+
+ /*
+ * The general player commands go here
+ */
+ ACMD(do_clan)
+ {
+ char subbcmd[MAX_INPUT_LENGTH], val_arg[MAX_INPUT_LENGTH];
+ int ccmd = 0, value = 0, found = 0, temp = 0, temp2 = 0, player_i = 0;
+ struct char_data *cbuf = NULL, *vict = NULL;
+ struct char_file_u tmp_store;
+ struct descriptor_data *pt;
+
+ half_chop(argument, subbcmd, buf);
+ strcpy(val_arg, buf);
+
+ if (strcasecmp(subbcmd, "list") == 0)
+ {
+ /* Display title for list */
+ send_to_char("[ # Clan Title Clan Owner ]\r\n", ch);
+ /* List all clans and owners */
+ for (ccmd = 0; clans[ccmd].title != "\n"; ccmd++)
+ {
+ if (clans[ccmd].colour == "CCNRM") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCNRM(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCRED") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCRED(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCYEL") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCYEL(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCGRN") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCGRN(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCBLU") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCBLU(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCMAG") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCMAG(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCCYN") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCCYN(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ if (clans[ccmd].colour == "CCWHT") sprintf(buf, " %2d %s%-25s%s %-15s\r\n",
+ ccmd, CCWHT(ch, C_NRM), clans[ccmd].title,
+ CCNRM(ch, C_NRM), clans[ccmd].owner);
+ send_to_char(buf, ch);
+ }
+ sprintf(buf, "\r\n[%d clans displayed.]\r\n", ccmd);
+ send_to_char(buf, ch);
+
+ }
+
+ if (strcasecmp(subbcmd, "info") == 0)
+ {
+ /* Use index to retrieve information on clan */
+ value = atoi(val_arg);
+ if (value != 0)
+ {
+ for (ccmd = 0; clans[ccmd].title != "\n"; ccmd++)
+ if (ccmd == value)
+ {
+ found = 1;
+ temp2 = 0;
+
+ /* Find number of members in clan */
+ /* This is stored in the owners char structure */
+ if (!(vict = get_char_vis(ch, clans[ccmd].owner)))
+ {
+ CREATE(cbuf, struct char_data, 1);
+ clear_char(cbuf);
+ if ((player_i = load_char(clans[ccmd].owner, &tmp_store)) > -1)
+ {
+ store_to_char(&tmp_store, cbuf);
+ vict = cbuf;
+ }
+ else
+ {
+ free(cbuf);
+ sprintf(buf, "Clan info: Unable to find owner of '%s' clan.",
+ clans[ccmd].title);
+ mudlog(buf, BRF, LVL_GOD, TRUE);
+ return;
+ }
+ }
+ else temp2 = 1;
+
+ temp = CLANPLAYERS(vict);
+
+ /* Store player record */
+ if (temp2 == 0)
+ {
+ char_to_store(vict, &tmp_store);
+ fseek(player_fl, (player_i) * sizeof(struct char_file_u), SEEK_SET);
+ fwrite(&tmp_store, sizeof(struct char_file_u), 1, player_fl);
+ free_char(cbuf);
+ }
+
+ temp2 = 0;
+ /* Find number of clan members currently online */
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ pt->character->player_specials->saved.clannum == value)
+ temp2++;
+
+ /* Display info header */
+ if (clans[ccmd].colour == "CCNRM")
+ sprintf(buf, "[%s", CCNRM(ch, C_NRM));
+ if (clans[ccmd].colour == "CCRED")
+ sprintf(buf, "[%s", CCRED(ch, C_NRM));
+ if (clans[ccmd].colour == "CCGRN")
+ sprintf(buf, "[%s", CCGRN(ch, C_NRM));
+ if (clans[ccmd].colour == "CCYEL")
+ sprintf(buf, "[%s", CCYEL(ch, C_NRM));
+ if (clans[ccmd].colour == "CCBLU")
+ sprintf(buf, "[%s", CCBLU(ch, C_NRM));
+ if (clans[ccmd].colour == "CCMAG")
+ sprintf(buf, "[%s", CCMAG(ch, C_NRM));
+ if (clans[ccmd].colour == "CCWHT")
+ sprintf(buf, "[%s", CCWHT(ch, C_NRM));
+ if (clans[ccmd].colour == "CCCYN")
+ sprintf(buf, "[%s", CCCYN(ch, C_NRM));
+
+ sprintf(buf, "%s%-25s%s]\r\n", buf, clans[ccmd].title, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ send_to_char("\r\n", ch);
+ sprintf(buf, "Owner: %-15s\r\n", clans[ccmd].owner);
+ send_to_char(buf, ch);
+ sprintf(buf, "Members currently online: %-3d\r\nTotal number of members: %-3d\r\n", temp2, temp);
+ send_to_char(buf, ch);
+ send_to_char("\r\n", ch);
+
+ if (!(clans[ccmd].fname == "\n"))
+ {
+ file_to_string(clans[ccmd].fname, buf);
+ send_to_char(CCGRN(ch, C_NRM), ch);
+ send_to_char(buf, ch);
+ send_to_char(CCNRM(ch, C_NRM), ch);
+ }
+ send_to_char("\r\n", ch);
+ }
+
+ if (found == 0)
+ {
+ send_to_char("Unable to find a clan with that number.\r\n", ch);
+ return;
+ }
+ }
+ else
+ {
+ send_to_char("Unable to find a clan with that number.\r\n", ch);
+ }
+ }
+
+ if (strcasecmp(subbcmd, "resign") == 0)
+ {
+ temp2 = 0;
+
+ /* This handles clan resignations */
+ if ((ch->player_specials->saved.clannum == 0) && (CLANRANK(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(GET_NAME(ch), CLANOWNER(ch)) == 0)
+ {
+ send_to_char("You can't resign from a clan you own!\r\n", ch);
+ return;
+ }
+
+ value = ch->player_specials->saved.clannum;
+ ch->player_specials->saved.clannum = 0;
+ ch->player_specials->saved.clanrank = 0;
+
+ /* Update number of members in clan */
+ /* This is stored in the owners char structure */
+ for (ccmd = 0; clans[ccmd].title != "\n"; ccmd++)
+ if (ccmd == value)
+ if (!(vict = get_char_vis(ch, clans[ccmd].owner)))
+ {
+ CREATE(cbuf, struct char_data, 1);
+ clear_char(cbuf);
+ if ((player_i = load_char(clans[ccmd].owner, &tmp_store)) > -1)
+ {
+ store_to_char(&tmp_store, cbuf);
+ vict = cbuf;
+ }
+ else
+ {
+ free(cbuf);
+ sprintf(buf, "Clan info: Unable to find owner of '%s' clan.",
+ clans[ccmd].title);
+ mudlog(buf, BRF, LVL_GOD, TRUE);
+ return;
+ }
+ }
+ else
+ temp2 = 1;
+
+ if (!(CLANRANK(ch) == CLAN_APPLY))
+ vict->player_specials->saved.numclanmembers--;
+
+ /* Store player record */
+ if (temp2 == 0)
+ {
+ char_to_store(vict, &tmp_store);
+ fseek(player_fl, (player_i) * sizeof(struct char_file_u), SEEK_SET);
+ fwrite(&tmp_store, sizeof(struct char_file_u), 1, player_fl);
+ free_char(cbuf);
+ }
+
+ send_to_char("You have resigned from your clan.\r\n", ch);
+
+ }
+
+ if (strcasecmp(subbcmd, "apply") == 0)
+ {
+ /* This handles clan applications */
+ if (CLANRANK(ch) != 0)
+ {
+ send_to_char("You must resign from the clan you currently belong to, first.\r\n", ch);
+ return;
+ }
+
+ value = 0;
+ found = 0;
+ value = atoi(val_arg);
+ if (value >= 0)
+ {
+ for (ccmd = 0; ((clans[ccmd].title != "\n") && (found != 1)); ccmd++)
+ if (ccmd == value)
+ {
+ found = 1;
+
+ CLANNUM(ch) = ccmd;
+ CLANRANK(ch) = CLAN_APPLY;
+
+ sprintf(buf, "You have applied to the clan '%s'.\r\n", CLANNAME(ch));
+ send_to_char(buf, ch);
+ }
+
+ if (found != 1)
+ {
+ send_to_char("Unable to find that clan.\r\n", ch);
+ return;
+ }
+ }
+ else
+ {
+ send_to_char("Which clan number?!\r\n", ch);
+ return;
+ }
+
+ }
+
+ if (strcasecmp(subbcmd, "enlist") == 0)
+ {
+ /* This handles the enlistment of characters who have applied to your
+ * clan.
+ *
+ * Implementors can force an enlistment. So, when creating a new clan,
+ * make sure your owner applies to join it. Then the implementor must
+ * do a 'clan enlist <character>' so that the owner belongs to the clan.
+ */
+
+ if (!(GET_LEVEL(ch) == LVL_IMPL))
+ {
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (!(CLANRANK(ch) >= CLAN_SARGEANT))
+ {
+ send_to_char("You have insufficent rank in your clan to do this.\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) != CLAN_APPLY)
+ {
+ send_to_char("But that person isn't applying to any clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANNUM(vict) != CLANNUM(ch))
+ {
+ send_to_char("But that person isn't applying to your clan!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict) = CLAN_SOLDIER;
+ sprintf(buf, "You have been enlisted into the ranks of the '%s' clan.\r\n",
+ CLANNAME(ch));
+ send_to_char(buf, vict);
+
+ sprintf(buf, "You have enlisted '%s' into your clan.\r\n",
+ GET_NAME(vict));
+ send_to_char(buf, ch);
+
+ SET_BIT(PRF_FLAGS(vict), PRF_CLANTALK);
+
+ /* Update number of clan members */
+ /* This is stored in the owners char structure */
+ if (!(vict = get_char_vis(ch, clans[CLANNUM(ch)].owner)))
+ {
+ CREATE(cbuf, struct char_data, 1);
+ clear_char(cbuf);
+ if ((player_i = load_char(clans[CLANNUM(ch)].owner, &tmp_store)) > -1)
+ {
+ store_to_char(&tmp_store, cbuf);
+ vict = cbuf;
+ }
+ else
+ {
+ free(cbuf);
+ sprintf(buf, "Clan info: Unable to find owner of '%s' clan.",
+ clans[CLANNUM(ch)].title);
+ mudlog(buf, BRF, LVL_GOD, TRUE);
+ return;
+ }
+ }
+ else
+ temp2 = 1;
+
+ vict->player_specials->saved.numclanmembers++;
+
+ /* Store player record */
+ if (temp2 == 0)
+ {
+ char_to_store(vict, &tmp_store);
+ fseek(player_fl, (player_i) * sizeof(struct char_file_u), SEEK_SET);
+ fwrite(&tmp_store, sizeof(struct char_file_u), 1, player_fl);
+ free_char(cbuf);
+ }
+
+
+ }
+ else
+ {
+ send_to_char("But there is noone here by that name!\r\n", ch);
+ return;
+ }
+ }
+ else
+ {
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) != CLAN_APPLY)
+ {
+ send_to_char("But that person isn't applying to any clan!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(GET_NAME(vict), CLANOWNER(vict)) == 0)
+ CLANRANK(vict) = CLAN_RULER;
+ else
+ CLANRANK(vict) = CLAN_SOLDIER;
+
+ sprintf(buf, "You have forced the enlistment of '%s' into the clan '%s'.\r\n",
+ GET_NAME(vict), CLANNAME(vict));
+ send_to_char(buf, ch);
+
+ sprintf(buf, "You have been enlisted into the clan '%s'.\r\n",
+ CLANNAME(vict));
+ send_to_char(buf, vict);
+
+ /* Update number of clan members */
+ /* This is stored in the owners char structure */
+ if (!(vict = get_char_vis(ch, clans[CLANNUM(ch)].owner)))
+ {
+ CREATE(cbuf, struct char_data, 1);
+ clear_char(cbuf);
+ if ((player_i = load_char(clans[CLANNUM(ch)].owner, &tmp_store)) > -1)
+ {
+ store_to_char(&tmp_store, cbuf);
+ vict = cbuf;
+ }
+ else
+ {
+ free(cbuf);
+ sprintf(buf, "Clan info: Unable to find owner of '%s' clan.",
+ clans[CLANNUM(ch)].title);
+ mudlog(buf, BRF, LVL_GOD, TRUE);
+ return;
+ }
+ }
+ else
+ temp2 = 1;
+
+ vict->player_specials->saved.numclanmembers++;
+
+ /* Store player record */
+ if (temp2 == 0)
+ {
+ char_to_store(vict, &tmp_store);
+ fseek(player_fl, (player_i) * sizeof(struct char_file_u), SEEK_SET);
+ fwrite(&tmp_store, sizeof(struct char_file_u), 1, player_fl);
+ free_char(cbuf);
+ }
+ }
+ else
+ {
+ send_to_char("Unable to find a character of that name.\r\n", ch);
+ return;
+ }
+
+ }
+ }
+
+ if (strcasecmp(subbcmd, "promote") == 0)
+ {
+ /* Clan promotions */
+ if (CLANRANK(ch) < CLAN_CAPTAIN)
+ {
+ send_to_char("You have insufficent rank to do that.\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) > CLANRANK(ch))
+ {
+ send_to_char("You can't promote someone who ranks higher than you!\r\n", ch);
+ return;
+ }
+
+ if ((CLANRANK(vict) < CLAN_SOLDIER) || (CLANNUM(vict) != CLANNUM(ch)))
+ {
+ send_to_char("You can't promote someone who doesn't belong to your clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(vict) == CLAN_RULER)
+ {
+ send_to_char("You can't promote this person any higher in rank!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict)++;
+ sprintf(buf, "%sYou have been promoted to ", CCRED(vict, C_NRM));
+ if (CLANRANK(vict) == CLAN_SARGEANT)
+ strcat(buf, SARGEANTTITLE(vict));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(vict));
+ if (CLANRANK(vict) == CLAN_RULER) strcat(buf, RULERTITLE(vict));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, vict);
+
+ sprintf(buf, "%sYou have promoted '%s' to the rank of ",
+ CCRED(vict, C_NRM), GET_NAME(vict));
+ if (CLANRANK(vict) == CLAN_SARGEANT) strcat(buf, SARGEANTTITLE(vict));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(vict));
+ if (CLANRANK(vict) == CLAN_RULER) strcat(buf, RULERTITLE(vict));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+ }
+ else
+ {
+ send_to_char("Promote who?!\r\n", ch);
+ return;
+ }
+
+ }
+
+ if (strcasecmp(subbcmd, "demote") == 0)
+ {
+ /* Clan demotions */
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(ch) < CLAN_CAPTAIN)
+ {
+ send_to_char("You have insufficent rank to do that.\r\n", ch);
+ return;
+ }
+
+ if ((vict = get_player_vis(ch, val_arg, 0)))
+ {
+ if (CLANRANK(vict) > CLANRANK(ch))
+ {
+ send_to_char("You can't demote someone who ranks higher than you!\r\n", ch);
+ return;
+ }
+
+ if ((CLANRANK(vict) < CLAN_SOLDIER) || (CLANNUM(vict) != CLANNUM(ch)))
+ {
+ send_to_char("You can't demote someone who doesn't belong to your clan!\r\n", ch);
+ return;
+ }
+
+ if (CLANRANK(vict) == CLAN_SOLDIER)
+ {
+ send_to_char("You can't demote this person any lower! Try clan boot <person>!\r\n", ch);
+ return;
+ }
+
+ if (strcasecmp(GET_NAME(vict), CLANOWNER(vict)) == 0)
+ {
+ send_to_char("You can't demote the clan owner!\r\n", ch);
+ return;
+ }
+
+ CLANRANK(vict)--;
+ sprintf(buf, "%sYou have been demoted to ", CCRED(vict, C_NRM));
+ if (CLANRANK(vict) == CLAN_SOLDIER) strcat(buf, SOLDIERTITLE(vict));
+ if (CLANRANK(vict) == CLAN_SARGEANT) strcat(buf, SARGEANTTITLE(vict));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(vict));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, vict);
+
+ sprintf(buf, "%sYou have demoted '%s' to the rank of ",
+ CCRED(vict, C_NRM), GET_NAME(vict));
+ if (CLANRANK(vict) == CLAN_SOLDIER) strcat(buf, SOLDIERTITLE(vict));
+ if (CLANRANK(vict) == CLAN_CAPTAIN) strcat(buf, CAPTAINTITLE(vict));
+ if (CLANRANK(vict) == CLAN_SARGEANT) strcat(buf, SARGEANTTITLE(vict));
+
+ sprintf(buf, "%s in your clan.%s\r\n", buf, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+ }
+ else
+ {
+ send_to_char("Demote who?!\r\n", ch);
+ return;
+ }
+
+ }
+
+ if (strcasecmp(subbcmd, "who") == 0)
+ {
+ /* List all clan members online, along with their clan rank */
+ if ((CLANNUM(ch) == 0) && (CLANRANK(ch) == 0))
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ sprintf(buf, "Members of the clan '%s' currently online:\r\n", CLANNAME(ch));
+ send_to_char(buf, ch);
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ pt->character->player_specials->saved.clannum == CLANNUM(ch))
+ {
+ sprintf(buf, "%s[%2d %s ",
+ (GET_LEVEL(pt->character) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
+ GET_LEVEL(pt->character), CLASS_ABBR(pt->character));
+ if (CLANRANK(pt->character) == CLAN_APPLY) sprintf(buf, "%s%-10s", buf, "--");
+ if (CLANRANK(pt->character) == CLAN_SOLDIER)
+ sprintf(buf, "%s%-10s", buf, SOLDIERTITLE(pt->character));
+ if (CLANRANK(pt->character) == CLAN_SARGEANT)
+ sprintf(buf, "%s%-10s", buf, SARGEANTTITLE(pt->character));
+ if (CLANRANK(pt->character) == CLAN_CAPTAIN)
+ sprintf(buf, "%s%-10s", buf, CAPTAINTITLE(pt->character));
+ if (CLANRANK(pt->character) == CLAN_RULER)
+ sprintf(buf, "%s%-10s", buf, RULERTITLE(pt->character));
+ sprintf(buf, "%s] %s %s%s\r\n", buf, GET_NAME(pt->character), GET_TITLE(pt->character), CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+ }
+ }
+
+ if (strcasecmp(subbcmd, "say") == 0)
+ {
+ /* Clan say */
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (!PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ send_to_char("Try turning your clan talk channel on first, dork!\r\n", ch);
+ return;
+ }
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ pt->character->player_specials->saved.clannum == CLANNUM(ch) &&
+ pt->character != ch && PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ sprintf(buf, "%s%s says to the clan, '%s'%s\r\n", CCRED(pt->character, C_NRM),
+ GET_NAME(ch), val_arg, CCNRM(pt->character, C_NRM));
+ send_to_char(buf, pt->character);
+ }
+ sprintf(buf, "%sYou say to the clan, '%s'%s\r\n", CCRED(ch, C_NRM),
+ val_arg, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ }
+
+ if (strcasecmp(subbcmd, "channel") == 0)
+ {
+ if (PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ TOGGLE_BIT(PRF_FLAGS(ch), PRF_CLANTALK);
+ send_to_char("Clan talk channel turned off.\r\n", ch);
+ }
+ else
+ {
+ TOGGLE_BIT(PRF_FLAGS(ch), PRF_CLANTALK);
+ send_to_char("Clan talk channel turned on.\r\n", ch);
+ }
+ }
+
+ };
+
+ ACMD(do_clansay)
+ {
+ struct descriptor_data *pt;
+
+ /* Clan say */
+ if (CLANRANK(ch) == 0)
+ {
+ send_to_char("But you don't belong to any clan!\r\n", ch);
+ return;
+ }
+
+ if (!PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ send_to_char("Try turning your clan talk channel on first, dork!\r\n", ch);
+ return;
+ }
+
+ for (pt = descriptor_list; pt; pt = pt->next)
+ if (!pt->connected && pt->character &&
+ pt->character->player_specials->saved.clannum == CLANNUM(ch) &&
+ pt->character != ch && PRF_FLAGGED(ch, PRF_CLANTALK))
+ {
+ sprintf(buf, "%s%s says to the clan, '%s'%s\r\n", CCRED(pt->character, C_NRM),
+ GET_NAME(ch), argument, CCNRM(pt->character, C_NRM));
+ send_to_char(buf, pt->character);
+ }
+ sprintf(buf, "%sYou say to the clan, '%s'%s\r\n", CCRED(ch, C_NRM),
+ argument, CCNRM(ch, C_NRM));
+ send_to_char(buf, ch);
+
+ };
diff -c -P -x *.o orig-src/clan.h src/clan.h
*** orig-src/clan.h Thu Jan 1 10:00:00 1970
--- src/clan.h Mon Feb 24 16:44:13 1997
***************
*** 0 ****
--- 1,99 ----
+ /* *************************************************************************
+ * File: clan.h Addition to CircleMUD *
+ * Usage: Contains structure definitions for clan.c *
+ * *
+ * Written by Daniel Muller *
+ * *
+ ************************************************************************* */
+
+ struct clan_info {
+ char *title;
+ int colour;
+ char *owner;
+ char *description;
+ char *old_description;
+ char *ranksoldiertitle;
+ char *ranksargeanttitle;
+ char *rankcaptaintitle;
+ char *rankrulertitle;
+ int clanroom;
+ int clangold;
+ int nummembers;
+ int number;
+ int status;
+ };
+
+ struct clan_colours {
+ char *colour_string;
+ };
+
+ struct clan_editing {
+ int mode; /* What edit mode are we in? */
+ struct descriptor_data *desc; /* Who owns this clan node? */
+ int clan;
+ };
+
+ #define CLAN_DEBUG_UNKNOWN 0
+ #define CLAN_DEBUG_ALL 1
+ #define CLAN_DEBUG_CREF 2
+ #define CLAN_DEBUG_NODE 3
+ #define CLAN_DEBUG_VAR 4
+
+ #define CLEAN_NODE 0
+ #define CLEAN_ALL 1
+
+ #define CON_CLAN_EDIT 17
+
+ #define CLAN_EDIT_CONFIRM_SAVE 0
+ #define CLAN_EDIT_MAIN_MENU 1
+ #define CLAN_EDIT_NAME 2
+ #define CLAN_EDIT_NUMBER 3
+ #define CLAN_EDIT_GOLD 4
+ #define CLAN_EDIT_OWNER 5
+ #define CLAN_EDIT_DESCRIPTION 6
+ #define CLAN_EDIT_CLANROOM 7
+ #define CLAN_EDIT_COLOUR 8
+ #define CLAN_EDIT_RANK_MENU 9
+ #define CLAN_EDIT_SELECT_COLOUR 10
+ #define CLAN_EDIT_SOLDIER 11
+ #define CLAN_EDIT_SARGEANT 12
+ #define CLAN_EDIT_CAPTAIN 13
+ #define CLAN_EDIT_RULER 14
+ #define CLAN_EDIT_DESCRIPTION_FINISHED 15
+ #define CLAN_EDIT_CONFIRM_DELETE 16
+
+ #define CLAN_EDIT_MODE(num) (clan_edit[(num)].mode)
+ #define CLAN_EDIT_DESC(num) (clan_edit[(num)].desc)
+ #define CLAN_EDIT_CLAN(num) (clan_edit[(num)].clan)
+
+ #define CLANSTATUS(cnum) (clan_index[(cnum)].status)
+ #define CLAN_DELETE 2
+ #define CLAN_NEW 1
+ #define CLAN_OLD 0
+
+ #define PLAYERCLAN(ch) ((ch)->player_specials->saved.clannum)
+ #define PLAYERCLANNUM(ch) (cross_reference[(ch)->player_specials->saved.clannum])
+ #define CLANNUM(clan) ((clan).number)
+ #define CLANNAME(clan) ((clan).title)
+ #define CLANRANK(ch) ((ch)->player_specials->saved.clanrank)
+ #define CLANPLAYERS(clan) ((clan).nummembers)
+ #define CLANOWNER(clan) ((clan).owner)
+ #define CLANGOLD(clan) ((clan).clangold)
+ #define CLANROOM(clan) ((clan).clanroom)
+ #define CLANDESC(clan) ((clan).description)
+ #define CLANCOLOUR(num) (clan_colour[clan_index[(num)].colour].colour_string)
+ #define CLANCOLOR(num) (clan_index[(num)].colour)
+
+ #define SOLDIERTITLE(clan) ((clan).ranksoldiertitle)
+ #define SARGEANTTITLE(clan) ((clan).ranksargeanttitle)
+ #define CAPTAINTITLE(clan) ((clan).rankcaptaintitle)
+ #define RULERTITLE(clan) ((clan).rankrulertitle)
+
+ #define CLAN_WHITE 0
+ #define CLAN_GREEN 1
+ #define CLAN_RED 2
+ #define CLAN_BLUE 3
+ #define CLAN_MAGENTA 4
+ #define CLAN_YELLOW 5
+ #define CLAN_CYAN 6
+ #define CLAN_NORMAL 7
diff -c -P -x *.o orig-src/comm.c src/comm.c
*** orig-src/comm.c Mon Feb 24 23:00:33 1997
--- src/comm.c Sun Feb 23 04:58:21 1997
***************
*** 32,37 ****
--- 32,38 ----
#include "handler.h"
#include "db.h"
#include "house.h"
+ #include "clan.h"
#ifdef HAVE_ARPA_TELNET_H
#include <arpa/telnet.h>
***************
*** 43,48 ****
--- 44,52 ----
#define INVALID_SOCKET -1
#endif
+ #define YES 1
+ #define NO 0
+
/* externs */
extern int restrict;
extern int mini_mud;
***************
*** 53,58 ****
--- 57,65 ----
extern int MAX_PLAYERS;
extern int MAX_DESCRIPTORS_AVAILABLE;
+ extern void clan_save(int system, struct char_data *ch);
+ extern void cleanup_clan_edit(struct descriptor_data *d, int method);
+
extern struct room_data *world; /* In db.c */
extern int top_of_world; /* In db.c */
extern struct time_info_data time_info; /* In db.c */
***************
*** 689,694 ****
--- 696,702 ----
mins_since_crashsave = 0;
Crash_save_all();
House_save_all();
+ clan_save(YES, NULL); /* Fido - Crash save and auto save clans */
}
}
if (!(pulse % (5 * 60 * PASSES_PER_SEC))) /* 5 minutes */
***************
*** 1363,1368 ****
--- 1371,1385 ----
SEND_TO_Q("Your victim is no longer among us.\r\n", d->snoop_by);
d->snoop_by->snooping = NULL;
}
+
+ /* Clean up clan edit if necessary */
+ switch (d->connected)
+ {
+ case CON_CLAN_EDIT:
+ cleanup_clan_edit(d, CLEAN_ALL);
+ break;
+ }
+
if (d->character) {
target_idnum = GET_IDNUM(d->character);
if (d->connected == CON_PLAYING) {
diff -c -P -x *.o orig-src/config.c src/config.c
*** orig-src/config.c Mon Feb 24 23:00:33 1997
--- src/config.c Sat Feb 8 13:35:03 1997
***************
*** 52,57 ****
--- 52,61 ----
* PK Mud, just set pk_allowed to YES - and anything goes.
*/
int pk_allowed = NO;
+ int summon_allowed = NO;
+ int charm_allowed = NO;
+ int sleep_allowed = NO;
+ int roomaffect_allowed = NO;
/* is playerthieving allowed? */
int pt_allowed = NO;
***************
*** 71,77 ****
int max_pc_corpse_time = 10;
/* should items in death traps automatically be junked? */
! int dts_are_dumps = YES;
/* "okay" etc. */
char *OK = "Okay.\r\n";
--- 75,81 ----
int max_pc_corpse_time = 10;
/* should items in death traps automatically be junked? */
! int dts_are_dumps = NO;
/* "okay" etc. */
char *OK = "Okay.\r\n";
diff -c -P -x *.o orig-src/constants.c src/constants.c
*** orig-src/constants.c Mon Feb 24 23:00:33 1997
--- src/constants.c Sun Feb 23 03:13:00 1997
***************
*** 230,235 ****
--- 230,236 ----
"Changing PW 3",
"Self-Delete 1",
"Self-Delete 2",
+ "Editing Clans",
"\n"
};
diff -c -P -x *.o orig-src/db.c src/db.c
*** orig-src/db.c Mon Feb 24 23:00:33 1997
--- src/db.c Sun Feb 23 03:00:14 1997
***************
*** 14,19 ****
--- 14,20 ----
#include "sysdep.h"
+ #include "clan.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
***************
*** 28,33 ****
--- 29,37 ----
* declarations of most of the 'global' variables *
************************************************************************ */
+ struct clan_info *clan_index = NULL; /* (FIDO) Clan global */
+ int clan_top = 0; /* (FIDO) Top of clan struct */
+
struct room_data *world = NULL; /* array of rooms */
int top_of_world = 0; /* ref to top element of world */
***************
*** 109,114 ****
--- 113,119 ----
void clear_char(struct char_data * ch);
/* external functions */
+ extern void parse_clan(FILE *fl, int virtual_nr);
extern struct descriptor_data *descriptor_list;
void load_messages(void);
void weather_and_time(int mode);
***************
*** 220,225 ****
--- 225,233 ----
log("Loading objs and generating index.");
index_boot(DB_BOOT_OBJ);
+ log("Loading clans and generating index.");
+ index_boot(DB_BOOT_CLAN);
+
log("Renumbering zone table.");
renum_zone_table();
***************
*** 462,467 ****
--- 470,478 ----
case DB_BOOT_HLP:
prefix = HLP_PREFIX;
break;
+ case DB_BOOT_CLAN:
+ prefix = CLAN_PREFIX;
+ break;
default:
log("SYSERR: Unknown subcommand to index_boot!");
exit(1);
***************
*** 528,533 ****
--- 539,548 ----
case DB_BOOT_HLP:
CREATE(help_table, struct help_index_element, rec_count * 2);
break;
+ case DB_BOOT_CLAN:
+ CREATE(clan_index, struct clan_info, rec_count + 10);
+ clan_top = rec_count - 1;
+ break;
}
rewind(index);
***************
*** 542,547 ****
--- 557,563 ----
case DB_BOOT_WLD:
case DB_BOOT_OBJ:
case DB_BOOT_MOB:
+ case DB_BOOT_CLAN:
discrete_load(db_file, mode);
break;
case DB_BOOT_ZON:
***************
*** 573,579 ****
int nr = -1, last = 0;
char line[256];
! char *modes[] = {"world", "mob", "obj"};
for (;;) {
/*
--- 589,595 ----
int nr = -1, last = 0;
char line[256];
! char *modes[] = {"world", "mob", "obj", "clan"};
for (;;) {
/*
***************
*** 606,611 ****
--- 622,630 ----
break;
case DB_BOOT_OBJ:
strcpy(line, parse_object(fl, nr));
+ break;
+ case DB_BOOT_CLAN:
+ parse_clan(fl, nr);
break;
}
} else {
diff -c -P -x *.o orig-src/db.c.save src/db.c.save
Showing the first 100 KB of 177.8 KB. Download the archive for the full file.