Coding an account system?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    mudlab.org Forum Index -> Coding
View previous topic :: View next topic  
Author Message
Delerak



Joined: 17 May 2005
Posts: 49
Location: Tampa

PostPosted: Wed May 18, 2005 4:31 pm    Post subject: Coding an account system? Reply with quote

Anyone up for some tips? I can show what we have so far which is around 100 lines so far. I'll have to ask my coder, but anything anyone can suggest will be helpful to him at this point.

-D
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Author Message
Traithe



Joined: 13 May 2005
Posts: 50

PostPosted: Wed May 18, 2005 9:15 pm    Post subject: Reply with quote

I seem to remember that you emailed me this code to look over, but I was too busy with exams to get to it.

If you want to resend it or post it here I'll be glad to take a look now that I have the time.
Back to top
View user's profile Send private message Visit poster's website
Author Message
eiz



Joined: 11 May 2005
Posts: 152
Location: Florida

PostPosted: Wed May 18, 2005 9:16 pm    Post subject: Reply with quote

This is really a pretty vague question. Is there something in particular he's stumped on? Really (assuming Diku), you need to add a data structure for representing accounts, code to save and load said data structure, extra connection states for account creation and login, and not a whole lot else (as far as I'm aware anyway).
Back to top
View user's profile Send private message Visit poster's website
Author Message
Traithe



Joined: 13 May 2005
Posts: 50

PostPosted: Wed May 18, 2005 9:17 pm    Post subject: Reply with quote

He's stumped on the particular implementation, IIRC.

I pointed him to the code I released as an example, but I think he was having some trouble getting it to work in practice.

Something I can more readily appreciate now that I'm wrestling with learning C++. Shocked
Back to top
View user's profile Send private message Visit poster's website
Author Message
Delerak



Joined: 17 May 2005
Posts: 49
Location: Tampa

PostPosted: Wed May 18, 2005 11:38 pm    Post subject: Reply with quote

I'll get him to come here and post about what he is particularly having troubles with.

-D
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Author Message
Xione



Joined: 19 May 2005
Posts: 9

PostPosted: Thu May 19, 2005 4:47 am    Post subject: Reply with quote

I'm the coder for Darksun.

I'm running into the problem basically with descriptors but most of all, how to work with the files.

For example, each account needs to be linked to a player if they create it and each player linked to an account which can be done via a new field in their pfile named "ch->account" in any case.

The problem comes when trying to load from the accounts, basically each account will have this structure.

Name
Email
Pword
Notes (multiple lines)
Current
Past

So.. I need all of that information someplace.

Someone told me I should do it like directories where when someone types in a login name it scans the /account directory for that name dir then goes into it and pulls a file say.. config.acc that contains their data and reads from it, then switch off of that and load the char.

Another thing would be.. I need to be able to allow imms to add 'notes' to the accounts whether a player is on or not, so I'd need to 'load' an account and then 'unload' it. But as of right now, I'm so clueless, I tried and wrote near 100 lines of code that didn't work, I got frustrated and gave up after trying and trying..

Here's the code if it let's me post it.

Code:

void nanny( DESCRIPTOR_DATA *d, char *argument )
{
   char buf[MAX_STRING_LENGTH];
   ACC_DATA *name;
//    char arg[MAX_INPUT_LENGTH];
   CHAR_DATA *ch;
   char *pwdnew;
   char *p;
/*    int iClass; */
   int iRace;
/*    int col, sn; */
   extern char * help_greeting;
   extern char * help_acc_greeting;
   FILE *fp;
   char strsave[MAX_INPUT_LENGTH];
   extern int interp_doer;


   while ( isspace(*argument) )
   argument++;

   acc = d->acc

   switch ( d->connected )
   {

   default:
   bug( "Nanny: bad d->connected %d.", d->connected );
   close_socket( d );
   return;

   case CON_LOGIN_PASSWORD:
   write_to_buffer( d, "\n\r", 2 );

   if ( strcmp( crypt( argument, acc->pwd ), acc->pwd ) )
   {
       write_to_buffer( d, "Wrong password.\n\r", 0 );
       close_socket( d );
       return;
   }

   write_to_buffer( d, echo_on_str, 0 );

   sprintf( buf, "\n\rWelcome back, %s!\n\r", acc->name );
   write_to_buffer( d, buf, 0 );
     if ( acc->current != NULL )
   {
       sprintf(buf, "\n\rConnecting to %s...\n\r", acc->current );
       write_to_buffer(d, buf, 0);
       ch = acc->current;
       write_to_buffer(d, help_acc_greeting, 0 );
       d->connected = CON_ACC_MENU;
       return;
   }
   write_to_buffer(d, "\n\rYou do not currently have a character, use the option N to create a new one.", 0 );
   write_to_buffer(d, help_acc_greeting, 0 );
   d->connected = CON_ACC_MENU;
   break;

   case CON_READ_MOTD:
   write_to_buffer( d,
   "\n\rWelcome to Darksun: Clash of the Sorceror Kings!\n\r", 0);
               ch->next    = char_list;
   char_list    = ch;
   d->connected    = CON_PLAYING;
   d->ansi_enable = TRUE;

   if ( ch->level == 0 )
   {
       ch->perm_stat_phys_str
         = number_stat() + race_array[ch->race]->stat_phys_str_mod;
       ch->perm_stat_phys_dex
         = number_stat() + race_array[ch->race]->stat_phys_dex_mod;
       ch->perm_stat_phys_tou
         = number_stat() + race_array[ch->race]->stat_phys_tou_mod;
       ch->perm_stat_phys_qui
         = number_stat() + race_array[ch->race]->stat_phys_qui_mod;
       ch->perm_stat_ment_int
         = number_stat() + race_array[ch->race]->stat_ment_int_mod;
       ch->perm_offense = 10;

       ch->level    = 1;
       ch->max_hit = race_array[ch->race]->hits_base
   + dice( race_array[ch->race]->hitnodice, race_array[ch->race]->hitsizedice );
       ch->hit[HIT_LOC_BODY]    = ch->max_hit;
       ch->max_mana = race_array[ch->race]->mana;
       ch->mana    = ch->max_mana;
       ch->max_move = race_array[ch->race]->move;
       ch->move    = ch->max_move;
       ch->vision_min = race_array[ch->race]->vision_min;
       ch->vision_max = race_array[ch->race]->vision_max;
       ch->vision_range = race_array[ch->race]->vision_range;
       ch->prompt = "< Please see HELP PROMPT to set your prompt >;

       ch->height = race_array[ch->race]->height_base
                        + dice( race_array[ch->race]->heightnodice,
                                race_array[ch->race]->heightsizedice );

       ch->weight = race_array[ch->race]->weight_base
                        + dice( race_array[ch->race]->weightnodice,
                                race_array[ch->race]->weightsizedice );

           /* for now, give all characters common */
           ch->pcdata->learned[gsn_common] = 100;

       char_to_room( ch,
         get_room_index( ROOM_VNUM_CHARACTER_GENERATION ), FALSE );
   }
   else if ( ch->in_room != NULL )
   {
       char_to_room( ch, ch->in_room, FALSE );
   }
   else if ( IS_IMMORTAL(ch) )
   {
       char_to_room( ch, get_room_index( ROOM_VNUM_CHAT ), FALSE );
   }
   else
   {
       char_to_room( ch, get_room_index( ROOM_VNUM_TEMPLE ), FALSE );
   }

   save_char_obj( ch );

   restore_hunting( ch );

   act( "$n has entered the realm of athas.",
     ch, NULL, NULL, NULL, NULL, TO_ROOM, SENSE_SIXTH );
   do_look( ch, "auto" );
   sprintf( log_buf, "%s@%s has entered the realm of athas.", ch->name, d->host );
   log_string( log_buf );
   break;

 
   case CON_MAIN_MENU:
   /*
    * Connect character.
    */
   if ( argument[0] == 'C' || argument[0] == 'c' )
   {
       if ( d->character != NULL )
       {
       free_char( d->character );
       d->character = NULL;
       }

       if ( d->acc != NULL )
       {
       free_char( d->acc );
       d->acc = NULL;
       }

       write_to_buffer( d, "\n\rPlease enter your account name:  ", 0 );
       d->connected = CON_LOGIN_GET_ACC_NAME;
       return;
   }

     /*
    * Create new account
    */
   if ( argument[0] == 'N' || argument[0] == 'n' )
   {
       if ( d->acc != NULL )
       {
       free_char( d->acc );
       d->acc = NULL;
       }

       if ( d->character != NULL )
       {
       free_char( d->character );
       d->character = NULL;
       }

       write_to_buffer( d, "\n\rEnter new account name>  ", 0 );
       d->connected = CON_CREATE_NEW_ACC_NAME;
       return;
   }

   /*
    * Exit the game.
    */
   if ( argument[0] == 'X' || argument[0] == 'x' )
   {
       write_to_buffer( d, "\n\rThank you for playing Darksun: Clash of the Sorceror Kings.\n\r", 0 );

       if ( d->acc != NULL )
       {
       free_char( d->acc );
       d->acc = NULL;
       }

       if ( d->character != NULL )
       {
       free_char( d->character );
       d->character = NULL;
       }
       close_socket( d );
   }
               write_to_buffer( d, "\n\rThat is an invalid option.\n\r", 0 );
   write_to_buffer( d, help_greeting, 0 );
   break;

   case CON_ACC_MENU:
   if ( argument[0] == '\0' )
   {
       write_to_buffer( d, help_acc_greeting, 0 );
       write_to_buffer( d, "\n\rPlease select an option: ", 0 );
       d->connected = CON_ACC_MENU;
       return;
   }
   

   if ( argument[0] == 'C' || argument[0] == 'c' )
   {

       if ( ch != NULL )
       {
       free_char( ch );
       ch = NULL;
       }

       ch = acc->current;
       else if ( IS_SET(ch->act, PLR_UNAPPROVED) )
       {
           write_to_buffer(d, "\n\rYour character hasn't been approved yet.", 0 );
           d->connected = CON_ACC_MENU;
           return;
       }

       else if ( IS_SET( ch->act, PLR_REJECTED ) )
       {
       sprintf( buf, "Your character was rejected because:\n\n\r%s\n\n",
       ch->pcdata->rejected );
       write_to_buffer( d, buf, 0 );
       sprintf( buf, "rm -f %s%s",
       REJECTED_DIR, capitalize( ch->name ) );
       system( buf );
       free_char( d->character );
       d->character = NULL;
       d->connected = CON_ACC_MENU;
       return;
   }
             sprintf( buf, "\n\rConnected to %s.\n\r", ch->name );
       write_to_buffer( d, buf, 0 );
       write_to_buffer( d, help_acc_greeting, 0);
       d->connected = CON_ACC_MENU;
   }

   if ( argument[0] == 'A' || argument[0] == 'a' )
   {
       write_to_buffer(d, "\n\rPlease enter a new email address: ", 0 );
       d->connected = CON_CHANGE_EMAIL;
       return;
   }

   if ( argument[0] == "N" || argument[0] == "n" )
   {
       if ( acc->current != NULL )
       {
           write_to_buffer(d, "\n\rBut you've already got a character.", 0 );
           return;
       }

   write_to_buffer(d, "What name would you like to use: ", 0 );
   d->connected = CON_GET_NEW_NAME;
   return;
   }

   case CON_GET_NEW_NAME:
     if ( argument[0] == '\0' )
   {
       write_to_buffer( d, "\n\rNo name input.\n\r", 0 );
       write_to_buffer( d, help_acc_Greeting, 0 );
       d->connected = CON_ACC_MENU;
       return;
   }

   argument[0] = UPPER(argument[0]);
   if ( !check_parse_name( argument ) )
   {
       write_to_buffer( d, "\n\rIllegal name.\n\r", 0 );
       write_to_buffer( d, help_acc_greeting, 0 );
       d->connected = CON_ACC_MENU;
       return;
   }

   fclose( fpReserve );
   sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( argument ) );
   if ( ( fp = fopen( strsave, "r" ) ) != NULL )
   {
       write_to_buffer( d, "\n\rThat character already exists.\n\r", 0 );
       write_to_buffer( d, help_acc_greeting, 0 );
       d->connected = CON_ACC_MENU;
       fclose( fp );
       fpReserve = fopen( NULL_FILE, "r" );
       return;
   }

   sprintf( strsave, "%s%s", UNAPPROVED_DIR, capitalize( argument ) );
   if ( ( fp = fopen( strsave, "r" ) ) != NULL )
   {
       write_to_buffer( d, "\n\rThat character already exists and is waiting reviewal.\n\r", 0 );
       write_to_buffer( d, help_acc_greeting, 0 );
       d->connected = CON_ACC_MENU;
       fclose( fp );
       fpReserve = fopen( NULL_FILE, "r" );
       return;
   }
   fpReserve = fopen( NULL_FILE, "r" );

   load_char_obj( d, argument );
   SET_BIT( d->character->act, PLR_UNAPPROVED );
   write_to_buffer( d, "What is your sex (M/F)? ", 0 );
   d->connected = CON_CREATE_NEW_SEX;
   break;

 
   case CON_CREATE_NEW_SEX:

   switch ( argument[0] )
   {
   case 'm': case 'M': ch->sex = SEX_MALE;    break;
   case 'f': case 'F': ch->sex = SEX_FEMALE;  break;
   default:
       write_to_buffer( d, "Invalid gender.\n\rWhat is your character's gender? ", 0 );
       return;
   }

   write_to_buffer( d, "Select a race:  human, elf, dwarf > ", 0 );
   d->connected = CON_CREATE_NEW_RACE;
   break;

   case CON_CREATE_NEW_RACE:
       /* KLUDGE */
   for ( iRace = 1; iRace <= 3; iRace++ )
   {
       if ( !str_cmp( argument, race_array[iRace]->race_name ) )
       {
       ch->race = iRace;
       break;
       }
   }

   if ( iRace > 3 )
   {
       write_to_buffer( d, "One of the following only:\n\r"
               "  human, elf, dwarf > ", 0 );
       break;
   }


   do_help( ch, "short_desc" );
   write_to_buffer( d, "\n\rEnter a short description on line below:\n\r>", 0 );
   d->connected = CON_CREATE_SHORT_DESC;
   break;

   case CON_CREATE_SHORT_DESC:
       if ( argument[0] == '\0' )
       {
           write_to_buffer(d, "\n\rPlease input a short description.", 0 );
           do_help( ch, "short_desc" );
           d->connected = CON_CREATE_SHORT_DESC;
           return;
       }

       if ( strlen(argument) > 35 )
       {
           write_to_buffer(d, "\n\rThat short description is too long, please limit it to 35 characters.", 0 );
           do_help( ch, "short_desc" );
           d->connected = CON_CREATE_SHORT_DESC;
           return;
       }

       ch->short_descr = str_dup( argument );
       do_help( ch, "namelist" );
       write_to_buffer( d, "\n\rPlease add extra keywords on this line.\n\r>", 0 );
       d->connected = CON_CREATE_NAMELIST;
       break;


   case CON_CREATE_NAMELIST:

   ch->namelist = str_dup( argument );

   do_help( ch, "description" );
   write_to_buffer( d, "\n\rEnter your description below.  End with a ~\n\r>", 0 );
   d->connected = CON_CREATE_DESCRIPTION;
   break;

   case CON_CREATE_DESCRIPTION:
   if ( argument[0] == '~' )
   {
       do_help( ch, "background" );
       write_to_buffer( d, "\n\rEnter your background below. End with a ~\n\r>", 0 );
       d->connected = CON_CREATE_BACKGROUND;
       return;
   }
   else
   {
       strcpy( buf, ch->description );
       if ( buf[0] == '\0' )
       strcpy( buf, argument );
       else
       strcat( buf, argument );
       strcat( buf, "\n\r" );
       free_string( ch->description, MEM_PCDATA );
       ch->description = str_dup( buf );

       if ( strlen( buf ) > 900 )
       {
       write_to_buffer( d, "\n\rMaximum description length exceeded.\n\r", 0 );
       do_help( ch, "background" );
       write_to_buffer( d, "\n\rEnter your background on the line below:\n\r>", 0 );
       d->connected = CON_CREATE_BACKGROUND;
       return;
       }
       else
       {
       write_to_buffer( d, ">", 1 );
       return;
       }
   }
   break;

   case CON_CREATE_BACKGROUND:
   if ( argument[0] == '~' )
   {
         ch->pcdata->rejected = str_dup( "" );
   SET_BIT( ch->act, PLR_UNAPPROVED );
   ch->account = acc->name;
   acc->current = ch->name
   save_char_obj( ch );

   write_to_buffer( d, "\n\n\rYour character has been saved, and should be approved or disapproved\n\rin less than a day or two.\n\n\r", 0 );

       sprintf( log_buf, "%s@%s new player application.",
     ch->name, d->host );
       interp_doer = MAX_LEVEL - 3;
   log_string( log_buf );
 
   write_to_buffer( d, help_greeting, 0 );
   free_char( ch );
   free_char( acc );
   d->character = NULL;
   d->connected = CON_MAIN_MENU;
   break;
   }

   return;
}
   else
   {
       strcpy( buf, ch->description );
       if ( buf[0] == '\0' )
       strcpy( buf, argument );
       else
       strcat( buf, argument );
       strcat( buf, "\n\r" );
       free_string( ch->description, MEM_PCDATA );
       ch->description = str_dup( buf );

       if ( strlen( buf ) > 500 )
       {
       write_to_buffer( d, "\n\rMaximum background length exceeded.\n\r", 0 );
       do_help( ch, "email" );
       write_to_buffer( d, "\n\rEnter your email address on the line below:\n\r>", 0 );
       d->connected = CON_CREATE_EMAIL;
       return;
       }
       else
       {
       write_to_buffer( d, ">", 1 );
       return;
       }
   }
   break;


   case CON_CHANGE_EMAIL:
   if (argument[0] == '\0' )
   {
       write_to_buffer(d, "\n\rNo input, no change.", 0 );
       return;
   }
     free_string( acc->email_address, MEM_PCDATA );
   acc->email_address = str_dup( argument );
   sprintf(buf, "\n\rEmail changed to %s.", acc->email_address );
   d->connected = CON_ACC_MENU;

   break;


   case CON_LOGIN_GET_ACC_NAME:
   if ( argument[0] == '\0' )
   {
       write_to_buffer( d, "\n\rNo name input.\n\r", 0 );
       write_to_buffer( d, help_greeting, 0 );
       d->connected = CON_MAIN_MENU;
       return;
   }

   argument[0] = UPPER(argument[0]);
   if ( !check_parse_name( argument ) )
   {
       write_to_buffer( d, "Illegal name, try another.\n\rName: ", 0 );
       return;
   }

   if ( load_char_acc( d, argument ) == FALSE )
   {
       write_to_buffer( d, "\n\rThat account does not exist.\n\r", 0 );
       write_to_buffer( d, help_greeting, 0 );
       free_char( d->acc );
       d->acc = NULL;
       d->connected = CON_MAIN_MENU;
       return;
   }
   acc   = d->acc;

   if ( IS_SET( ch->act, PLR_REJECTED ) )
       {
       sprintf( buf, "Your account was rejected because:\n\n\r%s\n\n",
       acc->rejected );
       write_to_buffer( d, buf, 0 );
       sprintf( buf, "rm -f %s%s",
       REJECTED_ACC_DIR, capitalize( ch->name ) );
       system( buf );
       free_char( d->acc );
       d->character = NULL;
       d->connected = CON_MAIN_MENU;
       return;
   }

   if ( IS_SET(acc->flags, PLR_DENY) )
   {
       sprintf( log_buf, "Denying access to %s@%s.", argument, d->host );
       interp_doer = MAX_LEVEL - 3;
       log_string( log_buf );
       write_to_buffer( d, "You have been denied access to the game. If you feel you have\n", 0 );
       write_to_buffer( d, "reached this in error, please email mud@darksukings.com.\n\r", 0 );
       close_socket( d );
       return;
   }

   if ( !check_reconnect( d, argument, FALSE ) )
   {
       if ( wizlock && acc->imm <= "0" )
       {
       write_to_buffer( d, "The game is wizlocked.\n\r", 0 );
       close_socket( d );
       return;
       }
           if ( downtime && acc->imm <= "0" )
           {
               write_to_buffer( d, "We are currently down for maintinence. The game will be back\n", 0 );
               write_to_buffer( d, "back up at approxamently 5 p.m. CST.\n\r", 0 );
               close_socket( d );
               return;
           }
}

   write_to_buffer( d, "Password: ", 0 );
   write_to_buffer( d, echo_off_str, 0 );
   d->connected = CON_LOGIN_PASSWORD;
   return;
   break;

   case CON_CREATE_NEW_NAME:
   if ( argument[0] == '\0' )
   {
       write_to_buffer( d, "\n\rNo name input.\n\r", 0 );
       write_to_buffer( d, help_greeting, 0 );
       d->connected = CON_MAIN_MENU;
       return;
   }

   argument[0] = UPPER(argument[0]);
   if ( !check_parse_name( argument ) )
   {
       write_to_buffer( d, "\n\rIllegal name.\n\r", 0 );
       write_to_buffer( d, help_greeting, 0 );
       d->connected = CON_MAIN_MENU;
       return;
   }

   fclose( fpReserve );
   sprintf( strsave, "%s%s", ACCOUNT_DIR, capitalize( argument ) );
   if ( ( fp = fopen( strsave, "r" ) ) != NULL )
   {
       write_to_buffer( d, "\n\rThat account already exists.\n\r", 0 );
       write_to_buffer( d, help_greeting, 0 );
       d->connected = CON_MAIN_MENU;
       fclose( fp );
       fpReserve = fopen( NULL_FILE, "r" );
       return;
   }

   sprintf( strsave, "%s%s", UNAPPROVED_ACC_DIR, capitalize( argument ) );
   if ( ( fp = fopen( strsave, "r" ) ) != NULL )
   {
       write_to_buffer( d, "\n\rYour account has not yet been approved.\n\r", 0 );
       write_to_buffer( d, help_greeting, 0 );
       d->connected = CON_MAIN_MENU;
       fclose( fp );
       fpReserve = fopen( NULL_FILE, "r" );
       return;
   }
   fpReserve = fopen( NULL_FILE, "r" );

   load_char_acc( d, argument );
   SET_BIT( d->acc->flags, PLR_UNAPPROVED );
     write_to_buffer( d, "\n\rEnter password:  ", 0 );
   write_to_buffer( d, echo_off_str, 0 );
   d->connected = CON_CREATE_NEW_PASSWORD;
   break;

   case CON_CREATE_NEW_PASSWORD:
   #if defined(unix)
       write_to_buffer( d, "\n\r", 2 );
   #endif

   if ( strlen(argument) < 5 )
   {
       write_to_buffer( d,
       "Password must be at least five characters long.\n\rPassword: ",
       0 );
       return;
   }

   pwdnew = crypt( argument, acc->name );
   for ( p = pwdnew; *p != '\0'; p++ )
   {
       if ( *p == '~' )
       {
       write_to_buffer( d,
           "New password not acceptable, try again.\n\rPassword: ",
           0 );
       return;
       }
   }

   free_string( acc->pwd, MEM_PCDATA );
   acc->pwd    = str_dup( pwdnew );
   write_to_buffer( d, "Please retype password: ", 0 );
   d->connected = CON_CREATE_CONFIRM_PASSWORD;
   break;

   case CON_CREATE_CONFIRM_PASSWORD:
   #if defined(unix)
       write_to_buffer( d, "\n\r", 2 );
   #endif

   if ( strcmp( crypt( argument, acc->pwd ), acc->pwd ) )
   {
       write_to_buffer( d, "Passwords don't match.\n\rRetype password: ",    0 );
       d->connected = CON_CREATE_NEW_PASSWORD;
       return;
   }

   write_to_buffer( d, echo_on_str, 0 );
   write_to_buffer( d, "\n\rWe require a -valid- email address for all Darksun MUD accounts. ", 0 );
   write_to_buffer( d, "\nThe email address will be used for the sole purpose of informing you", 0 );
   write_to_buffer( d, "\nof your account events, special roles, and general things in relation to your", 0 );
   write_to_buffer( d, "\ncharacter. We do not solicitate emails.\n\r", 0 );
   write_to_buffer( d, "Please enter a VALID email address: ", 0 );
   d->connected = CON_CREATE_EMAIL;
   break;

     case CON_CREATE_EMAIL:
            if ( argument[0] == '\0' )
       {
           write_to_buffer( d, "You must supply a VALID email address.\n\r
               Please enter a VALID email address: ", 0 );
           d->connected = CON_CREATE_EMAIL;
           return;
       }

       if ( !strstr (argument, "@") || !strstr (argument, ".") )
       {
       write_to_buffer (d ,"\n\rThe email address you provided did not contain the \"@\" or \".\" symbols. \n\rPlease try again: ", 0);
       d->connected = CON_CREATE_EMAIL;
       return;
       }



   acc->email_address = str_dup( argument );

   acc->rejected = str_dup( "" );
   SET_BIT( acc->flags, PLR_UNAPPROVED );
     save_char_acc( acc );

   write_to_buffer( d, "\n\n\rYour account has been saved, and should be approved or disapproved\n\rin less than a day or two.\n\n\r", 0 );

       sprintf( log_buf, "%s@%s new account application.",
     acc->name, d->host );
       interp_doer = MAX_LEVEL - 3;
   log_string( log_buf );

   write_to_buffer( d, help_greeting, 0 );
   free_char( acc );
   d->acc = NULL;
   d->connected = CON_MAIN_MENU;
   break;
   }

   return;
}



I've defined everything in the header merc.h so that's all done.. This is the nanny function found in comm.c that I rewrote..
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Author Message
eiz



Joined: 11 May 2005
Posts: 152
Location: Florida

PostPosted: Thu May 19, 2005 4:57 am    Post subject: Reply with quote

Xione wrote:

Someone told me I should do it like directories where when someone types in a login name it scans the /account directory for that name dir then goes into it and pulls a file say.. config.acc that contains their data and reads from it, then switch off of that and load the char.


That's certainly one way to do it. You'd have files like:

Code:

accounts/eiz/GenericFantasyName
accounts/eiz/SomethingIGotOutOfANameGenerator
accounts/eiz/config


Or you could just store a list of character names in the account file. Either way works, although using a directory per account is much simpler from a management perspective.

Xione wrote:

Another thing would be.. I need to be able to allow imms to add 'notes' to the accounts whether a player is on or not, so I'd need to 'load' an account and then 'unload' it. But as of right now, I'm so clueless, I tried and wrote near 100 lines of code that didn't work, I got frustrated and gave up after trying and trying..


Yes. This would look essentially the same as load_char_obj/fread_char except with different fields (obviously) and it would return the structure instead of associating it with a descriptor.
Back to top
View user's profile Send private message Visit poster's website
Author Message
Xione



Joined: 19 May 2005
Posts: 9

PostPosted: Thu May 19, 2005 5:04 am    Post subject: Reply with quote

So basically just set it up to look for a directory named -what they input for a name- if it's not found, return FALSE, if it's found, return TRUE and open up the config.acc file inside and read acc->passwd and so forth?

How'd the nanny look? The current nanny has been modified quite a bit actually, as far as races/classes goes, but that's a quick implentation to do, it's handling the logon and switching off and on between char and account that gets me.

It's not really that I don't know how to code it, it's I don't know what to do to make it work.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Author Message
Delerak



Joined: 17 May 2005
Posts: 49
Location: Tampa

PostPosted: Fri May 20, 2005 8:45 am    Post subject: Reply with quote

No ideas? Anybody? Maybe this is a bit more advanced then I thought..

Moderator Note:
Please don't write posts like this. Many people have already replied with several pointers.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Author Message
Yui Unifex
Site Admin


Joined: 11 May 2005
Posts: 47
Location: Florida

PostPosted: Fri May 20, 2005 11:40 pm    Post subject: Reply with quote

Xione wrote:
So basically just set it up to look for a directory named -what they input for a name- if it's not found, return FALSE, if it's found, return TRUE and open up the config.acc file inside and read acc->passwd and so forth?

You should probably write it so it returns an AccountData structure. If the return value is NULL, the account obviously doesn't exist. Otherwise, try to validate the password of that account you just loaded.

Xione wrote:
How'd the nanny look?

Try splitingt the significant sections of your nanny function apart. Gigantic functions are terribly difficult to digest. I recommend using a stack of input handlers that you can push and pop that replace the entire nanny function: Instead of keeping track of every possible state in nanny, you simply keep track of which state can transition to which other state. In many cases the states need not even know what state comes before them, since they could just pop themselves off the stack.

Xione wrote:
The current nanny has been modified quite a bit actually, as far as races/classes goes, but that's a quick implentation to do, it's handling the logon and switching off and on between char and account that gets me. It's not really that I don't know how to code it, it's I don't know what to do to make it work

What gets you? Could you be more specific about what your problem is? You could just add an intermediary step to handle the account menu -- right after the password validation, right before a character is logged in. Again, splitting the nanny into multiple functions makes this much simpler.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Author Message
Xione



Joined: 19 May 2005
Posts: 9

PostPosted: Sat May 21, 2005 3:57 am    Post subject: Reply with quote

I'm having trouble with the file structure.

How exactly would I check for an account if it's a directory and if it's found, how do I pull and open the config file and read the passwd part?

And about breaking it up into separate functions.. I've never seen that done before, could you elaborate a bit with some example code?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Author Message
Rendelven



Joined: 11 May 2005
Posts: 6
Location: Arkansas

PostPosted: Sat May 21, 2005 3:35 pm    Post subject: Reply with quote

Code:

struct ACCOUNT_DATA {
    char * accountName;
    char * accountPassword;
    CHAR_DATA * charList; // You need a list of characters
}



Basically, What you are doing is making a 'new' character structure. The only thing this does is, instead of holding character data, is hold 3 things.

It has been a while but there is a way to open up directories to get listings, etc. I remember there being a 'DIR' structure you are supposed to use.

You just search in that directory for a default file, you could name it whatever. You open it up, read the name/pw/etc. Once you've logged into the account, it should atleast load up the names of your characters.

Then, when they choose the character you load it up. ( There is already a function to load characters. Use that to build off of. You can modify to load other things. Smile )
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Author Message
Xione



Joined: 19 May 2005
Posts: 9

PostPosted: Mon May 23, 2005 5:04 am    Post subject: Reply with quote

I think I might have it.. who knows, when I get time I'm going to get back to work on it and see what I can come up with..

Thanks Guys.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Author Message
Xione



Joined: 19 May 2005
Posts: 9

PostPosted: Tue May 24, 2005 5:06 am    Post subject: Reply with quote

I get the concept, I can understand how to modify the load and save functions in save.c and such, but I still don't get the DIR part..
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Author Message
Xione



Joined: 19 May 2005
Posts: 9

PostPosted: Tue May 24, 2005 7:06 am    Post subject: Reply with quote

Here's something else..

Code:


gcc -g -c -O -Wall -ggdb   act_comm.c
gcc -g -c -O -Wall -ggdb   act_info.c
gcc -g -c -O -Wall -ggdb   act_move.c
gcc -g -c -O -Wall -ggdb   act_obj.c
gcc -g -c -O -Wall -ggdb   act_wiz.c
gcc -g -c -O -Wall -ggdb   change.c
gcc -g -c -O -Wall -ggdb   comm.c
comm.c:1540: unterminated character constant



I know what an unterminated character constant is.

Here's that line and some.

Code:



       if ( ch != NULL )
       {
      free_char( ch );
      ch = NULL;
       }

      if ( account->current == NULL )
      {
         ch = NULL;
         >>write_to_buffer(d, "You don't have a character at this time.\n", 0 );
         return;
      }

      

    
      else if ( IS_SET(ch->act, PLR_UNAPPROVED) )
      {
         sprintf(buf, "\n\rYour character hasn't been approved yet.");
         write_to_buffer(d, buf, 0 );
         d->connected = CON_ACCOUNT_MENU;
      


>> Is is the line 1540


What's up?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    mudlab.org Forum Index -> Coding All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
BBTech Template by © 2003-04 MDesign