Advanced Authorization Code 1.0 by Xerves (Released September 2 2000) Xerves is the admin/owner of Rafermand (mud.rafermand.net port 3002) Website: http://www.rafermand.net Contact: xerves@rafermand.net This is just an enhancement to the Auth code more than a total uplift. This code supports 2 nice features. 1. Keeps track of people who have been authorized (by who and what time they were authorized) 2. Has a timer, so after a certain amount of time, the player with be auto authorized. Helpful if no immortal is on at this time. There is another authorization code out at Samson's site, but this one does not change a lot of how the orginal authorization works if you like that, plus if you do not want the timed stuff, it is not too hard just to rip the list out of the code, so take whatever you want. Changed files --------------------- act_wiz.c comm.c db.c mud.h save.c tables.c update.c 1. actwiz.c ------------- Goto do_authorize in act_wiz.c and in the declarations add this. char *strtime; AUTHORIZE_DATA *newauth; AUTHORIZE_DATA *pastauth; Right before these lines victim = get_waiting_desc( ch, arg1 ); if ( victim == NULL ) Add this if ( !str_cmp( arg1, "list" ) ) { if (first_authorized) { send_to_char("&c&wName Authed by Date\n\r", ch); send_to_char( "&R----------------------------------------------------------------------------\n\r", ch ); for (pastauth = first_authorized; pastauth; pastauth = pastauth->next) { ch_printf(ch, "&G&W%-15s &C%-15s &c%s\n\r", pastauth->name, pastauth->authedby, pastauth->authdate); } } else { send_to_char("This list is currently empty.\n\r", ch); } return; } After these lines if ( arg2[0]=='\0' || !str_cmp( arg2,"accept" ) || !str_cmp( arg2,"yes" )) { victim->pcdata->auth_state = 3; Add this victim->pcdata->authwait = -1; CREATE(newauth, AUTHORIZE_DATA, 1); newauth->name = QUICKLINK( victim->name); newauth->authedby = QUICKLINK( ch->name); strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; newauth->authdate = STRALLOC( strtime ); LINK( newauth, first_authorized, last_authorized, next, prev ); fwrite_authlist(); After these lines else if ( !str_cmp( arg2, "name" ) || !str_cmp(arg2, "n" ) ) { victim->pcdata->auth_state = 2; Add victim->pcdata->authwait = 15; //Change name wait of 15 minutes, change if needed. 2. Comm.c ---------- In the function nanny in comm.c, you will find a section that starts with this if ( !str_cmp( argument, "New" ) ) Below that is some text that players see when they create a new character, you might want to change it so they know your authorization system has changed. See the bottom to see what has changed, etc. Find the following text ch->saving_poison_death = race_table[ch->race]->saving_poison_death; ch->saving_wand = race_table[ch->race]->saving_wand; ch->saving_para_petri = race_table[ch->race]->saving_para_petri; ch->saving_breath = race_table[ch->race]->saving_breath; ch->saving_spell_staff = race_table[ch->race]->saving_spell_staff; And add this line before or after it (does not matter) ch->pcdata->authwait = 6; // 5 to 6 minute Auth Wait, change if needed Look for the line if (!sysdata.WAIT_FOR_AUTH) Just a little below it you should see this line ch->pcdata->auth_state = 0; You might want to change it to 1. What this does allows you to automatically yes/no/deny that name when they login. Due to the timer, if they just sit there for 5 minutes and do not pull a rope or anything, they will get in without every being denied or accepted, so it is a good idea to change auth_state to 1. Again, in do_name you will find auth_state = 0, you might want to change it to 1 so you can authorize them after that if you want. 3. Db.c ------------- Find the following lines PROJECT_DATA * first_project; PROJECT_DATA * last_project; After it add AUTHORIZE_DATA * first_authorized; AUTHORIZE_DATA * last_authorized; Find the following lines log_string ("Loading Projects"); load_projects( ); after it add log_string ("Loading Authorized List"); load_authlist( ); 4. Mud.h --------------- Find the following line typedef struct affect_data AFFECT_DATA; After it add typedef struct authorize_data AUTHORIZE_DATA; // Keeps Auth data Find the following lines struct project_data { PROJECT_DATA * next; /* Next project in list */ Before it add struct authorize_data { AUTHORIZE_DATA * next; AUTHORIZE_DATA * prev; char *name; char *authedby; char *authdate; }; Find the following lines in pc_data int flags; /* Whether the player is deadly and whatever else we add. */ int pkills; /* Number of pkills on behalf of clan */ int pdeaths; /* Number of times pkilled (legally) */ Before them add sh_int authwait; Find the following extern PROJECT_DATA * first_project; extern PROJECT_DATA * last_project; After that add extern AUTHORIZE_DATA * first_authorized; extern AUTHORIZE_DATA * last_authorized; Find the following #define RIPTITLE_FILE SYSTEM_DIR "mudtitle.rip" #define ANSITITLE_FILE SYSTEM_DIR "mudtitle.ans" #define ASCTITLE_FILE SYSTEM_DIR "mudtitle.asc" After it add #define AUTHLIST_FILE SYSTEM_DIR "authlist.dat" Find the following void save_classes args( ( void ) ); void load_classes args( ( void ) ); void load_herb_table args( ( void ) ); Before those lines add void fwrite_authlist args( ( void ) ); void load_authlist args( ( void ) ); 5. Save.c ----------- Find the following lines ch->mental_state = -10; ch->mobinvis = 0; After those lines add ch->pcdata->authwait = -1; 6. Tables.c ------------- Somewhere in the file, best after all skills stuff in the beginning of the file, put these three functions in. void fwrite_authlist() { FILE *fpout; char buf[MAX_STRING_LENGTH]; char filename[MAX_INPUT_LENGTH]; AUTHORIZE_DATA *alist; sprintf( filename, "%s", AUTHLIST_FILE ); if ( (fpout=fopen(filename, "w")) == NULL ) { sprintf( buf, "Cannot open: %s for writing", filename ); bug( buf, 0 ); return; } if (first_authorized) { for (alist = first_authorized; alist; alist = alist->next) { fprintf( fpout, "#AUTH\n"); fprintf( fpout, "Name %s~\n", alist->name); fprintf( fpout, "Authedby %s~\n", alist->authedby); fprintf( fpout, "Authdate %s~\n", alist->authdate); fprintf( fpout, "End\n"); } } fprintf( fpout, "#END\n" ); fclose( fpout ); } void fread_authlist( FILE *fp ) { char buf[MAX_STRING_LENGTH]; char *word; bool fMatch; AUTHORIZE_DATA *alist; CREATE ( alist, AUTHORIZE_DATA, 1); for ( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': KEY( "Authedby", alist->authedby, fread_string_nohash(fp) ); KEY( "Authdate", alist->authdate, fread_string_nohash(fp) ); break; case 'E': if ( !str_cmp( word, "End" ) ) { LINK( alist, first_authorized, last_authorized, next, prev ); return; } case 'N': KEY( "Name", alist->name, fread_string_nohash(fp) ); break; } if ( !fMatch ) { sprintf( buf, "Fread_social: no match: %s", word ); bug( buf, 0 ); } } } void load_authlist() { FILE *fp; if ( ( fp = fopen( AUTHLIST_FILE, "r" ) ) != NULL ) { for ( ;; ) { char letter; char *word; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { bug( "Load_socials: # not found.", 0 ); break; } word = fread_word( fp ); if ( !str_cmp( word, "AUTH" ) ) { fread_authlist( fp ); continue; } else if ( !str_cmp( word, "END" ) ) break; else { bug( "Load_authlist: bad section.", 0 ); continue; } } fclose( fp ); } else { bug( "Cannot open authlist file", 0 ); exit(0); } } 7. Update.c ------------ Find the function void char_update( void ) and in the declerations add. AUTHORIZE_DATA *newauth; char *strtime; char buf[MAX_STRING_LENGTH]; After this chunk of code if ( !IS_NPC(ch) && ch->pcdata->nuisance ) { long int temp; if ( ch->pcdata->nuisance->flags < MAX_NUISANCE_STAGE ) { temp = ch->pcdata->nuisance->max_time-ch->pcdata->nuisance->time; temp *= ch->pcdata->nuisance->flags; temp /= MAX_NUISANCE_STAGE; temp += ch->pcdata->nuisance->time; if ( temp < current_time ) ch->pcdata->nuisance->flags++; } } Add the following if ( !IS_NPC(ch) && ch->pcdata->authwait != -1 && --ch->pcdata->authwait == 0) { ch->pcdata->auth_state = 3; SET_BIT(ch->pcdata->flags, PCFLAG_UNAUTHED); CREATE(newauth, AUTHORIZE_DATA, 1); newauth->name = QUICKLINK( ch->name); newauth->authedby = STRALLOC( "Auto" ); strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; newauth->authdate = STRALLOC( strtime ); LINK( newauth, first_authorized, last_authorized, next, prev ); fwrite_authlist(); if ( ch->pcdata->authed_by ) STRFREE( ch->pcdata->authed_by ); ch->pcdata->authed_by = STRALLOC ("Auto"); sprintf( buf, "%s: authorized", ch->name); to_channel( buf, CHANNEL_AUTH, "Auth", LEVEL_IMMORTAL ); /* Below sends a message to player when name is accepted - Brittany */ ch_printf_color( ch, "\n\r&GRafermand auto accepted the name of %s.\n\r" "You may be asked later to change it.\n\r", ch->name); ch->pcdata->authwait = -1; } ------------------------------------------------------------------ Well That is about it. Just a few comments to make about the code. ch->pcdata->authwait is the timer. When you first start a character, it will start at 6 (look in comm.c for where it does that). If you want the player to wait longer, change 6 to something bigger. The timer works on the char_update in update.c so it is about a minute every tick, so about 6 minutes. Also, once you have told a player to change its name, it will set to 15 and start over. ch->pcdata->auth_state is very important. This variable tells the game what state they are in. 0 - Need to pull a rope to get authorized. 1 - Waiting on immortals to authorize (will show up on authorize command) 2 - Needs to change name (can use name command) 3 - Authorized. In comm.c I mentioned before about setting auth_state to 1 because you will want to authorize the player as soon as possible so they do not sit there and wait out your timer to get through. This is the only loop hole and can be fixed by uping your timer or just getting tot he player if they do that, or just doing like I mentioned and have it almost always be set to 1 so you can authorize them without the player pulling a rope. Next, there is a file called authlist.dat that needs to be put into the system directory, put the following in the file. #AUTH Name Test~ Authedby Xerves~ Authdate Sat September 2 01:39:00 2000~ End #END It is always a good idea to have something in this file, it should start if you only have the #END in it, but if you do not have the file, the mud will shutdown. Well that is about it, remember to make clean and add authlist.dat to the system directory and you are ready to rumble. When you get into the game type authorize list To see a list of who has been authorized, by who, and when. Also change the timers and helpfiles if you need to. I would appreciate if you put my name in a helpfile somewhere relating to this code if you add one. This code was put together on a 1.4 custom mud and may contain bits of code that might need changed with 1.4a, if that happens, please contact me with the problem and I will try to resolve it. Also hunt through the code above for Xerves and Rafermand and change it to the name of your admin and mud. Thats it, contact info above.