delete_char.txt
snippets · 1.3 KB · 2010-03-30
delete_char: one function for deleting a player file, to avoid repeating code.
Download « Back to the snippets list
/*I hate repeating code over, and over again, and player file deletion happens in many places
*throughout my mud code. So i decided to write up this little function, it contains all my
*deletion data. Remove what you don't use in your system. and replace all your normal deletion
*code and replace it with this. Its allot of help :)
*Dazzle(Darien) of Sandstorm
* sandstorm.kicks-ass.org port 6969
*/
void delete_character(CHAR_DATA *ch)
{
DESCRIPTOR_DATA *d, *d_next;
int id;
char strsave[MIL];
xprintf( strsave, "%s%s", PLAYER_DIR, capitalize(ch->name ) );
remove_from_auth( ch->name );
stop_fighting(ch,TRUE);
update_members(ch,TRUE);
update_wizlist(ch,TRUE);
delete_home(ch);
if (ch->pcdata->in_progress)
free_note (ch->pcdata->in_progress);
id = ch->id;
d = ch->desc;
extract_char( ch, TRUE ); /* toast evil cheating bastards */
if ( d != NULL )
close_socket( d );
for (d = first_descriptor; d != NULL; d = d_next)
{
CHAR_DATA *tch;
d_next = d->next;
tch = d->original ? d->original : d->character;
if (tch && tch->id == id)
{
extract_char(tch,TRUE);
close_socket(d);
}
}
unlink(strsave);
}