Maybe it would be clearer if I posted the function, so here it is.

void do_alts( CHAR_DATA *ch, char *argument )
{
   DIR *player_dir;
   struct dirent *players;
   CHAR_DATA *victim, *lch;
   char buf[MSL];
   char output[MSL] = { '\0' };
   int count = 0;

   if ( ( victim = get_char_online(argument) ) == NULL )
   {
       if ( ( victim = get_char_offline(argument) ) == NULL )
       {
send_to_char("The character was not found to compare against.\n\r", ch);
           return;
       }
   }

   send_to_char( "^fPlease wait while we scan for alts. "
       "This process can take a minute...^0\n\r\n\r", ch );

   send_to_char( "Searching pfiles", ch );

   if ( ( player_dir = opendir(PLAYER_DIR) ) != NULL )
   {
       while ( ( players = readdir(player_dir) ) != NULL )
       {
           send_to_char( ".", ch );

           if ( !str_cmp( players->d_name, "." )
           || !str_cmp( players->d_name, ".." ) )
               continue;

           if ( !str_cmp( players->d_name, victim->name ) )
               continue;

           if ( ( lch = get_char_online(players->d_name) ) == NULL )
               lch = get_char_offline(players->d_name);

           if ( !str_cmp( victim->pcdata->host, lch->pcdata->host ) )
           {
               if ( !IS_SET( lch->pen, PEN_SNOOP_PROOF )
               && !IS_IMMORTAL(lch) )
               {
sprintf( buf, "^$%2d^!) ^$%s^0\n\r", ++count, lch->name );
                   strcat( output, buf );
               }
           }

           unload_char(lch);
       }

       send_to_char( "\n\r\n\r", ch );
       if ( count > 0 )
       {
           sprintf( buf, "Below is a list of all characters connecting"
               " from host:\n\r\t%s\n\r\n\r", victim->pcdata->host );
           send_to_char( buf, ch );

           send_to_char( output, ch );
       }
       else
           send_to_char( "No matches found.\n\r", ch );
   }
   else
       bug( "Could not open PLAYER_DIR!", 0 );

   closedir(player_dir);
   unload_char(victim);
   return;
}



----- Original Message ----- From: "Jason Gauthier" <[EMAIL PROTECTED]>
To: "Valnir" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Tuesday, March 08, 2005 9:44 AM
Subject: RE: Pausing a Loop.


Your best bet would be to run that in a separate thread.
(or fork(), if you don't want to mess with threading)


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valnir
Sent: Tuesday, March 08, 2005 9:41 AM
To: [email protected]
Subject: Pausing a Loop.

Ok, I created a nice little function so that my immortals can
find the alts of the any character on the game by comparing
against the host listed in the pfiles. The problem is that
since it loads and unloads every pfile, it takes a minute to
run, and since it does that, it literally pauses the game
while it's running. What command can I add into the loop to
tell it to pick up other process requests, etc? I'm sure
there is one, and I just don't know what it is.

Thanks in advance!
- Valnir

--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom


Reply via email to