Cedit/
Hey all, 
   this is a clan editor I wrote from Gary McNickle's gedit code.
   I changed a lot of it and added a lot my own coding into it. I 
   did find a bug in his clan system which it doesnt take the clan
   out of memory when being deleted unless you do a copyover or
   reboot the game. It also doesnt take it out of the file if its
   been created earlier. So I added a deletion code as well. I 
   used sedit and hedit as an inspiration to re-code this. Feel free 
   to use it at will. I used a static array instead of a dynamic
   structure. Way too many files needed to be edited if I made it
   dynamic. This was made around Blizzard's clan commands
   so no major editing of those arent needed, just minor changes.
   Thats the lazy way :P

-Bojack of dragonball arena

   Before adding this in, make sure you do a backup of your mud.
Also add clan.c into your src folder. If you have one there, either
replace it with this assuming it has not been changed and is
written by blizzard. If it has then just add/change whats needed.
Depending on how you have your make file, you might have to add
clan.c to it. We use $(wildcard *.c) so we dont have to add .o files
manually. Also add guild.dat into your data folder or change your
existing one to the structure in this one provided.

   Add this to your helpfiles. I put mine in help_olc.are.
4 CEDIT CSAVE~
{cCEDIT CSAVE{x
Syntax:   {RCEDIT{x [name]            - Clan to edit
Shortcut: {RCEDIT{x [create] [name]   - Clan creation

Syntax:   {RASAVE{x <world/changed>   -Saves clans to file
Shortcut: {RCSAVE{x                   -Saves clans to file


The following commands are available from within the CEDITOR:

name     <name>			      - Sets the name of the clan
				        if you used cedit create
					it sets it for you.
who      <name>			      - Sets the who name for do_who
leader   <name>			      - Sets the leaders name
rank     <rank #> <name>	      - Sets the rank name
flag     <flag name>		      - Sets the flag, type ? clan 
				        for a list of flags

delete				      - Deletes the clan from file
show				      - Shows the editor
list				      - Lists active clans in the game

The above commands are used to expand clans within the game.
Inside the editor, typing {RCOMMANDS{x lists working commands and ? gives
help. For a list of valid flags type '{c? clan{x'. In order to delete
a clan, you have to be editing the clan you want to delete then
type '{Rdelete{x'.

      This clan editor was changed from its original clan code which
was written by Gary McNickle called 'GEDIT' based off the stock Rom 2.4
clans written by Blizzard. I have taken hedit and gedit ideas and have
turned them into this clan editor. This is higly modified from GEDIT.
                   Thanks guys!

{R            Bojack{x of {YDrag{R*{Yn{RBall {CArena{x
~


---------------Pre-installation

-First go through the files finding any reference
 to  ctitle_table and change it to look similar:
clan_table[ch->clan].c_rank[ch->c_rank].rankname

 Whatever the reference is on ctitle.. just make sure
 it looks like this:
clan_table[ ].c_rank[ ].rankname on it


---------------Installation stuff

---------------act_comm.c

-for void do_clantalk, change to this:
    if (!is_clan (ch)
        || IS_SET(clan_table[ch->clan].flags, CLAN_INDEPENDENT) ) {


---------------act_info.c

-change clanlist to:
//Changed to reflect clans -Bo-
void do_clanlist (CHAR_DATA * ch, char *argument)
{
    char buf[MAX_STRING_LENGTH];
    int col, sn;

    if (IS_NPC(ch))
    return;

    sendch("{b================================================================={x\n\r",ch);
    sendch("{CN{came                           {CL{cogo                        {CL{ceader{x\n\r",ch);
    sendch("{b================================================================={x\n\r",ch);

    col = 0;
    for (sn = 0; sn < (1 + top_clan); sn++)
    {
        if (IS_IMMORTAL(ch) )
        {
            if (clan_table[sn].name != 0)
            {
                sprintf (buf, "{c%-27.27s{x %8s {r%25s{x",
                        clan_table[sn].name,
                        clan_table[sn].who_name,
                        clan_table[sn].leader);
                sendch (buf, ch);
            }
            if (++col % 1 == 0)
                sendch("\n\r", ch);

        }
        else
        {
            if (clan_table[sn].name != 0
                && str_cmp(clan_table[sn].name, "Immortal") )
            {
                sprintf (buf, "{c%-27.27s{x %4s {r%25s{x",
                        clan_table[sn].name,
                        clan_table[sn].who_name,
                        clan_table[sn].leader);
                sendch (buf, ch);
            }
            if (++col % 1 == 0)
                sendch("\n\r", ch);
        }
    }

    if (col % 1 != 0)
        sendch ("\n\r", ch);
    return;
}

-in do_score
-add after immortal stuff if not there:
    if (ch->clan)
    {
        sendch("{Y------------------------------{BCLAN{Y-------------------------------{x\n\r",ch);

        sprintf(buf,"{cClan:{W %-27s{x",clan_table[ch->clan].name);
        sendch(buf, ch);
        if (IS_SET(ch->act, PLR_LEADER))
            sendch("{cLeader    :{W Yes{x\n\r",ch);
        sprintf(buf,"{cRank:{W %-20d", ch->c_rank);
        sendch(buf, ch);
        if(IS_IMMORTAL(ch))
            sprintf(buf,"{cClan Title:{W %s{x\n\r", "Deity");
        else
            sprintf(buf,"{cClan Title:{W %s{x\n\r", clan_table[ch->clan].c_rank[ch->c_rank].rankname);
        sendch(buf,ch);
    }


-in do_who
-change:
//    bool rgfClan[MAX_CLAN];
    bool rgfClan[top_clan];

-change:
//    for (iClan = 0; iClan < MAX_CLAN; iClan++)
    for (iClan = 0; iClan < (1 + top_clan); iClan++)


---------------act_wiz.c

-before do_guild add:

//Added this to use later as a do_function();
void do_save_clans (CHAR_DATA *ch, char *argument)
{
    int i;
    bool found = FALSE;

    for (i = 1; clan_table[i].name != 0; i++)
    {
        if (IS_SET (clan_table[i].flags, CLAN_CHANGED) )
        {
            found = TRUE;
            break;
        }
    }

    if (!found)
    {
        sendch ("No modified clans to save.\n\rClan file up to date.\n\r", ch);
        return;
    }

    save_clans(ch, argument);
    sendch ("Clans file saved.\n\r", ch);
    return;
}

-in do_guild
-change  if (clan_table[clan].independent) to:
    if (IS_SET(clan_table[clan].flags, CLAN_INDEPENDENT))


-in do_mstat
-add or change below the immortal stuff:
    if (ch->clan)
    {
        sendch("{Y-----------------------------------------------------------------{x\n\r",ch);

        sprintf(buf,"{cClan:{W %-27s{x",clan_table[ch->clan].name);
        sendch(buf, ch);
        if (IS_SET(ch->act, PLR_LEADER))
            sendch("{cLeader    :{W Yes{x\n\r",ch);
        sprintf(buf,"{cRank:{W %-20d", ch->c_rank);
        sendch(buf, ch);
        if(IS_IMMORTAL(ch))
            sprintf(buf,"{cClan Title:{W %s{x\n\r", "Deity");
        else
            sprintf(buf,"{cClan Title:{W %s{x\n\r", clan_table[ch->clan].c_rank[ch->c_rank].rankname);
        sendch(buf,ch);
    }

---------------bit.c

-in flag_stat_type flag_stat_table
-add:
    {clan_flags, FALSE},

---------------db.c

-in local booting procedures
-add:
void load_clans args ( (void) ); /* Clans */

-in boot_db:
-RIGHT BEFORE these lines:
    /*
     * Read in all the area files.
     */
    logstr (LOG_GAME, "Loading areas");
-add:
    /* Read in the clan file. */
    load_clans();

-in do_memory:
-if there is a reference for clans there using MAX_CLAN already, 
 change it to this, otherwise add this before "Areas  %5d:
    sprintf (buf, "Clans   %5d\n\r", top_clan);
    sendch (buf, ch);

---------------db.h

-add:
/* from clan.c */
int                             top_clan;


---------------handler.c

-find and delete:
bool    is_clan         (CHAR_DATA *ch);
bool    is_same_clan    (CHAR_DATA *ch, CHAR_DATA *victim);

-find and change to a default death room:
        char_to_room (ch, get_room_index (clan_table[ch->clan].hall));

        char_to_room (ch, get_room_index (ROOM_VNUM_SNAKEWAY));
Note: we dont use death rooms for clans


---------------lookup.c

-find and delete:
int     clan_lookup     (const char *name);


---------------lookup.h

-delete if there:
int         clan_lookup     args( (const char *name) );


---------------interp.c

-after {"sedit", add:
    {"cedit",           do_cedit,               POS_DEAD, 4, LOG_ALWAYS, 1, FALSE},
    {"csave",           do_save_clans,          POS_DEAD, 4, LOG_ALWAYS, 1, FALSE},


---------------interp.h

-add:
DECLARE_DO_FUN( do_cedit                );
DECLARE_DO_FUN( do_save_clans           ); /* clan.c */


---------------merc.h

-find these and delete them:
-if you have clan_lookup in merc too, delete that as well
bool     is_clan             args( ( CHAR_DATA *ch ) );
bool     is_same_clan        args( ( CHAR_DATA *ch, CHAR_DATA *victim ));

-add under #if defined(unix) after #define NULL_FILE:
#define DATA_DIR        "../data/"  

-in Structure types.
-add:
typedef struct    clan_type        CLAN_DATA;

-after #define MAX_PC_RACE if MAX_CLAN isnt there, add it and put it
 to a 10+ number depending on how many clans you think you'll make.
-add after or with MAX_CLAN
#define MAX_CLAN           12 // Always go one higher then what we have
#define MAX_RANK           8 // Keep it at 8!

-after #define CH(d)
-add:
/*
 * Clan flags
 */
#define CLAN_DELETED            A
#define CLAN_CHANGED            B
#define CLAN_INDEPENDENT        C /* a "loner" guild */
#define CLAN_IMMORTAL           D /* immortal only clan */

-before
/*
 * Prototype for a mob.
 * This is the in-memory version of #MOBILES.
 */
struct    mob_index_data

-add:
/* Prototypes for clan data */
typedef struct clan_rank       rankdata;

struct clan_rank
{
    char *rankname;               /* name of rank */
};

struct clan_type
{
    long flags;                   /* flags for clan */
    char *name;                 /* name of clan */
    char *who_name;             /* name sent for "who" command */
    char *leader;                       /* leader of clan */
    rankdata c_rank[MAX_RANK];  /* clans rank system */
};

-in: One character (PC or NPC).
struct   char_data {

-if:     sh_int             clan; isnt added, add with this
 otherwise add or change:
//    int		       c_rank;
    sh_int             c_rank;

-around this:
#define IS_TRANSFORMED(ch) (ch->trans != TRANS_NONE)
#define IS_SWITCHED( ch )       ( ch->desc && ch->desc->original )
#define IS_BUILDER(ch, Area)    ( !IS_NPC(ch) && !IS_SWITCHED( ch ) &&      \

-add:
#define EDIT_CLAN(ch, Clan)     ( Clan = ch->desc->pEdit )

-after /* ban.c */ bool     check_ban
-add:
/* clan.c */
extern  int             top_clan;
struct  clan_type       clan_table[MAX_CLAN];
char *  clan_bit_name   args( ( int clan_flags ) );
bool    is_clan         args( (CHAR_DATA *ch) );
bool    is_same_clan    args( (CHAR_DATA *ch, CHAR_DATA *victim) );
int     clan_lookup     args( (const char *name) );
void    do_promote      args( (CHAR_DATA *ch, char *argument) );
void    do_demote	args( (CHAR_DATA *ch, char *argument) );
char    *player_rank    args( (CHAR_DATA *ch) );
char    *player_clan    args( (CHAR_DATA *ch) );

-after char *   olc_ed_vnum         args( ( CHAR_DATA *ch ) );
-add the following including the olc_save.c:
CLAN_DATA *get_clan_data     args( ( char *name ) );

/* olc_save.c */
void    save_clans      args( ( CHAR_DATA *ch, char *argument ) );
char    *fwrite_flag    args( ( long flags, char buf[] ) );


---------------olc.c

-in run_olc_editor add:
        case ED_CLAN:
            cedit (d->character, d->incomm);
            break;

-in olc_ed_name add:
        case ED_CLAN:
            sprintf (buf, "CEdit");
            break;

-in olc_ed_vnum add at top:
 CLAN_DATA *pClan;

-then add after ED_HELP:
        case ED_CLAN:
            pClan = (CLAN_DATA *) ch->desc->pEdit;
            sprintf (buf, "%s", pClan ? pClan->name : "");
            break;

-in bool show_commands add:
        case ED_CLAN:
            show_olc_cmds (ch, cedit_table);
            break;

-after olc_cmd_type medit_table add:
/* Clan edit command table */
const struct olc_cmd_type cedit_table[] =
{
    {   "commands",     show_commands   },
    {   "create",       cedit_create    },
    {   "delete",       cedit_delete    },
    {   "flag",         cedit_flags     },
    {   "list",         cedit_list      },
    {   "name",         cedit_name      },
    {   "who",          cedit_who_name  },
    {   "leader",       cedit_leader    },
    {   "rank",         cedit_rank      },
    {   "show",         cedit_show      },
    {   "?",            show_help       },
    {   NULL,           0               }
};

-after get_area_data (int vnum) add:
/*****************************************************************************
 Name:        get_clan_data
 Purpose:    Returns pointer to clan with given name.
 Called by:    do_cedit(olc.c).
****************************************************************************/
CLAN_DATA *get_clan_data( char *name )
{
    int clan;

    for (clan = 0; clan < (1 + top_clan); clan++)
    {
        if ( clan_table[clan].name != NULL
                && clan_table[clan].name[0] != '\0'
                && !str_prefix (name, clan_table[clan].name) )
        return &clan_table[clan];
    }
    return &clan_table[0]; /* null clan */
}

-after void medit (CHAR_DATA * ch, char *argument) add:
/* Clan interpreter, called by cedit */
void cedit( CHAR_DATA *ch, char *argument )
{
    CLAN_DATA *pClan;
    char command[MIL];
    char arg[MIL];
    int cmd;

    smash_tilde( argument );
    strcpy( arg, argument );
    argument = one_argument( argument, command );
    EDIT_CLAN(ch, pClan);

    if ( ch->level < ROLEPLAY )
    {
        sendch("Insufficient security to modify clans.\n\r", ch);
        edit_done( ch );
        return;
    }

    if ( !str_cmp(command, "done") )
    {
        edit_done( ch );
        return;
    }

    if ( command[0] == '\0' )
    {
        cedit_show( ch, argument );
        return;
    }

    if ( command[0] == '\0' )
    {
        cedit_show( ch, argument );
        return;
    }

    /* Search Table and Dispatch Command. */
    for ( cmd = 0; cedit_table[cmd].name != NULL; cmd++ )
    {
        if ( !str_prefix( command, cedit_table[cmd].name ) )
        {
            if ( (*cedit_table[cmd].olc_fun) ( ch, argument ) )
            {
                SET_BIT( pClan->flags, CLAN_CHANGED );
                return;
            }
           else
                return;
        }
    }

    /* Default to Standard Interpreter. */
    interpret( ch, arg );
    return;
}

-in editor_cmd_type editor_table
-add:
    {"clan", do_cedit},

-after void do_medit (CHAR_DATA * ch, char *argument) add:
/* Entry point for editing clans */
void do_cedit( CHAR_DATA *ch, char *argument )
{
    CLAN_DATA *pClan;
    char arg[MAX_STRING_LENGTH];

    if (IS_NPC(ch) )
    {
        sendch ("Npc's cant use editors, nice try.\n\r", ch);
        return;
    }

    argument = one_argument(argument, arg);

    if (ch->level < ROLEPLAY )
    {
        sendch("Insufficient level to edit clans.\n\r",ch);
        return;
    }

    if ( !str_cmp( arg, "create" ) )
    {
        if (argument[0] == '\0')
        {
            sendch("Syntax: cedit create <name>\n\r", ch);
            return;
        }

        if ( ch->level < ROLEPLAY )
        {
            sendch( "CEdit : Insufficient level to create new clans.\n\r", ch );
            return;
        }

	if ((clan_lookup(argument)) != 0)
	{
	    sendch ("That clan already exists.\n\r", ch);
	    return;
	}

        cedit_create( ch, argument );
        ch->desc->editor = ED_CLAN;

        pClan = get_clan_data (argument);
        SET_BIT (pClan->flags, CLAN_CHANGED);

        return;
    }

    else if (arg[0] != '\0')
    {
        pClan = get_clan_data( arg );
        if ((pClan->name == NULL) || pClan->name[0] == '\0')
        {
            sendch( "That clan does not exist.\n\r", ch );
            return;
        }

        else {
                ch->desc->pEdit = pClan;
                ch->desc->editor = ED_CLAN;
        }

    }
    else
        sendch ("CEdit: There is no default clan to edit.\n\r", ch);
        return;
}

---------------olc.h

-add after #define ED_HELP and the corresponding number:
#define ED_CLAN         9 <--- Ours is 9

-in Interpreter Prototypes
-add:
void    cedit           args( ( CHAR_DATA *ch, char *argument ) );

-add in Interpreter Table Prototypes:
extern const struct olc_cmd_type        cedit_table[];

-add with other declares:
DECLARE_DO_FUN( do_cedit        );

-add after /* Help edit */ Declares:
/* Clan editor */
DECLARE_OLC_FUN( cedit_flags            );
DECLARE_OLC_FUN( cedit_rank             );
DECLARE_OLC_FUN( cedit_show             );
DECLARE_OLC_FUN( cedit_name             );
DECLARE_OLC_FUN( cedit_who_name         );
DECLARE_OLC_FUN( cedit_create           );
DECLARE_OLC_FUN( cedit_delete           );
DECLARE_OLC_FUN( cedit_list             );
DECLARE_OLC_FUN( cedit_leader           );


---------------olc_act.c

-add:
#define CEDIT( fun )        bool fun( CHAR_DATA *ch, char *argument )

-in olc_help_type help_table 
-add:
    {"clan",    clan_flags, "Clan flags."},

-at the end of the file add:
// Clan editor functions
CEDIT( cedit_flags )
{
    CLAN_DATA *pClan;
    long value = 0;

    if ( argument[0] != '\0' )
    {
        EDIT_CLAN( ch, pClan );

        if ( ( value = flag_value( clan_flags, argument ) ) != NO_FLAG )
        {
                pClan->flags ^= value;
                sendch( "Clan flag(s) toggled.\n\r", ch);
                return TRUE;
        }
    }

    sendch( "Syntax: flag [flag ID]\n\r"
            "Type '? clan' for a list of valid flags.\n\r", ch );
    return FALSE;
}

CEDIT( cedit_rank )
{
    CLAN_DATA *pClan;
    char arg1[4];

    EDIT_CLAN(ch, pClan);

    argument = one_argument(argument, arg1);

    if (is_number(arg1) && atoi(arg1) <= MAX_RANK)
    {
        int value;

        value = atoi(arg1);

        if (argument[0] != '\0')
        {
                free_string(pClan->c_rank[value].rankname);
                pClan->c_rank[value].rankname = str_dup( argument );
                sendch("Rank title changed.\n\r", ch);
                return TRUE;
        }

    }

    sendch("Syntax: rank <rank#> <title>\n\r", ch);
    return FALSE;
}

CEDIT( cedit_create )
{
    int i;

    if (IS_NULLSTR (argument) )
    {
        sendch ("Syntax: create <name>\n\r", ch);
        return FALSE;
    }

    if ((clan_lookup(argument)) != 0)
    {
	sendch ("That clan already exists.\n\r", ch);
	return FALSE;
    }

    // just loop through and find an open spot
    for (i = 1; i < (1 + top_clan); i++)
    {
        if (clan_lookup(clan_table[i].name) == 0)
        break;
    }

    if (i <= MAX_CLAN) /* open slot */
    {
        CLAN_DATA *pClan;
        int x;

        clan_table[i].name = str_dup(capitalize(argument));
        clan_table[i].who_name = str_dup("Empty");
        clan_table[i].leader = str_dup("Empty");

        for (x = 1; x < MAX_RANK; x++)
        {
            clan_table[i].c_rank[x].rankname = str_dup("Empty");
        }

        pClan = &clan_table[i]; /* return new clan data */
        ch->desc->pEdit = pClan;
        top_clan++;

        sendch("Clan created.\n\r", ch);
        return TRUE;
    }
    sendch("No room to create a new clan. Increase MAX_CLAN!\n\r", ch);
    return FALSE;
}

CEDIT( cedit_delete )
{
    CLAN_DATA *pClan;
    DESCRIPTOR_DATA *d;
    CHAR_DATA *pch;
    int i, j, x, location;
    bool found = FALSE;

    EDIT_CLAN (ch, pClan);

    for (d = descriptor_list; d; d = d->next)
    {
        if (d->editor == ED_CLAN && pClan == d->pEdit)
                edit_done (d->character);
    }

    // Set clan location
    for (i = 0; i < (1 + top_clan); i++)
    {
        if (clan_table[i].name == pClan->name)
        {
                found = TRUE;
                location = i;
                break;
        }
    }

    if (!found)
    {
        sendch ("Clan has already been deleted.\n\r", ch);
        return FALSE;
    }

    // Incase the clan we delete is still being used by players
    for (pch = char_list; pch != NULL; pch = pch->next)
    {
        if (clan_table[pch->clan].name == pClan->name)
        {
            pch->clan = 0;
        }
    }

    // Shift the clans up
    for (i = location; i < (1 + top_clan); ++i)
    {
        x = i + 1;
        clan_table[i] = clan_table[x];
        clan_table[i].name = clan_table[x].name;
        clan_table[i].who_name = clan_table[x].who_name;
        clan_table[i].leader = clan_table[x].leader;

        for (j = 0; j < MAX_RANK; j++)
            clan_table[i].c_rank[j].rankname = clan_table[x].c_rank[j].rankname;

        clan_table[i].flags = clan_table[x].flags;
    }

    clan_table[top_clan] = clan_table[0]; // Set last clan to null
    top_clan--; // Change null from being accessed

    save_clans(ch, argument); //Updating file
    sendch ("Clan deleted.\n\r", ch);
    return TRUE;
}

CEDIT( cedit_list )
{
    char buf[MAX_INPUT_LENGTH], buf1[MIL];
    int i, col = 0;

    buf1[0] = '\0';
    sendch("================== Active Clans ==================\n\r", ch);

    for (i = 1; i < (1 + top_clan); i++)
    {
        if (clan_table[i].name != NULL
                && clan_table[i].name[0] != '\0')
        {
                sprintf (buf, "{c%-27.27s %s{x",
                        clan_table[i].name,
                        clan_table[i].leader);
                strcat (buf1, buf);

                if (++col % 1 == 0)
                        strcat (buf1, "\n\r");
        }
    }
    if (col % 1 != 0)
        strcat (buf1, "\n\r");
    sendch(buf1, ch);
    return FALSE;
}

CEDIT( cedit_show )
{
    CLAN_DATA *pClan;
    char buf[MAX_STRING_LENGTH];
    char buf1[2 * MAX_STRING_LENGTH];
    int i;

    EDIT_CLAN(ch, pClan);

    buf1[0] = '\0';

    sprintf(buf, "Name:        [%s]\n\r", pClan->name);
    strcat (buf1, buf);

    if (!str_cmp(pClan->who_name, "Empty") )
    {
        sprintf (buf, "Who Name:    [%s]\n\r", pClan->who_name);
        strcat (buf1, buf);
    } else {
        sprintf (buf, "Who Name:    %s\n\r", pClan->who_name);
        strcat (buf1, buf);
    }

    sprintf(buf, "Leader:      [%s]\n\r", pClan->leader);
    strcat (buf1, buf);

    for (i = 1; i < MAX_RANK; i++)
    {
        sprintf(buf, "Rank[%2d]:    [%s]\n\r",
        i, (pClan->c_rank[i].rankname  != '\0') ? pClan->c_rank[i].rankname : "None");
        strcat(buf1, buf);
    }

    sprintf(buf, "Flag:        [%s]\n\r", flag_string( clan_flags, pClan->flags ) );
    strcat (buf1, buf);

    sendch (buf1, ch);
    return FALSE;
}

CEDIT( cedit_name )
{
    CLAN_DATA *pClan;

    EDIT_CLAN(ch, pClan);

    if (argument[0] == '\0')
    {
        sendch("Syntax: name <name of clan>\n\r", ch);
        return FALSE;
    }

    if (argument[0] != '\0')
    {
        int i;

        for (i = 1; clan_table[i].name != 0; i++)
        {
            if (clan_table[i].name[0] == argument[0]
                && clan_table[i].name[0] != pClan->name[0])
            {
                sendch("That clan already exists.\n\r", ch);
                return FALSE;
            }
        }

    }

    if (pClan->name[0] != '\0')
        free_string(pClan->name);

        pClan->name = str_dup(argument);

    sendch("Name set.\n\r", ch);
    return TRUE;
}

CEDIT( cedit_who_name )
{
    CLAN_DATA *pClan;
    char buf[MSL];
    int i;

    EDIT_CLAN(ch, pClan);

    if (argument[0] == '\0')
    {
        sendch("Syntax: who <name>\n\r", ch);
        return FALSE;
    }

    if (pClan->who_name[0] != '\0')
        free_string(pClan->who_name);

        i = strlen(argument);
        if (argument[i-2] != '{' && argument[i-1] == '{')
                argument[i-1] = '\0';

        if (argument[i-2] != '{' || argument[i-1] != 'x')
                strcat (argument, "{x");

        sprintf (buf, "[%s] ", argument);
        pClan->who_name = str_dup(buf);

    sendch("Who name set.\n\r", ch);
    return TRUE;
}

CEDIT( cedit_leader )
{
    CLAN_DATA *pClan;

    EDIT_CLAN(ch, pClan);

    if (argument[0] == '\0')
    {
        sendch("Syntax: leader <name>\n\r", ch);
        return FALSE;
    }

    if (pClan->leader[0] != '\0')
        free_string(pClan->leader);

        pClan->leader = str_dup(argument);

    sendch("Leader's name set.\n\r", ch);
    return TRUE;
}


---------------olc_save.c

-add after save_other_helps:
void save_clans(CHAR_DATA *ch, char *argument)
{
    FILE *fp;
    int i;
    int value;
    char buf[MSL];

    sprintf (buf, "%sguild.dat", DATA_DIR);
    if ( !( fp = fopen(buf, "w" ) ) )
    {
        logstr(LOG_BUG, "Open_guild: fopen", 0 );
         return;
    }

    for (i = 1; clan_lookup(clan_table[i].name) != 0; i++)
    {
        if ( !IS_SET(clan_table[i].flags, CLAN_DELETED)
                && clan_lookup(clan_table[i].name) != 0)
        {
            fprintf(fp, "\nClan\t%s~\n", clan_table[i].name);

            fprintf(fp, "Who\t%s~\n", clan_table[i].who_name);

            fprintf(fp, "Leader\t%s~\n", clan_table[i].leader);

            for (value = 1; value < MAX_RANK; value++)
            {
                if (clan_table[i].c_rank[value].rankname == NULL
                    || clan_table[i].c_rank[value].rankname[0] == '\0')
                clan_table[i].c_rank[value].rankname = str_dup("Unassigned");

                fprintf(fp, "Rank\t%d\t%s~\n",
                       value, clan_table[i].c_rank[value].rankname);
            }

            /* Remove "changed" bit before writing flags to file */
            if (IS_SET(clan_table[i].flags, CLAN_CHANGED))
                REMOVE_BIT(clan_table[i].flags, CLAN_CHANGED);

        fprintf( fp, "Flags %s\n",  fwrite_flag( clan_table[i].flags, buf ) );
        fprintf(fp, "\n");
        }
    }

    fprintf(fp, "\nEnd\n");
    fclose(fp);
    return;
}

-in do_asave in str_cmp ("world", arg1)
-add after save_other_helps:
        save_clans (ch, argument);

-in str_cmp ("changed", arg1)
-after:
        save_other_helps (ch);

        if (!str_cmp (buf, "None.\n\r"))
        {
            if (ch)
                sendch (buf, ch);
            else
                logstr (LOG_GAME, "None.");
        }
-add before return;:
        char buf1[MIL];
        int i;

        for (i = 1; clan_lookup(clan_table[i].name) != 0; i++)
        {
            if (clan_lookup (clan_table[i].name) != 0
                && IS_SET(clan_table[i].flags, CLAN_CHANGED)
                && !IS_SET(clan_table[i].flags, CLAN_DELETED) )
            {
                save_clans(ch, argument);
                sprintf (buf1, "\n\rClan '%s' saved.", clan_table[i].name);
                if (ch)
                {
                    sendch (buf1, ch);
                    sendch ("\n\r", ch);
                }
                else
                    logstr (LOG_GAME, buf1);
            }
        } Note: make sure return is after this last bracket here


---------------save.c

-in void fwrite_char
-if you already have  "Clan %s~\n", clan_table[ch->clan]
 change it to this, otherwise:
    if (ch->clan)
    {
        fprintf (fp, "Clan %s~\n", clan_table[ch->clan].name);
        fprintf (fp, "CRank %d\n", ch->c_rank);
    }

-in void fread_char under case 'C':
-if you have a clan reference there, change it all to this:
                if ( !str_cmp( word, "Clan" ) ) {
                    char *tmp = fread_string(fp);
                    ch->clan = clan_lookup(tmp);
                    free_string(tmp);
                    fMatch = TRUE;
                    break;
                }
                if ( !str_cmp( word, "CRank" ) ) {
                    char *tmp = fread_string_eol(fp);
                    ch->c_rank = atoi(tmp);
                    free_string(tmp);
                    fMatch = TRUE;
                    break;
                }
                // clan below was replaced with above because mem leak
                // KEY ("Clan", ch->clan, clan_lookup (fread_string (fp)));


---------------tables.c

-Note: If you use these, make note of what clans you want to keep,
 titles and who name look to add in later

-delete all of these structures:
const struct clan_type clan_table[MAX_CLAN] = 
const struct clan_titles ctitle_table[MAX_CLAN] =

-add at bottom:
const struct flag_type clan_flags[] = {
   {    "Independent",          CLAN_INDEPENDENT,       TRUE    },
   {    "Delete",               CLAN_DELETED,           TRUE    },
   {    "Immortal",             CLAN_IMMORTAL,          TRUE    },
   {    "Modified",             CLAN_CHANGED,           FALSE   },
   {    NULL,                   0,                      FALSE   }
};


---------------tables.h

-Delete these structures:
struct clan_titles
{
    char *clan_title[7];
};

struct clan_type
{
    char                *name;
    char                *who_name;
    sh_int              hall;
    bool                independent; /* true for loners */
};

-Find and delete:
struct  clan_type       clan_table[MAX_CLAN];
struct  clan_titles     ctitle_table[MAX_CLAN];

-add at the bottom:
extern  const   struct  flag_type       clan_flags[];

---------End of installation file