/*************************************************************************** * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. * * * Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * * * In order to use any part of this Merc Diku Mud, you must comply with * * both the original Diku license in 'license.doc' as well the Merc * * license in 'license.txt'. In particular, you may not remove either of * * these copyright notices. * * * * Much time and thought has gone into this software and you are * * benefitting. We hope that you share your changes too. What goes * * around, comes around. * ***************************************************************************/ #include <glib.h> #if defined(macintosh) #include <types.h> #else #include <sys/types.h> #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <merc.h> #include <tables.h> #include <recycle.h> #include <interp.h> #include <olc.h> #include <player.h> extern void fread_char args(( CHAR_DATA *ch, FILE *fp )); extern void fread_pet args( ( CHAR_DATA *ch, FILE *fp ) ); extern void fread_obj args( ( CHAR_DATA *ch, FILE *fp ) ); extern CHAR_DATA *reset_player args(( DESCRIPTOR_DATA *d, const char *name )); void do_chomp( CHAR_DATA *ch, char *argument) { char arg[MSL]; CHAR_DATA *victim; char strsave[MAX_STRING_LENGTH]; bool online = FALSE; FILE *fp; GString *charName; DESCRIPTOR_DATA *d; argument = one_argument(argument,arg); charName = g_string_new(capitalize( arg )); if ((victim = get_char_world(ch,charName->str)) != NULL) { send_to_char("Character is currently online.\n\r",ch); send_to_char("Attempting a online restore.\n\r",ch); online = TRUE; } if (fclose( fpReserve ) != 0) { bug("Problems closing reserve!",0); return; } sprintf( strsave, "%sstore/%s", PLAYER_DIR, charName->str ); if ( ( fp = fopen( strsave, "r" ) ) != NULL ) { if (online) { d = victim->desc; extract_char(victim,TRUE); victim = reset_player(d,charName->str); d->connected = CON_PLAYING; } else{ d = new_descriptor(); d->connected = CON_PLAYING; victim = reset_player(d,charName->str); } set_rObjNest_null(); for ( ; ; ) { char letter; char *word; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { bug( "CHOMP: # not found.", 0 ); break; } word = fread_word( fp ); if ( !str_cmp( word, "PLAYERS" ) ) fread_char ( victim, fp ); else if ( !str_cmp( word, "OBJECT" ) ) fread_obj ( victim, fp ); else if ( !str_cmp( word, "PET" ) ) fread_pet ( victim, fp ); else if ( !str_cmp( word, "END" ) ) break; else { fpReserve = fopen( NULL_FILE, "r" ); bug( "CHOMP: bad section.", 0 ); if (fclose( fpReserve ) != 0) break; } } if (fclose( fp ) != 0) bug("Error closing the pfile!",0); } else { send_to_char("Player store file not found.\n\r",ch); fpReserve = fopen( NULL_FILE, "r" ); g_string_free(charName,TRUE); return; } fpReserve = fopen( NULL_FILE, "r" ); if (online) { victim->next = char_list; char_list = victim; send_to_char("You suddenly feel like your old self again.\n\r",victim); d->connected = CON_PLAYING; } save_char_obj(victim); if (!online) { free_descriptor(d); free_char(victim); } else char_to_room(victim,ch->in_room); send_to_char("Restore complete.\n\r",ch); g_string_free(charName,TRUE); return; } void do_return( CHAR_DATA *ch, char *argument ) { char buf[MAX_STRING_LENGTH]; sprintf(buf,"%s: Return %s",ch->name->str,argument); if ( ch->desc == NULL ) return; if ( ch->desc->original == NULL ) { send_to_char( "You aren't switched.\n\r", ch ); return; } REMOVE_BIT(ch->act, ACT_HOLYLIGHT); send_to_char( "You return to your original body.\n\r", ch ); REMOVE_BIT(ch->desc->original->extra, EXTRA_SWITCH); ch->desc->character = ch->desc->original; ch->desc->original = NULL; ch->desc->character->desc = ch->desc; ch->desc = NULL; return; }