Beispiel #1
0
/* Recover from a hotreboot - load players */
void hotreboot_recover()
{
	DESCRIPTOR_DATA *d;
	FILE *fp;
	char name[100];
	char host[MSL];
	long desc;
	bool fOld;

	fp = fopen(HOTREBOOT_FILE, "r");

	if(!fp)			/* there are some descriptors open which will hang forever then ? */
	{
		perror("hotreboot_recover:fopen");
		exit(1);
	}

/*	unlink (HOTREBOOT_FILE);  In case something crashes - doesn't prevent reading	*/

	for(;;)
	{
		fscanf(fp, "%li %s %s\n", &desc, name, host);
		if(desc == -1)
			break;

		/* Write something, and check if it goes error-free */
		if(!write_to_descriptor(desc, "\n\rRestoring from hotreboot...\n\r", 0))
		{
#ifdef WIN32
			closesocket(desc);

#else /*  */
			close(desc);	/* nope */
#endif /*  */
			continue;
		}

		d = alloc_perm(sizeof(DESCRIPTOR_DATA));
		init_descriptor(d, desc);	/* set up various stuff */

		d->host = str_dup(host);
		d->next = descriptor_list;
		descriptor_list = d;
		d->connected = CON_HOTREBOOT_RECOVER;	/* -15, so close_socket frees the char */


		/* Now, find the pfile */

		fOld = load_char_obj(d, name);

		if(!fOld)	/* Player file not found?! */
		{
			write_to_descriptor(desc, "\n\rSomehow, your character was lost in the hotreboot. Reconnect\n\r",
					    0);
			close_socket2(d, FALSE);
		}
		else		/* ok! */
		{
			/* Just In Case */
			if(!d->character->in_room)
				d->character->in_room = get_room_index(ROOM_VNUM_TEMPLE);

			/* Insert in the char_list */
			d->character->next = char_list;
			char_list = d->character;

			char_to_room(d->character, d->character->in_room);
			do_look(d->character, "");
			act("$n appears from the netherworld!", d->character, 0, 0, TO_ROOM);
			d->connected = CON_PLAYING;
		}

	}

	fclose(fp);
	olduptime = get_olduptime();

}
Beispiel #2
0
/* Recover from a hotboot - load players */
void hotboot_recover( void )
{
   DESCRIPTOR_DATA *d = NULL;
   FILE *fp;
   char name[100];
   char host[MAX_STRING_LENGTH];
   int desc, room, dport, idle, dcompress, maxp = 0;
   bool fOld;

   fp = fopen( HOTBOOT_FILE, "r" );

   if( !fp )   /* there are some descriptors open which will hang forever then ? */
   {
      perror( "hotboot_recover: fopen" );
      bug( "%s", "Hotboot file not found. Exitting." );
      exit( 1 );
   }

   unlink( HOTBOOT_FILE ); /* In case something crashes - doesn't prevent reading */
   for( ;; )
   {
      d = NULL;

      fscanf( fp, "%d %d %d %d %d %s %s\n", &dcompress, &desc, &room, &dport, &idle, name, host );

      if( desc == -1 || feof( fp ) )
         break;

      if( !str_cmp( name, "maxp" ) || !str_cmp( host, "maxp" ) )
      {
         maxp = idle;
         continue;
      }

      /*
       * Write something, and check if it goes error-free 
       */
      if( !write_to_descriptor_old( desc, "\r\nThe Force swirls around you.\r\n", 0 ) )
      {
         close( desc ); /* nope */
         continue;
      }

      CREATE( d, DESCRIPTOR_DATA, 1 );
      CREATE( d->mccp, MCCP, 1 );
      d->next = NULL;
      d->descriptor = desc;
      d->connected = CON_GET_NAME;
      d->outsize = 2000;
      d->idle = 0;
      d->lines = 0;
      d->scrlen = 24;
      d->newstate = 0;
      d->prevcolor = 0x08;
      d->ifd = -1;
      d->ipid = -1;

      CREATE( d->outbuf, char, d->outsize );

      d->host = STRALLOC( host );
      d->port = dport;
      d->idle = idle;
#ifdef MCCP
      if( dcompress )
         write_to_buffer( d, compress2_on_str_2, 0 );
#endif
      LINK( d, first_descriptor, last_descriptor, next, prev );
      d->connected = CON_COPYOVER_RECOVER;   /* negative so close_socket will cut them off */
//      d->can_compress = dcompress;
//      if( d->can_compress )
//         compressStart( d );

      /*
       * Now, find the pfile 
       */
      fOld = load_char_obj( d, name, FALSE, TRUE );

      if( !fOld ) /* Player file not found?! */
      {
         write_to_descriptor( d, "\r\nSomehow, your character was lost during hotboot. Contact the immortals ASAP.\r\n", 0 );
         close_socket( d, FALSE );
      }
      else  /* ok! */
      {
         write_to_descriptor( d, "Suddenly, you remember nothing as the Force continues into the Galaxy.\r\n", 0 );
         d->character->in_room = get_room_index( room );
         if( !d->character->in_room )
            d->character->in_room = get_room_index( ROOM_VNUM_TEMPLE );

         /*
          * Insert in the char_list 
          */
         LINK( d->character, first_char, last_char, next, prev );

         char_to_room( d->character, d->character->in_room );
         act( AT_MAGIC, "You appear in a swirl of the Force!", d->character, NULL, NULL, TO_CHAR );
         act( AT_MAGIC, "$n appears in a swrrl of the Force!", d->character, NULL, NULL, TO_ROOM );
         d->connected = CON_PLAYING;
         if( ++num_descriptors > sysdata.maxplayers )
            sysdata.maxplayers = num_descriptors;
#ifdef AUTO_AUTH
         check_auth_state( d->character );   /* new auth */
#endif
      }
   }
   FCLOSE( fp );
   if( maxp > sysdata.maxplayers )
      sysdata.maxplayers = maxp;
   log_string( "Hotboot recovery complete." );
   return;
}
Beispiel #3
0
/*
 * Bring up the pfile for rare item adjustments
 */
void adjust_pfile( const string & name )
{
   char_data *ch;
   char fname[256];
   struct stat fst;

   list < char_data * >::iterator ich;
   for( ich = pclist.begin(  ); ich != pclist.end(  ); ++ich )
   {
      char_data *temp = *ich;

      if( !str_cmp( name, temp->name ) )
      {
         log_printf( "Skipping rare item adjustments for %s, player is online.", temp->name );
         if( temp->is_immortal(  ) )   /* Get the rare items off the immortals */
         {
            list < obj_data * >::iterator iobj;

            log_printf( "Immortal: Removing rare items from %s.", temp->name );
            for( iobj = temp->carrying.begin(  ); iobj != temp->carrying.end(  ); )
            {
               obj_data *tobj = *iobj;
               ++iobj;

               rare_purge( temp, tobj );
            }
         }
         return;
      }
   }

   room_index *temproom, *original;
   if( !( temproom = get_room_index( ROOM_VNUM_RAREUPDATE ) ) )
   {
      bug( "%s: Error in rare item adjustment, temporary loading room is missing!", __FUNCTION__ );
      return;
   }

   snprintf( fname, 256, "%s%c/%s", PLAYER_DIR, tolower( name[0] ), capitalize( name ).c_str(  ) );

   if( stat( fname, &fst ) != -1 )
   {
      descriptor_data *d = new descriptor_data;
      d->init(  );
      d->connected = CON_PLOADED;

      load_char_obj( d, name, false, false );
      charlist.push_back( d->character );
      pclist.push_back( d->character );
      original = d->character->in_room;
      if( !d->character->to_room( temproom ) )
         log_printf( "char_to_room: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ );
      ch = d->character;   /* Hopefully this will work, if not, we're SOL */
      d->character->desc = NULL;
      d->character = NULL;
      deleteptr( d );

      log_printf( "Updating rare items for %s", ch->name );

      ++ch->pcdata->daysidle;
      expire_items( ch );

      ch->from_room(  );
      if( !ch->to_room( original ) )
         log_printf( "char_to_room: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ );

      quitting_char = ch;
      ch->save(  );

      if( sysdata->save_pets )
      {
         list < char_data * >::iterator pet;

         for( pet = ch->pets.begin(  ); pet != ch->pets.end(  ); )
         {
            char_data *cpet = *pet;
            ++pet;

            cpet->extract( true );
         }
      }

      /*
       * Synch clandata up only when clan member quits now. --Shaddai 
       */
      if( ch->pcdata->clan )
         save_clan( ch->pcdata->clan );

      saving_char = NULL;

      /*
       * After extract_char the ch is no longer valid!
       */
      ch->extract( true );
      for( int x = 0; x < MAX_WEAR; ++x )
         for( int y = 0; y < MAX_LAYERS; ++y )
            save_equipment[x][y] = NULL;

      log_printf( "Rare items for %s updated sucessfully.", name.c_str(  ) );
   }
}