The Quit BUG for EmberMUD Fix Sheet 1.0 by Rindar (Ron Cole) Fix 1.0 by Raven (Laurie Zenner) The Bug: In a number of EmberMUDs, there seems to be a problem that, when people quit, the entire game crashes. Needless to say, this can get extremely annoying when you have a large user base. The Bugfix: Unlike most of my other fix sheets, this one will explain what the problem was and then briefly explain what occured to fix it. At the bottom of this sheet is the do_quit function direct from the MUD of the coder. It may or may not run smoothly when installed into your MUD. The reason I'm not testing and checking the fix like usual is because I had nothing to do with the actual coding of it. I have done this "fix sheet" because it is a problem that a number of EmberMUD's have and I felt some sort of explanation would be useful, even if it was not the up to my normal standards. Perhaps I will talk to Raven in the future about this and get a complete understanding for a 1.1 version of this fix sheet. Or maybe not. At any rate, this is how the bug was explained to me: the game is attempting to check a variable ch towards the end of function. The problem is, the ch variable is already invalid by this time. That check was what was making the game crash most (but not all) of the times there were QUIT related crashes. -= Rindar clogar@concentric.net ** Note: This function is provided "as is" and may be used so long as 1) The author's name is kept at the top of the function (if requested) and 2) all other previous licensing aggreements are abided by. The author assumes no responsibility for problems that occur through use or install- ation, including lost wages, bugs, deletions, downtimes, etc... Use at your own risk. All new code is copyrighted by its author and may be used in all "free" MUDs. New do_quit function (act_comm.c): void do_quit( CHAR_DATA *ch, char *argument ) { DESCRIPTOR_DATA *d; DESCRIPTOR_DATA *d_next; char *name; send_to_char( "\n\r", ch ); if ( IS_NPC(ch) ) return; if ( ch->position == POS_FIGHTING ) { send_to_char( "No way! You are fighting.\n\r", ch ); return; } if ( ch->position < POS_STUNNED ) { send_to_char( "You're not DEAD yet.\n\r", ch ); return; } send_to_char("Alas, all good things must come to an end.\n\r",ch); act( "$n has left the game.", ch, NULL, NULL, TO_ROOM ); sprintf( log_buf, "%s has quit.", ch->name ); wiznet("$N rejoins the real world.",ch,NULL,WIZ_LOGINS,0,get_trust(ch)); log_string( log_buf ); /* * After extract_char the ch is no longer valid! */ save_char_obj( ch ); sprintf( log_buf, "DEBUG (quit): %s's info successfully saved.", ch->name ); log_string( log_buf ); /* Free note that might be there somehow */ if (ch->pcdata->in_progress) free_note (ch->pcdata->in_progress); sprintf( log_buf, "DEBUG (quit): %s's note freed or no note.", ch->name ); log_string( log_buf ); name = strdup(ch->name); d = ch->desc; extract_char( ch, TRUE ); sprintf( log_buf, "DEBUG (quit): %s extracted.", name ); log_string( log_buf ); if ( d != NULL ) close_socket( d ); sprintf( log_buf, "DEBUG (quit): %s's socket closed.", name ); log_string( log_buf ); for (d = descriptor_list; d!=NULL; d = d_next) { CHAR_DATA *tch; d_next=d->next; tch = d->original ? d->original : d->character; sprintf( log_buf, "DEBUG (quit): Comparing %s to %s", tch->name, name ); log_string( log_buf ); /* if ((tch) && (!strcmp(tch->name,name)) && (ch != tch)) */ if ((tch) && (!strcmp(tch->name,name)) ) { sprintf( log_buf, "DEBUG(quit): %s = %s, removing %s", tch->name, name, tch->name ); log_string( log_buf); extract_char(tch,TRUE); /* close_socket(d); */ if ( d != NULL ) close_socket( d ); } } sprintf( log_buf, "DEBUG(quit): %s quit successfully", name ); log_string( log_buf ); return; } ============================================================================= / ______ _______ ____ _____ ___ __ _ ______ ____ ____ _____ / \ | ____|__ __| _ \ / ____\ / _ \| \ / | ____| / __ \| _ \ / ____\ \ / | |__ | | | |_| | | | |_| | |\/| | |___ | | | | |_| | | / / | ___| | | | ___/| | __| _ | | | | ____| | | | | __/| | ___ \ \ | | | | | | | |___| | | | | | | | |____ | |__| | |\ \| |___| | / / |_| |_| |_| o \_____/|_| |_|_| |_|______|o \____/|_| \_|\_____/ \ \ / ============================================================================ ------------------------------------------------------------------------------ ftp://ftp.game.org/pub/mud FTP.GAME.ORG http://www.game.org/ftpsite/ ------------------------------------------------------------------------------ This file came from FTP.GAME.ORG, the ultimate source for MUD resources. ------------------------------------------------------------------------------