/* Load the channel file */ void load_mudchannels( void ) { mud_channel *channel = nullptr; int filever = 0; ifstream stream; log_string( "Loading channels..." ); chanlist.clear( ); stream.open( CHANNEL_FILE ); if( !stream.is_open( ) ) { log_string( "No channel file found." ); return; } do { string key, value; char buf[MIL]; stream >> key; stream.getline( buf, MIL ); value = buf; strip_lspace( key ); strip_tilde( value ); strip_lspace( value ); if( key.empty( ) ) continue; if( key == "#VERSION" ) filever = atoi( value.c_str( ) ); else if( key == "#CHANNEL" ) channel = new mud_channel; else if( key == "ChanName" ) channel->name = value; else if( key == "ChanColorname" ) channel->colorname = value; else if( key == "ChanLevel" ) channel->level = atoi( value.c_str( ) ); else if( key == "ChanType" ) channel->type = atoi( value.c_str( ) ); else if( key == "ChanFlags" ) { if( filever < 1 ) channel->flags = atoi( value.c_str( ) ); else flag_string_set( value, channel->flags, chan_flags ); } else if( key == "End" ) chanlist.push_back( channel ); else log_printf( "%s: Bad line in channel file: %s %s", __func__, key.c_str( ), value.c_str( ) ); } while( !stream.eof( ) ); stream.close( ); }
void load_auth_list( void ) { ifstream stream; auth_data *auth = nullptr; authlist.clear( ); stream.open( AUTH_FILE ); if( !stream.is_open( ) ) { bug( "%s: Cannot open auth.dat", __func__ ); return; } do { string key, value; char buf[MIL]; stream >> key; stream.getline( buf, MIL ); value = buf; strip_lspace( key ); strip_lspace( value ); strip_tilde( value ); if( key.empty( ) ) continue; if( key == "#AUTH" ) auth = new auth_data; else if( key == "Name" ) auth->name = value; else if( key == "State" ) { auth->state = atoi( value.c_str( ) ); if( auth->state == AUTH_ONLINE || auth->state == AUTH_LINK_DEAD ) /* * Crash proofing. Can't be online when booting up. Would suck for do_auth */ auth->state = AUTH_OFFLINE; } else if( key == "AuthedBy" ) auth->authed_by = value; else if( key == "Change" ) auth->change_by = value; else if( key == "End" ) authlist.push_back( auth ); else log_printf( "%s: Bad line in auth.dat file: %s %s", __func__, key.c_str( ), value.c_str( ) ); } while( !stream.eof( ) ); stream.close( ); clear_auth_list( ); }
void load_ships( void ) { ifstream stream; ship_data *ship; shiplist.clear( ); stream.open( SHIP_FILE ); if( !stream.is_open( ) ) { bug( "%s: Unable to open ships file.", __FUNCTION__ ); return; } do { string key, value; char buf[MIL]; stream >> key; stream.getline( buf, MIL ); value = buf; strip_lspace( key ); strip_lspace( value ); strip_tilde( value ); if( key.empty( ) ) continue; if( key == "#SHIP" ) ship = new ship_data; else if( key == "Name" ) ship->name = value; else if( key == "Owner" ) ship->owner = value; else if( key == "Flags" ) flag_string_set( value, ship->flags, ship_flags ); else if( key == "Vnum" ) ship->vnum = atoi( value.c_str( ) ); else if( key == "Room" ) ship->room = atoi( value.c_str( ) ); else if( key == "Type" ) { ship->type = get_shiptype( value ); ship->type = URANGE( SHIP_NONE, ship->type, SHIP_WARSHIP ); } else if( key == "Hull" ) ship->hull = atoi( value.c_str( ) ); else if( key == "Max_hull" ) ship->max_hull = atoi( value.c_str( ) ); else if( key == "Fuel" ) ship->fuel = atoi( value.c_str( ) ); else if( key == "Max_fuel" ) ship->max_fuel = atoi( value.c_str( ) ); else if( key == "Coordinates" ) { string coord; value = one_argument( value, coord ); ship->cmap = atoi( coord.c_str( ) ); value = one_argument( value, coord ); ship->mx = atoi( coord.c_str( ) ); ship->my = atoi( value.c_str( ) ); } else if( key == "End" ) shiplist.push_back( ship ); else log_printf( "%s: Bad line in ships file: %s %s", __FUNCTION__, key.c_str( ), value.c_str( ) ); } while( !stream.eof( ) ); stream.close( ); }
/* Loads the conn.hist file into memory */ void load_connhistory( void ) { ifstream stream; conn_data *conn; size_t conncount = 0; connlist.clear( ); stream.open( CH_FILE ); if( !stream.is_open( ) ) return; do { string key, value; char buf[MIL]; stream >> key; stream.getline( buf, MIL ); value = buf; strip_lspace( key ); strip_lspace( value ); strip_tilde( value ); if( key.empty( ) ) continue; if( key == "#CONN" ) conn = new conn_data; else if( key == "User" ) conn->user = value; else if( key == "When" ) conn->when = value; else if( key == "Host" ) conn->host = value; else if( key == "Level" ) conn->level = atoi( value.c_str( ) ); else if( key == "Type" ) conn->type = atoi( value.c_str( ) ); else if( key == "Invis" ) conn->type = atoi( value.c_str( ) ); else if( key == "End" ) { if( conncount < MAX_CONNHISTORY ) { ++conncount; connlist.push_back( conn ); } else { bug( "%s: more connection histories than MAX_CONNHISTORY %zd", __FUNCTION__, MAX_CONNHISTORY ); stream.close( ); return; } } else bug( "%s: Bad line in connection history file: %s %s", __FUNCTION__, key.c_str( ), value.c_str( ) ); } while( !stream.eof( ) ); stream.close( ); }