/* This functions purpose is to open up all of the various things the mud needs to have * up before the game_loop is entered. If something needs to be added to the mud * startup proceedures it should be placed in here. */ void init_mud( bool fCopyOver, int gameport, int wsocket, int imcsocket ) { // Scan for and create necessary dirs if they don't exit. directory_check( ); /* * If this all goes well, we should be able to open a new log file during hotboot */ if( fCopyOver ) { open_mud_log( ); log_string( "Hotboot: Spawning new log file" ); } log_string( "Booting Database" ); boot_db( fCopyOver ); if( !fCopyOver ) /* We have already the port if copyover'ed */ { log_string( "Initializing main socket" ); control = init_socket( gameport ); log_string( "Main socket initialized" ); } clear_trdata( ); // Begin the transfer data tracking #ifdef MULTIPORT switch ( gameport ) { case MAINPORT: log_printf( "%s game server ready on port %d.", sysdata->mud_name.c_str( ), gameport ); break; case BUILDPORT: log_printf( "%s builders' server ready on port %d.", sysdata->mud_name.c_str( ), gameport ); break; case CODEPORT: log_printf( "%s coding server ready on port %d.", sysdata->mud_name.c_str( ), gameport ); break; default: log_printf( "%s - running on unsupported port %d!!", sysdata->mud_name.c_str( ), gameport ); break; } #else log_printf( "%s ready on port %d.", sysdata->mud_name.c_str( ), gameport ); #endif #ifdef IMC imc_startup( false, imcsocket, fCopyOver ); #endif if( fCopyOver ) { log_string( "Initiating hotboot recovery." ); hotboot_recover( ); } }
int main(int argc, char **argv) { bool recovering = false; int port, control = 0; init_signals(); /** Get the port number. */ port = 7778; if (argc > 1) { if (!is_number(argv[1])) { fprintf(stderr, "Usage: %s [port #]\n", argv[0]); return 0; } else if ((port = atoi(argv[1])) <= 1024) { fprintf(stderr, "Port number must be above 1024.\n"); return 0; } /* Are we recovering from a copyover? */ if ((argv[2] != NULL) && (argv[2][0] != '\0')) { recovering = true; control = atoi(argv[3]); } else { recovering = false; } } init_time(&globalSystemState); boot_db(); /** Run the game. */ if (!recovering) { control = remote_listen(port); } log_string("BT is ready to rock on port %d.", port); if (recovering) { copyover_recover(); } game_loop(port, control); remote_deafen(control); log_string("Normal termination of game."); return 0; }