Clan Patch [by Chris Powell]
Patch Posted Thursday, October 1st @ 02:56:28 PM, by George Greer in the ex-snippet-patchified dept.
This is a patch of the clan code from the snippet site. In addition to the patch below, the original README is available.
diff -uprN stk/Makefile src/Makefile
--- stk/Makefile	Tue Feb 10 08:08:35 1998
+++ src/Makefile	Tue Feb 10 08:16:42 1998
@@ -24,14 +24,14 @@ OBJFILES = comm.o act.comm.o act.informa
 	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 random.o shop.o spec_assign.o spec_procs.o \
-	spell_parser.o spells.o utils.o weather.o
+	spell_parser.o spells.o utils.o weather.o clan.o
 
 CXREF_FILES = act.comm.c act.informative.c act.item.c act.movement.c \
 	act.offensive.c act.other.c act.social.c act.wizard.c ban.c boards.c \
 	castle.c class.c comm.c config.c constants.c db.c fight.c graph.c \
 	handler.c house.c interpreter.c limits.c magic.c mail.c mobact.c \
 	modify.c objsave.c olc.c random.c shop.c spec_assign.c spec_procs.c \
-	spell_parser.c spells.c utils.c weather.c
+	spell_parser.c spells.c utils.c weather.c clan.c
 
 default: all
 
@@ -91,10 +91,10 @@ ref:
 # gcc -MM)
 
 act.comm.o: act.comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
-  handler.h db.h screen.h
+  handler.h db.h screen.h clan.h
 	$(CC) -c $(CFLAGS) act.comm.c
 act.informative.o: act.informative.c conf.h sysdep.h structs.h utils.h comm.h \
-  interpreter.h handler.h db.h spells.h screen.h
+  interpreter.h handler.h db.h spells.h screen.h clan.h
 	$(CC) -c $(CFLAGS) act.informative.c
 act.item.o: act.item.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
   handler.h db.h spells.h
@@ -132,7 +132,7 @@ config.o: config.c conf.h sysdep.h struc
 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
+  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
@@ -192,3 +192,6 @@ utils.o: utils.c conf.h sysdep.h structs
 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 utils.h comm.h spells.h handler.h \
+  db.h clan.h
+	$(CC) -c $(CFLAGS) clan.c
diff -uprN stk/act.comm.c src/act.comm.c
--- stk/act.comm.c	Tue Feb 10 07:53:45 1998
+++ src/act.comm.c	Tue Feb 10 08:01:26 1998
@@ -19,6 +19,7 @@
 #include "handler.h"
 #include "db.h"
 #include "screen.h"
+#include "clan.h"
 
 /* extern variables */
 extern struct room_data *world;
@@ -485,3 +486,79 @@ ACMD(do_qcomm)
 	act(buf, 0, ch, 0, i->character, TO_VICT | TO_SLEEP);
   }
 }
+
+/*
+ * I didn't write this command, i just modified it, all credits should
+ * go to original coder
+ */
+ACMD (do_ctell)
+{
+  struct descriptor_data *i;
+  int minlev=1, c=0;
+  char level_string[6]="\0\0\0\0\0\0";
+
+  skip_spaces (&argument);
+
+/*
+ * The syntax of ctell for imms is different then for morts
+ * mort: ctell     imms: ctell  
+ * Imms cannot actually see ctells but they can send them
+ */
+  if (GET_LEVEL(ch) >= LVL_IMMORT){
+    c = atoi (argument);
+    if ((c <= 0) || (c > num_of_clans)){
+      send_to_char ("There is no clan with that number.\r\n", ch);
+      return;
+    }
+    while ((*argument != ' ') && (*argument != '\0'))
+      argument++;
+    while (*argument == ' ') argument++;
+  }
+  else
+    if((c=GET_CLAN(ch))==0 || GET_CLAN_RANK(ch)==0) {
+      send_to_char ("You're not part of a clan.\r\n", ch);
+      return;
+    }
+
+  skip_spaces (&argument);
+
+  if (!*argument){
+    send_to_char ("What do you want to tell your clan?\r\n", ch);
+    return;
+  }
+
+  if (*argument == '#'){
+    argument++;
+    minlev = atoi (argument);
+    if (minlev > clan[c].ranks){
+      send_to_char ("No one has a clan rank high enough to hear you!\r\n", ch);
+      return;
+    }
+    while (*argument != ' ') argument++;
+    while (*argument == ' ') argument++;
+    sprintf (level_string, "(%d)", minlev);
+  }
+
+  if (PRF_FLAGGED(ch,PRF_NOREPEAT))
+    sprintf (buf1, OK);
+  else
+      sprintf (buf1, "You tell your clan%s, '%s'\r\n",level_string, argument);
+  send_to_char (buf1, ch);
+
+  for (i = descriptor_list; i; i=i->next){
+      if (i->character->player_specials->saved.clan == c){
+        if (i->character->player_specials->saved.clan_rank >= minlev){
+          if (strcmp (i->character->player.name, ch->player.name)){
+            sprintf (buf, "%s tells your clan%s, '%s'\r\n",
+                     (((IS_AFFECTED(ch, AFF_INVISIBLE)) &&
+                      (!IS_AFFECTED(i->character, AFF_DETECT_INVIS))) ?
+                      "Someone" : ch->player.name), level_string, argument);
+            send_to_char (buf, i->character);
+          }
+        }
+      }
+    }
+
+  return;
+}
+
diff -uprN stk/act.informative.c src/act.informative.c
--- stk/act.informative.c	Tue Feb 10 07:53:45 1998
+++ src/act.informative.c	Tue Feb 10 08:43:47 1998
@@ -19,6 +19,7 @@
 #include "db.h"
 #include "spells.h"
 #include "screen.h"
+#include "clan.h"
 
 /* extern variables */
 extern struct room_data *world;
@@ -907,7 +908,7 @@ ACMD(do_who)
   size_t i;
   int low = 0, high = LVL_IMPL, localwho = 0, questwho = 0;
   int showclass = 0, short_list = 0, outlaws = 0, num_can_see = 0;
-  int who_room = 0;
+  int who_room = 0, clan_num = 0;
 
   skip_spaces(&argument);
   strcpy(buf, argument);
@@ -1006,6 +1007,21 @@ ACMD(do_who)
 	      (GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
 	      GET_LEVEL(tch), CLASS_ABBR(tch), GET_NAME(tch),
 	      GET_TITLE(tch));
+
+
+      /*. Add the clan title to the title between []. Think about no allowing
+          brakets in titles to prevent simulating clan titles .*/
+
+if ((clan_num=find_clan_by_id(GET_CLAN(tch))) >=0 && clan_num < num_of_clans)
+   {
+        if(GET_CLAN_RANK(tch) > 0)
+          sprintf(buf, "%s [%s of %s]", buf,
+                clan[clan_num].rank_name[GET_CLAN_RANK(tch) -1],
+                clan[clan_num].name);
+        else
+          sprintf(buf, "%s [Applying to %s]", buf, clan[clan_num].name);
+       }
+
 
       if (GET_INVIS_LEV(tch))
 	sprintf(buf, "%s (i%d)", buf, GET_INVIS_LEV(tch));
diff -uprN stk/clan.c src/clan.c
--- stk/clan.c	Wed Dec 31 19:00:00 1969
+++ src/clan.c	Tue Feb 10 08:36:53 1998
@@ -0,0 +1,1171 @@
+/**************************************************************************
+ * File: clan.c                       Intended to be used with CircleMUD  *
+ * Usage: This is the code for clans                                      *
+ * By Mehdi Keddache (Heritsun on Eclipse of Fate eclipse.argy.com 7777)  *
+ * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.               *
+ * CircleMUD (C) 1993, 94 by the Trustees of the Johns Hopkins University *
+ **************************************************************************/
+
+#include "conf.h"
+#include "sysdep.h"
+
+#include "structs.h"
+#include "utils.h"
+#include "comm.h"
+#include "db.h"
+#include "interpreter.h"
+#include "spells.h"
+#include "handler.h"
+#include "clan.h"
+
+int num_of_clans;
+struct clan_rec clan[MAX_CLANS];
+
+extern save_char_file_u(struct char_file_u st);
+extern struct descriptor_data *descriptor_list;
+extern struct char_data *is_playing(char *vict_name);
+
+char clan_privileges[NUM_CP+1][20] ={
+"setplan","enroll","expel","promote","demote","setfees","withdraw","setapplev"};
+
+void send_clan_format(struct char_data *ch)
+{
+int c,r;
+
+send_to_char("Clan commands available to you:\n\r"
+             "   clan who\r\n"
+             "   clan status\r\n"
+             "   clan info \r\n",ch);
+if(GET_LEVEL(ch)>=LVL_CLAN_GOD)
+  send_to_char("   clan create      \r\n"
+               "   clan destroy    \r\n"
+               "   clan enroll      \r\n"
+               "   clan expel       \r\n"
+               "   clan promote     \r\n"
+               "   clan demote      \r\n"
+               "   clan withdraw    \r\n"
+               "   clan deposit     \r\n"
+               "   clan set ranks     \r\n"
+               "   clan set appfee  \r\n"
+               "   clan set dues    \r\n"
+               "   clan set applev   \r\n"
+               "   clan set plan   \r\n"
+               "   clan privilege      \r\n"
+               "   clan set title    \r\n",ch);
+else {
+  c=find_clan_by_id(GET_CLAN(ch));
+  r=GET_CLAN_RANK(ch);
+  if(r<1)
+    send_to_char("   clan apply      <clan>\r\n",ch);
+  if(c>=0) {
+    send_to_char("   clan deposit    <amount>\r\n",ch);
+    if(r>=clan[c].privilege[CP_WITHDRAW])
+      send_to_char("   clan withdraw   <amount>\r\n" ,ch);
+    if(r>=clan[c].privilege[CP_ENROLL])
+      send_to_char("   clan enroll     <player>\r\n" ,ch);
+    if(r>=clan[c].privilege[CP_EXPEL])
+      send_to_char("   clan expel      <player>\r\n" ,ch);
+    if(r>=clan[c].privilege[CP_PROMOTE])
+      send_to_char("   clan promote    <player>\r\n",ch);
+    if(r>=clan[c].privilege[CP_DEMOTE])
+      send_to_char("   clan demote     <player>\r\n",ch);
+    if(r>=clan[c].privilege[CP_SET_APPLEV])
+      send_to_char("   clan set applev <level>\r\n",ch);
+    if(r>=clan[c].privilege[CP_SET_FEES])
+      send_to_char("   clan set appfee <amount>\r\n"
+                   "   clan set dues   <amount>\r\n",ch);
+    if(r>=clan[c].privilege[CP_SET_PLAN])
+      send_to_char("   clan set plan\r\n",ch);
+    if(r==clan[c].ranks)
+      send_to_char("   clan set ranks  <rank>\r\n"
+                   "   clan set title  <rank> <title>\r\n"
+                   "   clan privilege  <privilege> <rank>\r\n",ch);
+    }
+  }
+}
+
+void do_clan_create (struct char_data *ch, char *arg)
+{
+struct char_data *leader = NULL;
+char arg1[MAX_INPUT_LENGTH],arg2[MAX_INPUT_LENGTH];
+int new_id=0,i;
+
+if (!*arg) {
+  send_clan_format(ch);
+  return; }
+
+if (GET_LEVEL(ch) < LVL_CLAN_GOD) {
+  send_to_char("You are not mighty enough to create new clans!\r\n", ch);
+  return; }
+
+if(num_of_clans == MAX_CLANS) {
+  send_to_char("Max clans reached. WOW!\r\n",ch);
+  return; }
+
+half_chop(arg, arg1, arg2);
+
+if(!(leader=get_char_vis(ch,arg1))) {
+  send_to_char("The leader of the new clan must be present.\r\n",ch);
+  return; }
+
+if(strlen(arg2)>=32) {
+  send_to_char("Clan name too long! (32 characters max)\r\n",ch);
+  return; }
+
+if(GET_LEVEL(leader)>=LVL_IMMORT) {
+  send_to_char("You cannot set an immortal as the leader of a clan.\r\n",ch);
+  return; }
+
+if(GET_CLAN(leader)!=0 && GET_CLAN_RANK(leader)!=0) {
+  send_to_char("The leader already belongs to a clan!\r\n",ch);
+  return; }
+
+if(find_clan(arg2)!=-1) {
+  send_to_char("That clan name alread exists!\r\n",ch);
+  return; }
+
+strncpy(clan[num_of_clans].name, CAP((char *)arg2), 32);
+for(i=0;i<num_of_clans;i++)
+  if(new_id<clan[i].id)
+    new_id=clan[i].id;
+clan[num_of_clans].id=new_id+1;
+clan[num_of_clans].ranks =  2;
+strcpy(clan[num_of_clans].rank_name[0],"Member");
+strcpy(clan[num_of_clans].rank_name[1],"Leader");
+clan[num_of_clans].treasure = 0 ;
+clan[num_of_clans].members = 1 ;
+clan[num_of_clans].power = GET_LEVEL(leader) ;
+clan[num_of_clans].app_fee = 0 ;
+clan[num_of_clans].dues = 0 ;
+clan[num_of_clans].app_level = DEFAULT_APP_LVL ;
+for(i=0;i<5;i++)
+  clan[num_of_clans].spells[i]=0;
+for(i=0;i<20;i++)
+  clan[num_of_clans].privilege[i]=clan[num_of_clans].ranks;
+for(i=0;i<4;i++)
+  clan[num_of_clans].at_war[i]=0;
+num_of_clans++;
+save_clans();
+send_to_char("Clan created\r\n", ch);
+GET_CLAN(leader)=clan[num_of_clans-1].id;
+GET_CLAN_RANK(leader)=clan[num_of_clans-1].ranks;
+save_char(leader, leader->in_room);
+
+return;
+}
+
+
+void do_clan_destroy (struct char_data *ch, char *arg)
+{
+
+int i,j;
+extern int top_of_p_table;
+extern struct player_index_element *player_table;
+struct char_file_u chdata;
+struct char_data *victim=NULL;
+
+if (!*arg) {
+  send_clan_format(ch);
+  return; }
+
+if ((i = find_clan(arg)) < 0) {
+  send_to_char("Unknown clan.\r\n", ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+  send_to_char("Your not mighty enough to destroy clans!\r\n", ch);
+  return; }
+
+for (j = 0; j <= top_of_p_table; j++){
+  if((victim=is_playing((player_table +j)->name))) {
+    if(GET_CLAN(victim)==clan[i].id) {
+      GET_CLAN(victim)=0;
+      GET_CLAN_RANK(victim)=0;
+      save_char(victim, victim->in_room); } }
+  else {
+    load_char((player_table + j)->name, &chdata);
+    if(chdata.player_specials_saved.clan==clan[i].id) {
+      chdata.player_specials_saved.clan=0;
+      chdata.player_specials_saved.clan_rank=0;
+      save_char_file_u(chdata); } } }
+
+memset(&clan[i], sizeof(struct clan_rec), 0);
+
+for (j = i; j < num_of_clans - 1; j++)
+  clan[j] = clan[j + 1];
+
+num_of_clans--;
+
+send_to_char("Clan deleted.\r\n", ch);
+save_clans();
+return;
+}
+
+void do_clan_enroll (struct char_data *ch, char *arg)
+{
+struct char_data *vict=NULL;
+int clan_num,immcom=0;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return;
+  }
+}
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_ENROLL] && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return;
+  }
+
+if(!(vict=get_char_room_vis(ch,arg))) {
+  send_to_char("Er, Who ??\r\n",ch);
+  return;
+}
+else {
+  if(GET_CLAN(vict)!=clan[clan_num].id) {
+    if(GET_CLAN_RANK(vict)>0) {
+      send_to_char("They're already in a clan.\r\n",ch);
+      return;
+    }
+    else {
+      send_to_char("They didn't request to join your clan.\r\n",ch);
+      return;
+    }
+  }
+  else
+    if(GET_CLAN_RANK(vict)>0) {
+      send_to_char("They're already in your clan.\r\n",ch);
+      return;
+    }
+  if(GET_LEVEL(vict)>=LVL_IMMORT) {
+    send_to_char("You cannot enroll immortals in clans.\r\n",ch);
+    return; }
+}
+
+GET_CLAN_RANK(vict)++;
+save_char(vict, vict->in_room);
+clan[clan_num].power += GET_LEVEL(vict);
+clan[clan_num].members++;
+send_to_char("You've been enrolled in the clan you chose!\r\n",vict);
+send_to_char("Done.\r\n",ch);
+
+return;
+}
+
+void do_clan_expel (struct char_data *ch, char *arg)
+{
+struct char_data *vict=NULL;
+int clan_num,immcom=0;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return; } }
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return; } }
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_EXPEL] && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return; }
+
+if(!(vict=get_char_room_vis(ch,arg))) {
+  send_to_char("Er, Who ??\r\n",ch);
+  return; }
+else {
+  if(GET_CLAN(vict)!=clan[clan_num].id) {
+    send_to_char("They're not in your clan.\r\n",ch);
+    return; }
+  else {
+    if(GET_CLAN_RANK(vict)>=GET_CLAN_RANK(ch) && !immcom) {
+      send_to_char("You cannot kick out that person.\r\n",ch);
+      return; } } }
+
+GET_CLAN(vict)=0;
+GET_CLAN_RANK(vict)=0;
+save_char(vict, vict->in_room);
+clan[clan_num].members--;
+clan[clan_num].power-=GET_LEVEL(vict);
+send_to_char("You've been kicked out of your clan!\r\n",vict);
+send_to_char("Done.\r\n",ch);
+
+return;
+}
+
+void do_clan_demote (struct char_data *ch, char *arg)
+{
+struct char_data *vict=NULL;
+int clan_num,immcom=0;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return; } }
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return; } }
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_DEMOTE] && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return; }
+
+if(!(vict=get_char_room_vis(ch,arg))) {
+  send_to_char("Er, Who ??\r\n",ch);
+  return; }
+else {
+  if(GET_CLAN(vict)!=clan[clan_num].id) {
+    send_to_char("They're not in your clan.\r\n",ch);
+    return; }
+  else {
+    if(GET_CLAN_RANK(vict)==1) {
+      send_to_char("They can't be demoted any further, use expel now.\r\n",ch);
+      return; }
+    if(GET_CLAN_RANK(vict)>=GET_CLAN_RANK(ch) && !immcom) {
+      send_to_char("You cannot demote a person of this rank!\r\n",ch);
+      return; } } }
+
+GET_CLAN_RANK(vict)--;
+save_char(vict, vict->in_room);
+send_to_char("You've demoted within your clan!\r\n",vict);
+send_to_char("Done.\r\n",ch);
+return;
+}
+
+void do_clan_promote (struct char_data *ch, char *arg)
+{
+struct char_data *vict=NULL;
+int clan_num,immcom=0;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return; } }
+else {
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return; } }
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_PROMOTE] && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return; }
+
+if(!(vict=get_char_room_vis(ch,arg))) {
+  send_to_char("Er, Who ??\r\n",ch);
+  return; }
+else {
+  if(GET_CLAN(vict)!=clan[clan_num].id) {
+    send_to_char("They're not in your clan.\r\n",ch);
+    return; }
+  else {
+    if(GET_CLAN_RANK(vict)==0) {
+      send_to_char("They're not enrolled yet.\r\n",ch);
+      return; }
+    if((GET_CLAN_RANK(vict)+1)>GET_CLAN_RANK(ch) && !immcom) {
+      send_to_char("You cannot promote that person over your rank!\r\n",ch);
+      return; }
+    if(GET_CLAN_RANK(vict)==clan[clan_num].ranks) {
+      send_to_char("You cannot promote someone over the top rank!\r\n",ch);
+      return; } } }
+
+GET_CLAN_RANK(vict)++;
+save_char(vict, vict->in_room);
+send_to_char("You've been promoted within your clan!\r\n",vict);
+send_to_char("Done.\r\n",ch);
+return;
+}
+
+void do_clan_who (struct char_data *ch)
+{
+struct descriptor_data *d;
+struct char_data *tch;
+char line_disp[90];
+
+if(GET_CLAN_RANK(ch)==0) {
+  send_to_char("You do not belong to a clan!\r\n",ch);
+  return; }
+
+send_to_char("\r\nList of your clan members\r\n",ch);
+send_to_char("-------------------------\r\n",ch);
+  for (d=descriptor_list; d; d=d->next){
+    if(d->connected)
+      continue;
+    if((tch=d->character))
+      if(GET_CLAN(tch)==GET_CLAN(ch) && GET_CLAN_RANK(tch)>0) {
+        sprintf(line_disp,"%s\r\n",GET_NAME(tch));
+        send_to_char(line_disp,ch); }
+  }
+return;
+}
+
+void do_clan_status (struct char_data *ch)
+{
+char line_disp[90];
+int clan_num;
+
+if(GET_LEVEL(ch)>=LVL_IMMORT) {
+  send_to_char("You are immortal and cannot join any clan!\r\n",ch);
+  return; }
+
+clan_num=find_clan_by_id(GET_CLAN(ch));
+
+if(GET_CLAN_RANK(ch)==0)
+  if(clan_num>=0) {
+    sprintf(line_disp,"You applied to %s\r\n",clan[clan_num].name);
+    send_to_char(line_disp,ch);
+    return; }
+  else {
+    send_to_char("You do not belong to a clan!\r\n",ch);
+    return; }
+
+ sprintf(line_disp,"You are %s (Rank %d) of %s (ID %d)\r\n",
+    clan[clan_num].rank_name[GET_CLAN_RANK(ch)-1],GET_CLAN_RANK(ch),
+    clan[clan_num].name,clan[clan_num].id);
+ send_to_char(line_disp,ch);
+
+return;
+}
+
+void do_clan_apply (struct char_data *ch, char *arg)
+{
+int clan_num;
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)>=LVL_IMMORT) {
+  send_to_char("Gods cannot apply for any clan.\r\n",ch);
+  return; }
+
+if(GET_CLAN_RANK(ch)>0) {
+  send_to_char("You already belong to a clan!\r\n",ch);
+  return; }
+else {
+  if ((clan_num = find_clan(arg)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return; } }
+
+if(GET_LEVEL(ch) < clan[clan_num].app_level) {
+  send_to_char("You are not mighty enough to apply to this clan.\r\n",ch);
+  return; }
+
+if(GET_GOLD(ch) < clan[clan_num].app_fee) {
+  send_to_char("You cannot afford the application fee!\r\n", ch);
+  return; }
+
+GET_GOLD(ch) -= clan[clan_num].app_fee;
+clan[clan_num].treasure += clan[clan_num].app_fee;
+save_clans();
+GET_CLAN(ch)=clan[clan_num].id;
+save_char(ch, ch->in_room);
+send_to_char("You've applied to the clan!\r\n",ch);
+
+return;
+}
+
+void do_clan_info (struct char_data *ch, char *arg)
+{
+int i=0,j;
+
+if(num_of_clans == 0) {
+  send_to_char("No clans have formed yet.\r\n",ch);
+  return; }
+
+if(!(*arg)) {
+  sprintf(buf, "\r");
+  for(i=0; i < num_of_clans; i++)
+    sprintf(buf, "%s[%-3d]  %-20s Members: %3d  Power: %5d  Appfee: %d\r\n",buf,
+    i, clan[i].name,clan[i].members,clan[i].power,clan[i].app_fee);
+  page_string(ch->desc,buf, 1);
+  return; }
+else
+  if ((i = find_clan(arg)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return; }
+
+sprintf(buf, "Info for clan <<%s>>:\r\n",clan[i].name);
+send_to_char(buf, ch);
+sprintf(buf, "Ranks      : %d\r\nTitles     : ",clan[i].ranks);
+for(j=0;j<clan[i].ranks;j++)
+  sprintf(buf, "%s%s ",buf,clan[i].rank_name[j]);
+sprintf(buf, "%s\r\nMembers    : %d\r\nPower      : %d\t\nTreasure   : %ld\r\nSpells     : ",buf, clan[i].members, clan[i].power, clan[i].treasure);
+for(j=0; j<5;j++)
+  if(clan[i].spells[j])
+    sprintf(buf, "%s%d ",buf,clan[i].spells[j]);
+sprintf(buf, "%s\r\n",buf);
+send_to_char(buf, ch);
+sprintf(buf,"Clan privileges:\r\n");
+for(j=0; j<NUM_CP;j++)
+  sprintf(buf, "%s   %-10s: %d\r\n",buf,clan_privileges[j],clan[i].privilege[j]);
+sprintf(buf, "%s\r\n",buf);
+send_to_char(buf, ch);
+/*
+sprintf(buf, "Description:\r\n%s\r\n\n", clan[i].description);
+send_to_char(buf, ch);
+*/
+if((clan[i].at_war[0] == 0) && (clan[i].at_war[1] == 0) && (clan[i].at_war[2] == 0) && (clan[i].at_war[3] == 0))
+  send_to_char("This clan is at peace with all others.\r\n", ch);
+else
+  send_to_char("This clan is at war.\r\n", ch);
+sprintf(buf, "Application fee  : %d gold\r\nMonthly Dues     : %d gold\r\n", clan[i].app_fee, clan[i].dues);
+send_to_char(buf, ch);
+sprintf(buf, "Application level: %d\r\n", clan[i].app_level);
+send_to_char(buf, ch);
+
+return;
+}
+
+sh_int find_clan_by_id(int idnum)
+{
+int i;
+for( i=0; i < num_of_clans; i++)
+  if(idnum==clan[i].id)
+    return i;
+return -1;
+}
+
+sh_int find_clan(char *name)
+{
+int i;
+for( i=0; i < num_of_clans; i++)
+  if(strcmp(CAP(name), CAP(clan[i].name))==0)
+    return i;
+return -1;
+}
+
+void save_clans()
+{
+FILE *fl;
+
+if (!(fl = fopen(CLAN_FILE, "wb"))) {
+  log("SYSERR: Unable to open clan file");
+  return; }
+
+fwrite(&num_of_clans, sizeof(int), 1, fl);
+fwrite(clan, sizeof(struct clan_rec), num_of_clans, fl);
+fclose(fl);
+return;
+}
+
+
+void init_clans()
+{
+FILE *fl;
+int i,j;
+extern int top_of_p_table;
+extern struct player_index_element *player_table;
+struct char_file_u chdata;
+
+memset(clan,0,sizeof(struct clan_rec)*MAX_CLANS);
+num_of_clans=0;
+i=0;
+
+if (!(fl = fopen(CLAN_FILE, "rb"))) {
+  log("   Clan file does not exist. Will create a new one");
+  save_clans();
+  return; }
+
+fread(&num_of_clans, sizeof(int), 1, fl);
+fread(clan, sizeof(struct clan_rec), num_of_clans, fl);
+fclose(fl);
+
+log("   Calculating powers and members");
+for(i=0;i<num_of_clans;i++) {
+  clan[i].power=0;
+  clan[i].members=0;
+}
+for (j = 0; j <= top_of_p_table; j++){
+  load_char((player_table + j)->name, &chdata);
+  if((i=find_clan_by_id(chdata.player_specials_saved.clan))>=0) {
+    clan[i].power+=chdata.level;
+    clan[i].members++;
+  }
+}
+
+return;
+}
+
+void do_clan_bank(struct char_data *ch, char *arg, int action)
+{
+int clan_num,immcom=0;
+long amount=0;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return;
+  }
+}
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_WITHDRAW] && !immcom && action
+==CB_WITHDRAW) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return;
+  }
+
+if(!(*arg)) {
+  send_to_char("Deposit how much?\r\n",ch);
+  return;
+  }
+
+if(!is_number(arg)) {
+  send_to_char("Deposit what?\r\n",ch);
+  return;
+  }
+
+amount=atoi(arg);
+
+if(!immcom && action==CB_DEPOSIT && GET_GOLD(ch)<amount) {
+  send_to_char("You do not have that kind of money!\r\n",ch);
+  return;
+  }
+
+if(action==CB_WITHDRAW && clan[clan_num].treasure<amount) {
+  send_to_char("The clan is not wealthy enough for your needs!\r\n",ch);
+  return;
+  }
+
+switch(action) {
+  case CB_WITHDRAW:
+    GET_GOLD(ch)+=amount;
+    clan[clan_num].treasure-=amount;
+    send_to_char("You withdraw from the clan's treasure.\r\n",ch);
+    break;
+  case CB_DEPOSIT:
+    if(!immcom) GET_GOLD(ch)-=amount;
+    clan[clan_num].treasure+=amount;
+    send_to_char("You add to the clan's treasure.\r\n",ch);
+    break;
+  default:
+    send_to_char("Problem in command, please report.\r\n",ch);
+    break;
+  }
+save_char(ch, ch->in_room);
+save_clans();
+return;
+}
+
+void do_clan_money(struct char_data *ch, char *arg, int action)
+{
+int clan_num,immcom=0;
+long amount=0;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return;
+  }
+}
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_SET_FEES] && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return;
+  }
+
+if(!(*arg)) {
+  send_to_char("Set it to how much?\r\n",ch);
+  return;
+  }
+
+if(!is_number(arg)) {
+  send_to_char("Set it to what?\r\n",ch);
+  return;
+  }
+
+amount=atoi(arg);
+
+switch(action) {
+  case CM_APPFEE:
+    clan[clan_num].app_fee=amount;
+    send_to_char("You change the application fee.\r\n",ch);
+    break;
+  case CM_DUES:
+    clan[clan_num].dues=amount;
+    send_to_char("You change the monthly dues.\r\n",ch);
+    break;
+  default:
+    send_to_char("Problem in command, please report.\r\n",ch);
+    break;
+  }
+
+save_clans();
+return;
+}
+
+void do_clan_ranks(struct char_data *ch, char *arg)
+{
+int i,j;
+int clan_num,immcom=0;
+int new_ranks;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+extern int top_of_p_table;
+extern struct player_index_element *player_table;
+struct char_file_u chdata;
+struct char_data *victim=NULL;
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return;
+  }
+}
+
+if(GET_CLAN_RANK(ch)!=clan[clan_num].ranks && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return;
+  }
+
+if(!(*arg)) {
+  send_to_char("Set how many ranks?\r\n",ch);
+  return;
+  }
+
+if(!is_number(arg)) {
+  send_to_char("Set the ranks to what?\r\n",ch);
+  return;
+  }
+
+new_ranks=atoi(arg);
+
+if(new_ranks==clan[clan_num].ranks) {
+  send_to_char("The clan already has this number of ranks.\r\n",ch);
+  return;
+  }
+
+if(new_ranks<2 || new_ranks>20) {
+  send_to_char("Clans must have from 2 to 20 ranks.\r\n",ch);
+  return;
+  }
+
+if(GET_GOLD(ch)<750000 && !immcom) {
+  send_to_char("Changing the clan hierarchy requires 750,000 coins!\r\n",ch);
+  return;
+  }
+
+if(!immcom)
+  GET_GOLD(ch)-=750000;
+
+for (j = 0; j <= top_of_p_table; j++) {
+  if((victim=is_playing((player_table +j)->name))) {
+    if(GET_CLAN(victim)==clan[clan_num].id) {
+      if(GET_CLAN_RANK(victim)<clan[clan_num].ranks && GET_CLAN_RANK(victim)>0)
+        GET_CLAN_RANK(victim)=1;
+      if(GET_CLAN_RANK(victim)==clan[clan_num].ranks)
+        GET_CLAN_RANK(victim)=new_ranks;
+      save_char(victim, victim->in_room);
+    }
+  }
+  else {
+    load_char((player_table + j)->name, &chdata);
+    if(chdata.player_specials_saved.clan==clan[clan_num].id) {
+      if(chdata.player_specials_saved.clan_rank<clan[clan_num].ranks && chdata.
+player_specials_saved.clan_rank>0)
+        chdata.player_specials_saved.clan_rank=1;
+      if(chdata.player_specials_saved.clan_rank==clan[clan_num].ranks)
+        chdata.player_specials_saved.clan_rank=new_ranks;
+      save_char_file_u(chdata);
+    }
+  }
+}
+
+clan[clan_num].ranks=new_ranks;
+for(i=0;i<clan[clan_num].ranks-1;i++)
+  strcpy(clan[clan_num].rank_name[i],"Member");
+strcpy(clan[clan_num].rank_name[clan[clan_num].ranks -1],"Leader");
+for(i=0;i<NUM_CP;i++)
+  clan[clan_num].privilege[i]=new_ranks;
+
+save_clans();
+return;
+}
+
+void do_clan_titles( struct char_data *ch, char *arg)
+{
+char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
+int clan_num=0,rank;
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+  if(GET_CLAN_RANK(ch)!=clan[clan_num].ranks) {
+    send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg2);
+  if(!is_number(arg1)) {
+    send_to_char("You need to specify a clan number.\r\n",ch);
+    return;
+  }
+  if((clan_num=atoi(arg1))<0 || clan_num>=num_of_clans) {
+    send_to_char("There is no clan with that number.\r\n",ch);
+    return;
+  }
+}
+
+half_chop(arg,arg1,arg2);
+
+if(!is_number(arg1)) {
+  send_to_char("You need to specify a rank number.\r\n",ch);
+  return; }
+
+rank=atoi(arg1);
+
+if(rank<1 || rank>clan[clan_num].ranks) {
+  send_to_char("This clan has no such rank number.\r\n",ch);
+  return; }
+
+if(strlen(arg2)<1 || strlen(arg2)>19) {
+  send_to_char("You need a clan title of under 20 characters.\r\n",ch);
+  return; }
+
+strcpy(clan[clan_num].rank_name[rank-1],arg2);
+save_clans();
+send_to_char("Done.\r\n",ch);
+return;
+}
+
+void do_clan_application( struct char_data *ch, char *arg)
+{
+int clan_num,immcom=0;
+int applevel;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg2)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return;
+  }
+}
+
+if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_SET_APPLEV] && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return;
+  }
+
+if(!(*arg)) {
+  send_to_char("Set to which level?\r\n",ch);
+  return;
+  }
+
+if(!is_number(arg)) {
+  send_to_char("Set the application level to what?\r\n",ch);
+  return;
+  }
+
+applevel=atoi(arg);
+
+if(applevel<1 || applevel>999) {
+  send_to_char("The application level can go from 1 to 999.\r\n",ch);
+  return;
+  }
+
+clan[clan_num].app_level=applevel;
+save_clans();
+
+return;
+}
+
+void do_clan_sp(struct char_data *ch, char *arg, int priv)
+{
+int clan_num,immcom=0;
+int rank;
+char arg1[MAX_INPUT_LENGTH];
+char arg2[MAX_INPUT_LENGTH];
+
+if (!(*arg)) {
+  send_clan_format(ch);
+  return; }
+
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return;
+  }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  immcom=1;
+  half_chop(arg,arg1,arg2);
+  strcpy(arg,arg1);
+  if ((clan_num = find_clan(arg1)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return;
+  }
+}
+
+if(GET_CLAN_RANK(ch)!=clan[clan_num].ranks && !immcom) {
+  send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+  return;
+  }
+
+if(!(*arg)) {
+  send_to_char("Set the privilege to which rank?\r\n",ch);
+  return;
+  }
+
+if(!is_number(arg)) {
+  send_to_char("Set the privilege to what?\r\n",ch);
+  return;
+  }
+
+rank=atoi(arg);
+
+if(rank<1 || rank>clan[clan_num].ranks) {
+  send_to_char("There is no such rank in the clan.\r\n",ch);
+  return;
+  }
+
+clan[clan_num].privilege[priv]=rank;
+save_clans();
+
+return;
+}
+
+void do_clan_plan(struct char_data *ch, char *arg)
+{
+int clan_num;
+
+send_to_char("Command not ready yet\r\n",ch);
+return;
+
+if(GET_LEVEL(ch)<LVL_IMMORT) {
+  if((clan_num=find_clan_by_id(GET_CLAN(ch)))<0) {
+    send_to_char("You don't belong to any clan!\r\n",ch);
+    return; }
+  if(GET_CLAN_RANK(ch)<clan[clan_num].privilege[CP_SET_PLAN]) {
+    send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
+    return; }
+}
+else {
+  if(GET_LEVEL(ch)<LVL_CLAN_GOD) {
+    send_to_char("You do not have clan privileges.\r\n", ch);
+    return; }
+  if (!(*arg)) {
+    send_clan_format(ch);
+    return; }
+  if ((clan_num = find_clan(arg)) < 0) {
+    send_to_char("Unknown clan.\r\n", ch);
+    return; }
+}
+
+if(strlen(clan[clan_num].description)==0) {
+   sprintf(buf, "Enter the description, or plan for clan <<%s>>.\r\n",clan[clan_num].name);
+   send_to_char(buf, ch);
+}
+else {
+   sprintf(buf, "Old plan for clan <<%s>>:\r\n", clan[clan_num].name);
+   send_to_char(buf, ch);
+   send_to_char(clan[clan_num].description, ch);
+   send_to_char("Enter new plan:\r\n", ch);
+}
+send_to_char("End with @ on a line by itself.\r\n", ch);
+/*ch->desc->str   = clan[clan_num].description;*/
+ch->desc->max_str = CLAN_PLAN_LENGTH;
+save_clans();
+return;
+}
+
+void do_clan_privilege( struct char_data *ch, char *arg)
+{
+char arg1[MAX_INPUT_LENGTH] ,arg2[MAX_INPUT_LENGTH];
+int i;
+
+half_chop(arg,arg1,arg2);
+
+if (is_abbrev(arg1,"setplan"  )) { do_clan_sp(ch,arg2,CP_SET_PLAN);   return ;}
+if (is_abbrev(arg1,"enroll"   )) { do_clan_sp(ch,arg2,CP_ENROLL);     return ;}
+if (is_abbrev(arg1,"expel"    )) { do_clan_sp(ch,arg2,CP_EXPEL);      return ;}
+if (is_abbrev(arg1,"promote"  )) { do_clan_sp(ch,arg2,CP_PROMOTE);    return ;}
+if (is_abbrev(arg1,"demote"   )) { do_clan_sp(ch,arg2,CP_DEMOTE);     return ;}
+if (is_abbrev(arg1,"withdraw" )) { do_clan_sp(ch,arg2,CP_WITHDRAW);   return ;}
+if (is_abbrev(arg1,"setfees"  )) { do_clan_sp(ch,arg2,CP_SET_FEES);   return ;}
+if (is_abbrev(arg1,"setapplev")) { do_clan_sp(ch,arg2,CP_SET_APPLEV); return ;}
+send_to_char("\r\nClan privileges:\r\n", ch);
+for(i=0;i<NUM_CP;i++) {
+  sprintf(arg1,"\t%s\r\n",clan_privileges[i]);
+  send_to_char(arg1,ch); }
+}
+
+void do_clan_set(struct char_data *ch, char *arg)
+{
+char arg1[MAX_INPUT_LENGTH] ,arg2[MAX_INPUT_LENGTH];
+
+half_chop(arg,arg1,arg2);
+
+if (is_abbrev(arg1, "plan"      )) { do_clan_plan(ch,arg2);            return ;
+}
+if (is_abbrev(arg1, "ranks"     )) { do_clan_ranks(ch,arg2);           return ;
+}
+if (is_abbrev(arg1, "title"     )) { do_clan_titles(ch,arg2);          return ;
+}
+if (is_abbrev(arg1, "privilege" )) { do_clan_privilege(ch,arg2);       return ;
+}
+if (is_abbrev(arg1, "dues"      )) { do_clan_money(ch,arg2,CM_DUES);   return ;
+}
+if (is_abbrev(arg1, "appfee"    )) { do_clan_money(ch,arg2,CM_APPFEE); return ;
+}
+if (is_abbrev(arg1, "applev"    )) { do_clan_application(ch,arg2);     return ;
+}
+send_clan_format(ch);
+}
+
+ACMD(do_clan)
+{
+char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
+
+half_chop(argument, arg1, arg2);
+
+if (is_abbrev(arg1, "create"  )) { do_clan_create(ch,arg2);   return ;}
+if (is_abbrev(arg1, "destroy" )) { do_clan_destroy(ch,arg2);  return ;}
+if (is_abbrev(arg1, "enroll"  )) { do_clan_enroll(ch,arg2);   return ;}
+if (is_abbrev(arg1, "expel"   )) { do_clan_expel(ch,arg2);    return ;}
+if (is_abbrev(arg1, "who"     )) { do_clan_who(ch);           return ;}
+if (is_abbrev(arg1, "status"  )) { do_clan_status(ch);        return ;}
+if (is_abbrev(arg1, "info"    )) { do_clan_info(ch,arg2);     return ;}
+if (is_abbrev(arg1, "apply"   )) { do_clan_apply(ch,arg2);    return ;}
+if (is_abbrev(arg1, "demote"  )) { do_clan_demote(ch,arg2);   return ;}
+if (is_abbrev(arg1, "promote" )) { do_clan_promote(ch,arg2);  return ;}
+if (is_abbrev(arg1, "set"     )) { do_clan_set(ch,arg2);      return ;}
+if (is_abbrev(arg1, "withdraw")) { do_clan_bank(ch,arg2,CB_WITHDRAW); return ;}
+if (is_abbrev(arg1, "deposit" )) { do_clan_bank(ch,arg2,CB_DEPOSIT);  return ;}
+send_clan_format(ch);
+}
diff -uprN stk/clan.h src/clan.h
--- stk/clan.h	Wed Dec 31 19:00:00 1969
+++ src/clan.h	Tue Feb 10 08:05:38 1998
@@ -0,0 +1,49 @@
+#define MAX_CLANS        20
+#define LVL_CLAN_GOD     LVL_GOD
+#define DEFAULT_APP_LVL  8
+#define CLAN_PLAN_LENGTH 800
+
+#define GET_CLAN(ch)            ((ch)->player_specials->saved.clan)
+#define GET_CLAN_RANK(ch)       ((ch)->player_specials->saved.clan_rank)
+
+#define CP_SET_PLAN   0
+#define CP_ENROLL     1
+#define CP_EXPEL      2
+#define CP_PROMOTE    3
+#define CP_DEMOTE     4
+#define CP_SET_FEES   5
+#define CP_WITHDRAW   6
+#define CP_SET_APPLEV 7
+#define NUM_CP        8        /* Number of clan privileges */
+
+#define CM_DUES   1
+#define CM_APPFEE 2
+
+#define CB_DEPOSIT  1
+#define CB_WITHDRAW 2
+
+void save_clans(void);
+void init_clans(void);
+sh_int find_clan_by_id(int clan_id);
+sh_int find_clan(char *name);
+
+extern struct clan_rec clan[MAX_CLANS];
+extern int num_of_clans;
+
+struct clan_rec {
+  int   id;
+  char  name[32];
+  ubyte ranks;
+  char  rank_name[20][20];
+  long  treasure;
+  int   members;
+  int   power;
+  int   app_fee;
+  int   dues;
+  int   spells[5];
+  int   app_level;
+  ubyte privilege[20];
+  int   at_war[4];
+  char  description[CLAN_PLAN_LENGTH];
+};
+
diff -uprN stk/db.c src/db.c
--- stk/db.c	Tue Feb 10 07:53:45 1998
+++ src/db.c	Tue Feb 10 08:36:56 1998
@@ -121,6 +121,7 @@ void load_banned(void);
 void Read_Invalid_List(void);
 void boot_the_shops(FILE * shop_f, char *filename, int rec_count);
 int hsort(const void *a, const void *b);
+void init_clans(void);
 
 /* external vars */
 extern int no_specials;
@@ -291,6 +292,9 @@ void boot_db(void)
   sort_commands();
   sort_spells();
 
+  log("Booting Clans.");
+  init_clans();
+
   log("Booting mail system.");
   if (!scan_file()) {
     log("    Mail boot failed -- Mail system disabled");
@@ -2421,5 +2425,17 @@ int real_object(int virtual)
       top = mid - 1;
     else
       bot = mid + 1;
+  }
+}
+
+void save_char_file_u(struct char_file_u st)
+{
+int player_i;
+int find_name(char *name);
+
+if((player_i = find_name(st.name)) >=0 )
+  {
+  fseek(player_fl, player_i * sizeof(struct char_file_u), SEEK_SET);
+  fwrite(&st, sizeof(struct char_file_u), 1, player_fl);
   }
 }
diff -uprN stk/db.h src/db.h
--- stk/db.h	Tue Feb 10 07:53:45 1998
+++ src/db.h	Tue Feb 10 07:55:38 1998
@@ -49,6 +49,7 @@
 #define MAIL_FILE	"etc/plrmail"	/* for the mudmail system	*/
 #define BAN_FILE	"etc/badsites"	/* for the siteban system	*/
 #define HCONTROL_FILE	"etc/hcontrol"  /* for the house system		*/
+#define CLAN_FILE	"etc/clans"	/* for the clan system		*/
 
 #ifdef CIRCLE_AMIGA
 #define FASTBOOT_FILE   "/.fastboot"    /* autorun: boot without sleep  */
diff -uprN stk/interpreter.c src/interpreter.c
--- stk/interpreter.c	Tue Feb 10 07:53:45 1998
+++ src/interpreter.c	Tue Feb 10 07:58:28 1998
@@ -61,10 +61,12 @@ ACMD(do_backstab);
 ACMD(do_ban);
 ACMD(do_bash);
 ACMD(do_cast);
+ACMD(do_clan);
 ACMD(do_color);
 ACMD(do_commands);
 ACMD(do_consider);
 ACMD(do_credits);
+ACMD(do_ctell);
 ACMD(do_date);
 ACMD(do_dc);
 ACMD(do_diagnose);
@@ -233,6 +235,7 @@ const struct command_info cmd_info[] = {
   { "cackle"   , POS_RESTING , do_action   , 0, 0 },
   { "check"    , POS_STANDING, do_not_here , 1, 0 },
   { "chuckle"  , POS_RESTING , do_action   , 0, 0 },
+  { "clan"     , POS_SLEEPING, do_clan     , 1, 0 },
   { "clap"     , POS_RESTING , do_action   , 0, 0 },
   { "clear"    , POS_DEAD    , do_gen_ps   , 0, SCMD_CLEAR },
   { "close"    , POS_SITTING , do_gen_door , 0, SCMD_CLOSE },
@@ -247,6 +250,7 @@ const struct command_info cmd_info[] = {
   { "credits"  , POS_DEAD    , do_gen_ps   , 0, SCMD_CREDITS },
   { "cringe"   , POS_RESTING , do_action   , 0, 0 },
   { "cry"      , POS_RESTING , do_action   , 0, 0 },
+  { "ctell"    , POS_SLEEPING, do_ctell    , 0, 0 },
   { "cuddle"   , POS_RESTING , do_action   , 0, 0 },
   { "curse"    , POS_RESTING , do_action   , 0, 0 },
   { "curtsey"  , POS_STANDING, do_action   , 0, 0 },
diff -uprN stk/structs.h src/structs.h
--- stk/structs.h	Tue Feb 10 07:53:45 1998
+++ src/structs.h	Tue Feb 10 08:07:37 1998
@@ -735,8 +735,8 @@ struct player_special_data_saved {
    /* spares below for future expansion.  You can change the names from
       'sparen' to something meaningful, but don't change the order.  */
 
-   ubyte spare0;
-   ubyte spare1;
+   ubyte clan;
+   ubyte clan_rank;
    ubyte spare2;
    ubyte spare3;
    ubyte spare4;
diff -uprN stk/utils.c src/utils.c
--- stk/utils.c	Tue Feb 10 07:53:45 1998
+++ src/utils.c	Tue Feb 10 08:12:42 1998
@@ -475,3 +475,15 @@ int num_pc_in_room(struct room_data *roo
 
 
   
+struct char_data *is_playing(char *vict_name)
+{
+  extern struct descriptor_data *descriptor_list;
+  struct descriptor_data *i, *next_i;
+
+  for (i = descriptor_list; i; i = next_i) {
+    next_i = i->next;
+    if(i->connected == CON_PLAYING && !strcmp(i->character->player.name,CAP(vict_name)))
+      return i->character;
+  }
+  return NULL;
+}

</PRE>

 << <A href="/patch/981001/1430231.shtml">128-bit Patch [by Chris Powell]</A> | <A href="/commentSubmit.pl?sid=981001/1455229&pid=0"><B>Reply</B></A>  | <A HREF="/dumpbody.pl?sid=981001/1455229">View as text</A> | <A href="/patch/981001/1455229_F.shtml">Flattened</A>  | <A href="/articles/981008/0012252.shtml">Buffer Allocation System 2.0 (Preview)</A> >> <P>  </TD><TD valign="top" align="center"><BR><TABLE cellpadding=0 cellspacing=0 width="200" align=center border=0>
<TR bgcolor="#00bbdd">
  <TD><IMG src="/images/leftfade.gif" alt=""></TD>
  <TD valign=middle width="98%" align=center><FONT size=4 color="#000000" face="arial,helvetica"><B>Related Links</B></FONT></TD>
  <TD align=right><IMG src="/images/rightfade.gif" alt=""></TD>
</TR>
<TR><TD colspan=3>
  <TABLE cellspacing=0 cellpadding=0 border=0 width="100%">
    <TR>
      <TD bgcolor="#cdcdcd"> </TD>
      <TD bgcolor="#cdcdcd"><FONT color="#000000"><A HREF=http://www.circlemud.org/>CircleMUD</A><BR>
<A HREF="/patches/Chris_Powell/clan.README">original README</A><BR><A href="/search.pl?topic=patch"> Related Articles </A><BR>
<A href="/search.pl?author=greerga"> More by greerga </A><BR></FONT></TD>
      <TD bgcolor="#000000"> </TD>
    </TR>
    <TR>
      <TD></TD>
      <TD bgcolor="#000000" colspan=2> </TD>
    </TR>
  </TABLE>
</TD></TR>
</TABLE>
<BR></TD>
</TR></TABLE>
<TABLE width="99%" bgcolor="#ffffff">
</TD></TR></TABLE><!--#include virtual='/slashfoot.inc'-->
<!--#exec cmd='/home/circledb/www/dev/slashlog.cgi'-->