One issue with it is that if I am creating a clan and decide to use Q to quit, it still saves the clan in the clist
if I go back and try to use P to purge the account it does some real wonky stuff that requires a boot in order to remove the stuff from clist or it crashes
Code:
/* external functions */
extern struct char_data *find_clan_char(struct char_data *ch, char *arg);
/******************************************************************************/
/** Internal Functions **/
/******************************************************************************/
void cedit_clan_menu(struct descriptor_data *d);
void cedit_setup_new(struct descriptor_data *d);
void cedit_save_to_disk( void );
void save_config( IDXTYPE nowhere );
ACMD(do_oasis_cledit)
{
int number = 0, save = 0, real_num;
struct descriptor_data *d;
struct clan_type *cptr = NULL;
char buf1[MAX_STRING_LENGTH];
/****************************************************************************/
/** Parse any arguments. **/
/****************************************************************************/
one_argument(argument, buf1);
if (!*buf1) {
send_to_char(ch, "Specify a clan VNUM to edit.\r\n");
return;
} else if (!isdigit(*buf1)) {
if (str_cmp("save", buf1) == 0) {
save = TRUE;
number = 0;
}else{
send_to_char(ch, "Yikes! Stop that, someone will get hurt!\r\n");
return;
}
}
/****************************************************************************/
/** If a numeric argument was given (like a room number), get it. **/
/****************************************************************************/
if (number == 0)
number = atoi(buf1);
/****************************************************************************/
/** Check that whatever it is isn't already being edited. **/
/****************************************************************************/
for (d = descriptor_list; d; d = d->next) {
if (STATE(d) == CON_CLEDIT) {
if (d->olc && OLC_CLAN(d) == number) {
send_to_char(ch, "That clan is currently being edited by %s.\r\n",
GET_NAME(d->character));
return;
}
}
}
d = ch->desc;
/****************************************************************************/
/** Give descriptor an OLC structure. **/
/****************************************************************************/
if (d->olc) {
mudlog(BRF, LVL_IMMORT, TRUE,
"SYSERR: do_oasis_cledit: Player already had olc structure.");
free(d->olc);
}
CREATE(d->olc, struct oasis_olc_data, 1);
/****************************************************************************/
/** If save is TRUE, save the mobiles. **/
/****************************************************************************/
if (save) {
send_to_char(ch, "Saving all clans\r\n");
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE,
"OLC: %s saves clans.",
GET_NAME(ch));
/**************************************************************************/
/** Save the clans. **/
/**************************************************************************/
save_clans();
/**************************************************************************/
/** Free the olc structure stored in the descriptor. **/
/**************************************************************************/
free(d->olc);
d->olc = NULL;
return;
}
OLC_CLAN(d) = number;
/****************************************************************************/
/** If this is a new mobile, setup a new one, otherwise, setup the **/
/** existing mobile. **/
/****************************************************************************/
if (number == 0) {
cedit_setup_new(d);
}
else {
for (cptr = clan_info; cptr && cptr->number != number; cptr=cptr->next);
if (cptr && (cptr->number == number)) {
OLC_CLAN(d) = cptr;
cedit_clan_menu(d);
} else {
send_to_char(d->character, "Invalid clan number!\r\n");
return;
}
}
STATE(d) = CON_CLEDIT;
/****************************************************************************/
/** Display the OLC messages to the players in the same room as the **/
/** builder and also log it. **/
/****************************************************************************/
act("$n starts using OLC.", TRUE, d->character, 0, 0, TO_ROOM);
SET_BIT_AR(PLR_FLAGS(ch), PLR_WRITING);
mudlog(BRF, MAX(LVL_IMPL, GET_INVIS_LEV(d->character)), TRUE,"OLC: %s starts editing clans",
GET_NAME(ch));
}
void cedit_clan_menu(struct descriptor_data * d)
{
char buf[MAX_STRING_LENGTH];
if (!OLC_CLAN(d))
cedit_setup_new(d);
get_char_colors(d->character);
write_to_output(d,
"-- Clan number : [%s%d%s]\r\n"
"%s1%s) Name : %s%s\r\n"
"%s2%s) Leader : %s%s\r\n"
"%s4%s) Clan Abbrev : %s%s\r\n"
"%sP%s) Purge this Clan\r\n"
"%sQ%s) Quit\r\n"
"Enter choice : ",
cyn, OLC_CLAN(d)->number, nrm,
grn, nrm, yel, OLC_CLAN(d)->name,
grn, nrm, yel, OLC_CLAN(d)->leadersname,
grn, nrm, yel, OLC_CLAN(d)->member_look_str ?
OLC_CLAN(d)->member_look_str : OLC_CLAN(d)->name,
grn, nrm,
grn, nrm
);
OLC_MODE(d) = CEDIT_CLAN_MENU;
}
void cedit_free_clan(struct clan_type *cptr)
{
dequeue_clan(cptr->number);
}
void cledit_parse(struct descriptor_data *d, char *arg)
{
char buf[MAX_STRING_LENGTH];
switch (OLC_MODE(d)) {
case CEDIT_CONFIRM_SAVE:
switch (*arg) {
case 'y':
case 'Y':
save_clans();
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE,
"OLC: %s modifies the game configuration.", GET_NAME(d->character));
cleanup_olc(d, CLEANUP_CONFIG);
if (CONFIG_AUTO_SAVE) {
save_clans();
write_to_output(d, "Game configuration saved to disk.\r\n");
} else
write_to_output(d, "Game configuration saved to memory.\r\n");
return;
case 'n':
case 'N':
/* free everything up, including strings etc */
cleanup_olc(d, CLEANUP_STRUCTS);
break;
default:
write_to_output(d, "Invalid choice!\r\nDo you wish to save your changes? : ");
break;
}
return;
case CEDIT_CLAN_MENU:
switch (*arg) {
case '1':
write_to_output(d, "Enter clan name:-\r\n| ");
OLC_MODE(d) = CEDIT_NAME;
break;
case '2':
write_to_output(d, "Enter clan leader's name: ");
OLC_MODE(d) = CEDIT_LEADERSNAME;
break;
case '4':
write_to_output(d, "Enter clan member who string:-\r\n| ");
OLC_MODE(d) = CEDIT_MBR_LOOK_STR;
break;
case 'p':
case 'P':
if (GET_LEVEL(d->character) >= LVL_IMPL) {
newclan = OLC_CLAN(d)->number; /* next new clan will get this one's number */
/* free everything up, including strings etc */
cleanup_olc(d, CLEANUP_ALL);
cnum--;
write_to_output(d, "Clan purged.\r\n");
} else {
write_to_output(d, "Sorry you are not allowed to do that at this time.\r\n");
cedit_clan_menu(d);
}
return;
case 'q':
case 'Q':
if (OLC_VAL(d)) {
write_to_output(d, "Do you wish to save the configuration? (y/n) : ");
OLC_MODE(d) = CEDIT_CONFIRM_SAVE;
} else
cleanup_olc(d, CLEANUP_STRUCTS);
return;
default:
write_to_output(d, "Invalid choice!");
cedit_clan_menu(d);
break;
}
return;
case CEDIT_NAME:
if (OLC_CLAN(d)->name)
free(OLC_CLAN(d)->name);
OLC_CLAN(d)->name = str_udup(arg);
break;
case CEDIT_LEADERSNAME:
if (OLC_CLAN(d)->leadersname)
free(OLC_CLAN(d)->leadersname);
OLC_CLAN(d)->leadersname = str_udup(arg);
break;
case CEDIT_MBR_LOOK_STR:
if (OLC_CLAN(d)->member_look_str)
free(OLC_CLAN(d)->member_look_str);
OLC_CLAN(d)->member_look_str = str_udup(arg);
break;
default:
/* we should never get here */
mudlog("SYSERR: Reached default case in cledit_parse",BRF,LVL_GOD,TRUE);
break;
}
/* If we get this far, something has been changed */
OLC_VAL(d) = 1;
cedit_clan_menu(d);
}
/*
* Create a new clan with some default strings.
*/
void cedit_setup_new(struct descriptor_data *d)
{
int i;
if ((OLC_CLAN(d) = enqueue_clan()) != NULL) {
OLC_CLAN(d)->name = str_udup("Unfinished Clan");
OLC_CLAN(d)->number = newclan;
OLC_CLAN(d)->leadersname = str_udup("NoOne");
OLC_CLAN(d)->member_look_str = NULL;
OLC_CLAN(d)->clan_entr_room = 1;
OLC_CLAN(d)->clan_password = str_udup("none");
OLC_CLAN(d)->gold = 0;
for (i = 0; i < 20; i++)
OLC_CLAN(d)->applicants[i] = NULL;
} else
fprintf(stderr, "SYSERR: Unable to create new clan!\r\n");
cnum++;
if (newclan == cnum)
newclan++;
else
newclan = cnum;
cedit_clan_menu(d);
OLC_VAL(d) = 0;
} [attachment=232]clan.PNG[/attachment] [attachment=233]clan2.PNG[/attachment]