I put this snippet together for my dev mud so that we could wizlock the mud and allow testing with mortals without having to unwizlock it. It changes the way wizlock works, as well as the location of the greeting screen. Its a modified version of AFK's multi-port system. Any Questions, email me at novotellus@hotmail.com Tristan Ramsey (KazRo) Enjoy! Files Edited - comm.c - mud.h - db.c - act_wiz.c Edited Functions - cset - send_greeting - new_descriptor - nanny - save_sysdata - do_users - init_descriptor - boot_db <<<MUD.H>>>> --------------- IN: struct system_data UNDER: char *mud_name; /* Name of mud */ ADD: char *password; /* password for mud */ AFTER: CON_READ_MOTD, ADD: CON_CHECK_FOR_PASSWORD, UNDER: #define PLAYER_DIR "../player/" /* Player files */ ADD: #define MOTD_DIR "../motd/" UNDER: void show_file args( ( CHAR_DATA * ch, char *filename ) ); ADD: bool exists_file( char *name ); in act_wiz.c --------------- In: do_cset( CHAR_DATA * ch, char *argument ) FIND - pager_printf_color( ch, "\r\n&WMud_name: %s", sysdata.mud_name ); change to - pager_printf_color( ch, "\r\n&WMud_name: %s Password: [not shown]", sysdata.mud_name ); UNDER - ch_printf( ch, "Mud name set to: %s\n\r", argument ); } save_sysdata( sysdata ); return; } ADD - if( !str_cmp( arg, "password" ) ) { char *pwdnew; if( strlen( argument ) < 5 ) { send_to_char( "New password must be at least five characters long.\n\r", ch ); return; } if( argument[0] == '!' ) { send_to_char( "New password cannot begin with the '!' character.\n\r", ch ); return; } pwdnew = sha256_crypt( argument ); /* SHA-256 Encryption */ DISPOSE( sysdata.password ); sysdata.password = str_dup( pwdnew ); send_to_char( "Mud password changed.\n\r", ch ); save_sysdata( sysdata ); return; } FIND - void do_users( CHAR_DATA * ch, char *argument ) { UNDER - st = "Playing"; break; ADD - case CON_CHECK_FOR_PASSWORD: st = "Access code"; break; in comm.c --------------- FIND - void new_descriptor( int new_desc ) { ABOVE ADD - void send_greeting( DESCRIPTOR_DATA * d ) { FILE *rpfile; int num = 0; char BUFF[MSL], filename[256]; snprintf( filename, 256, "%sgreeting.dat", MOTD_DIR ); if( ( rpfile = fopen( filename, "r" ) ) != NULL ) { while( ( ( BUFF[num] = fgetc( rpfile ) ) != EOF ) && num < MSL - 1 ) num++; FCLOSE( rpfile ); BUFF[num] = '\0'; send_to_desc_color( BUFF, d ); } } In - void new_descriptor( int new_desc ) FIND - /* * Send the greeting. Forces new color function - Tawnos */ { extern char *help_greeting; if( help_greeting[0] == '.' ) send_to_desc_color( help_greeting + 1, dnew ); else send_to_desc_color( help_greeting, dnew ); } REPLACE with - /* * Send the greeting. No longer handled kludgely by a global variable. */ send_greeting( dnew ); if( wizlock ) { send_to_desc_color( "&RThe game is wizlocked&w. &ROnly immortals can connect now&w.&W\r\n", dnew ); send_to_desc_color( "&WPlease try back later&w.&W\r\n", dnew ); send_to_desc_color( "Enter access code: ", dnew ); } else send_to_desc_color( "Enter your character's name: ", dnew ); In - void init_descriptor( DESCRIPTOR_DATA * dnew, int desc ) find - dnew->connected = CON_GET_NAME; change to - if( wizlock ) dnew->connected = CON_CHECK_FOR_PASSWORD; else dnew->connected = CON_GET_NAME; In - void nanny( DESCRIPTOR_DATA * d, char *argument ) after - default: bug( "Nanny: bad d->connected %d.", d->connected ); close_socket( d, TRUE ); return; add - case CON_CHECK_FOR_PASSWORD: if( argument[0] == '\0' ) { close_socket( d, FALSE ); return; } if( str_cmp( sha256_crypt( argument ), sysdata.password ) ) { send_to_desc_color( "\n\r&RInvalid access code.", d ); close_socket( d, FALSE ); return; } send_to_desc_color( "Enter your character's name: ", d ); d->connected = CON_GET_NAME; break; In - CON_GET_NAME find - if( chk ) { fOld = TRUE; } else { if( wizlock && !IS_IMMORTAL( ch ) ) { write_to_buffer( d, "The game is wizlocked. Only immortals can connect now.\r\n", 0 ); write_to_buffer( d, "Please try back later.\r\n", 0 ); close_socket( d, FALSE ); return; } } change to - if( chk ) { fOld = TRUE; } db.c -------------------- find - void shutdown_mud( char *reason ) after - FCLOSE( fp ); } } add - bool exists_file( char *name ) { struct stat fst; /* * Stands to reason that if there ain't a name to look at, it damn well don't exist! */ if( !name || name[0] == '\0' || !str_cmp( name, "" ) ) return FALSE; if( stat( name, &fst ) != -1 ) return TRUE; else return FALSE; } find - shutdown_mud( "libdl failure" ); exit( 1 ); } add - log_string( "Verifying existance of login greeting..." ); snprintf( log_buf, MSL, "%sgreeting.dat", MOTD_DIR ); if( !exists_file( log_buf ) ) { bug( "%s", "Login greeting not found!" ); shutdown_mud( "Missing login greeting" ); exit( 1 ); } else log_string( "Login greeting located." ); In - void save_sysdata( SYSTEM_DATA sys ) find - fprintf( fp, "MudName %s~\n", sys.mud_name ); add - fprintf( fp, "Password %s~\n", sys.password ); find - case 'P': KEY( "Protoflag", sys->level_modify_proto, fread_number( fp ) ); add - KEY( "Password", sys->password, fread_string_nohash( fp ) ); /* Samson 2-8-01 */ Notes ---------------------- 1 - You will need to create a folder named motd 2 - Inside your motd folder you will need to create a file called greeting.dat - greeting.dat should contain your login screen (the greeting helpfile) - Included in this snippet is a folder called motd, it has stock dat files in it. Permissions ---------------------- Some of the code above is used from the AFK codebase, with permission.