Mailing List
Home
Forum Home
Mac Game - Mac game development
Rivers of MUD - a Diku and Merc based multiuser dungeon
SMAUG
Subjects
Getting UDP through NAT/firewalls/whatever for a game
Getting UDP through NAT/firewalls/whatever for a game
QuickTime errors
Python script as stand alone MUD server
Subject: Various sound problems
Fragment Shaders & GL TEXTURE RECTANGLE EXT
Subject: Timers and global variables
Re: Language and platform for Text MUD server
Apparent acquisition of Yantis (mysupersales) by IDE
HID keyboard
Getting UDP through NAT/firewalls/whatever for a game
Microsoft Sparkle
Subject: Director MX
Congratulations Horizons
Yet more problems fullscreen mode
Apple Dev Kitchen Them 's tasty vittles, Maw!
NSOpenGLContext, Pbuffers, and drawables
More DCR "theft " naughtiness
dynamic sprite creation and imaging lingo
Re: Find stuff in Flash array?
Effects of skill imbalances?
QuickTime errors
Rom 2 4/Quickmud Enhancement/Bug fix
Subject: Working with XML files/CFURL
smooth scrolling/subpixel tweening
RE: (Ron help me?) Flash text
Subject: Flash Racing
Subject: MudDev FAQ 2
Browser based games
Installing GLUT
Special character in Flash XML
 
Subject: Questions about FORK.

Subject: Questions about FORK.

2006-08-15       - By Valnir

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Ok.. I'm working on an account system, and want to make sure that no two
accounts have the same email address. Don't want users having duplicate
accounts. The issue I'm having is that during account creation I'm scanning
all the existing user accounts to see if any have the same address. I'm
using fork() so that I don't have the entire mud come to a screeching halt
while it scans, but for some reason, although everything in the fork() seems
to be working fine, it doesn't set the d->connected correctly or process the
nanny function again at the end the way I'm wanting it to. Ideas? Thansk!

- Valnir

/* Code snippet */

void check_dup_email ( DESCRIPTOR_DATA *d, char *email )
{
   DIR *user_dir;
   struct dirent *users;
   USER_DATA *usr;
   char name[MIL];
   char buf[MSL];
   bool duplicate = FALSE;
   int f;

   if ( ( f = fork() ) == (-1) )
   {
       write_to_buffer( d, "\n\r\n\r", 0 );
       write_to_buffer( d, "An error occured while trying to validate your
email address!\n\r", 0 );
       write_to_buffer( d, "You will not be able to complete continue
creating your account\n\r"
           "until this problem is solved. The staff has been
contacted.\n\r\n\r"
           "Please check back soon!\n\r\n\r"
           "^e[^fPress Return to Disconnect^e]^0\n\r", 0 );

       d->connected = CON_USER_DISCONNECT;
       bug( "fork() failed in check_dup_email.", 0 );
       do_bug( NULL, "fork() failed in check_dup_email." );
       return;
   }

   if ( !f )
   {
       write_to_buffer( d, "Please wait while we scan for duplicate
accounts.", 0 );
       process_output( d, FALSE );

       if ( ( user_dir = opendir(USER_DIR) ) != NULL )
       {
           while ( ( users = readdir(user_dir) ) != NULL )
           {
               write_to_buffer( d, ".", 0 );

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

               if ( !strstr( users->d_name, ".usr" ) )
                   continue;

               /* get name from file filename - still need to parse the
'.usr' off the filename */

               if ( ( usr = load_account( NULL, name ) ) != NULL )
               {
                   if ( !str_cmp( usr->email, email ) )
                   {
                       sprintf( buf, "Attempt to use duplicate email
address detected. "
                           "Same as '%s'.", usr->name );
                       log_string( buf );
                       duplicate = TRUE;
                   }
               }

               unload_account( NULL, usr);
               process_output( d, FALSE );

               if ( duplicate )
                   break;
           }
       }
       else
           bug( "Could not open USER_DIR!", 0 );

       closedir( user_dir );
       write_to_buffer( d, "\n\r\n\r", 0 );

       if ( duplicate )
       {
           write_to_buffer( d, "Duplicate email found! We do not allow
multiple accounts\n\r"
               "per player. If you have forgotten your account name, please
contact\n\r"
               "the staff at http://www.legendofthenobles.com/?page=email
to request\n\r"
               "your account name.\n\r\n\r"
               "^e[^fPress Return to Disconnect^e]^0\n\r", 0 );

           process_output( d, TRUE );
           d->connected = CON_USER_DISCONNECT;
       }
       else
       {
           write_to_buffer( d, "No duplicate found.\n\r", 0 );
           process_output( d, TRUE );

           d->connected = CON_CONFIRM_EMAIL;
           nanny( d, email );
       }

       exit(0);
   }

   return;
}

--
ROM mailing list
ROM@(protected)
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom