Пример #1
0
void check_pfiles( time_t reset )
{
   /*
    * This only counts them up on reboot if the cleanup isn't needed - Samson 1-2-00 
    */
   if( reset == 255 && new_pfile_time_t > current_time )
   {
      reset = 0;  /* Call me paranoid, but it might be meaningful later on */
      log_string( "Counting pfiles....." );
      pfile_scan( TRUE );
      return;
   }

   if( new_pfile_time_t <= current_time )
   {
      if( sysdata.CLEANPFILES == TRUE )
      {

         char buf[MSL];

         /*
          * Makes a backup copy of existing pfiles just in case - Samson 
          */
         sprintf( buf, "tar -cf %spfiles.tar %s*", PLAYER_DIR, PLAYER_DIR );

         /*
          * Would use the shell pipe for this, but alas, it requires a ch in order
          * to work, this also gets called during boot_db before the rare item
          * checks for the rent code - Samson 
          */
         system( buf );

         new_pfile_time_t = current_time + 86400;
         save_timedata(  );
         log_string( "Automated pfile cleanup beginning...." );
         pfile_scan( FALSE );
#ifdef SAMSONRENT
         if( reset == 0 )
            rent_update(  );
#endif
      }
      else
      {
         new_pfile_time_t = current_time + 86400;
         save_timedata(  );
         log_string( "Counting pfiles....." );
         pfile_scan( TRUE );
#ifdef SAMSONRENT
         if( reset == 0 )
            rent_update(  );
#endif
      }
   }
   return;
}
Пример #2
0
/* This function is called from 'main' or 'SigTerm'. Its purpose is to clean up
 * the various loose ends the mud will have running before it shuts down. Put anything
 * which needs to be added to the shutdown proceedures in here.
 */
void close_mud( void )
{
   if( auction->item )
      bid( supermob, NULL, "stop" );

   if( !DONTSAVE )
   {
      list < descriptor_data * >::iterator ds;

      log_string( "Saving players...." );
      for( ds = dlist.begin(  ); ds != dlist.end(  ); ++ds )
      {
         descriptor_data *d = *ds;
         char_data *vch = ( d->character ? d->character : d->original );

         if( !vch )
            continue;

         if( !vch->isnpc(  ) )
         {
            vch->save(  );
            log_printf( "%s saved.", vch->name );
            d->write( "You have been saved to disk.\033[0m\r\n" );
         }
      }
   }

   // Save game world time - Samson 1-21-99 
   log_string( "Saving game world time...." );
   save_timedata(  );

   // Save ship information - Samson 1-8-01 
   save_ships(  );

   fflush( stderr ); /* make sure stderr is flushed */

   close( control );

#ifdef IMC
   imc_shutdown( false );
#endif

#if defined(WIN32)
   /*
    * Shut down Windows sockets 
    */

   WSACleanup(  );   /* clean up */
   kill_timer(  );   /* stop timer thread */
#endif
}
Пример #3
0
void do_pfiles( CHAR_DATA * ch, char *argument )
{
   char buf[512];

   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs cannot use this command!\r\n", ch );
      return;
   }

   if( argument[0] == '\0' || !argument )
   {
      /*
       * Makes a backup copy of existing pfiles just in case - Samson 
       */
      snprintf( buf, 512, "tar -czf %spfiles.tar %s*", PLAYER_DIR, PLAYER_DIR );

      /*
       * GAH, the shell pipe won't process the command that gets pieced
       * together in the preceeding lines! God only knows why. - Samson 
       */
      system( buf );

      snprintf( buf, 512, "Manual pfile cleanup started by %s.", ch->name );
      log_string( buf );
      pfile_scan( FALSE );
#ifdef SAMSONRENT
      rent_update(  );
#endif
      return;
   }

   if( !str_cmp( argument, "settime" ) )
   {
      new_pfile_time_t = current_time + 86400;
      save_timedata(  );
      send_to_char( "New cleanup time set for 24 hrs from now.\r\n", ch );
      return;
   }

   if( !str_cmp( argument, "count" ) )
   {
      snprintf( buf, 512, "Pfile count started by %s.", ch->name );
      log_string( buf );
      pfile_scan( TRUE );
      return;
   }
   send_to_char( "Invalid argument.\r\n", ch );
   return;
}
Пример #4
0
void do_pfiles( CHAR_DATA * ch, char *argument )
{
   char buf[MSL];
   char arg1[MIL];
   char x[3];


   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs cannot use this command!\n\r", ch );
      return;
   }


   if ( !argument || argument[0] == '\0' )
   {
        send_to_char( "&RSyntax: pfiles <scan/settime/count/letter/force>\n\r", ch);
        return;
   }

   if( !str_cmp( argument, "scan") )
   {
      /*
       * Makes a backup copy of existing pfiles just in case - Samson 
       */
      sprintf( buf, "tar -cf %spfiles.tar %s*", PLAYER_DIR, PLAYER_DIR );

      /*
       * GAH, the shell pipe won't process the command that gets pieced
       * together in the preceeding lines! God only knows why. - Samson 
       */
      system( buf );

      sprintf( log_buf, "Manual pfile cleanup started by %s.", ch->name );
      log_string( log_buf );
      pfile_scan( FALSE );

      return;
   }

   if( !str_cmp( argument, "settime" ) )
   {
      new_pfile_time_t = current_time + 86400;
      save_timedata(  );
      send_to_char( "New cleanup time set for 24 hrs from now.\n\r", ch );
      return;
   }

   if( !str_cmp( argument, "count" ) )
   {
      sprintf( log_buf, "Pfile count started by %s.", ch->name );
      log_string( log_buf );
      pfile_scan( TRUE );
      return;
   }

	argument = one_argument( argument, arg1);

   if ( !str_cmp( arg1, "letter" ) )
   {

	if ( (argument[0] == '\0') || !argument )
	{
		send_to_char("&RSyntax: pfiles letter (letter A-Z)\n\r", ch );
                return;
        }

        if( !is_number( argument ) || ( argument[1] != '\0' ) ) 
        { 
           snprintf( x, 2, argument ); 
           x[0] = tolower(x[0]); 
           show_pfiles( ch, x ); 
        } 
        else
        {
          send_to_char("You can only use a letter in this scan!\n\r",ch);
          return;
        }

        return;
     }   

    if ( !str_cmp( arg1, "forcers" ) )
	{
	   scan_forcers( ch );
	   return;
	}

   send_to_char( "Invalid argument.\n\r", ch );
   return;
}