void Storage::read( ConfigFile& cf ) { static int num_until_dot = 1000; unsigned long nobjects = 0; StorageArea *area = NULL; ConfigElem elem; clock_t start = clock(); while (cf.read( elem )) { if (--num_until_dot == 0) { cout << "."; num_until_dot = 1000; } if (elem.type_is( "StorageArea" )) { area = create_area( elem ); } else if (elem.type_is("Item")) { if (area != NULL) { try { area->load_item( elem ); } catch( std::exception& ) { if (!config.ignore_load_errors) throw; } } else { cerr << "Storage: Got an ITEM element, but don't have a StorageArea to put it." << endl; throw runtime_error( "Data file integrity error" ); } } else { cerr << "Unexpected element type " << elem.type() << " in storage file." << endl; throw runtime_error( "Data file integrity error" ); } ++nobjects; } clock_t end = clock(); long ms = static_cast<long>((end-start) * 1000.0 / CLOCKS_PER_SEC); cout << " " << nobjects << " elements in " << ms << " ms." << std::endl; }
int xmain( int argc, char* argv[] ) { StoreCmdArgs( argc, argv ); if (FindArg2( "uodata=" ) != NULL) { config.uo_datafile_root = FindArg2( "uodata=" ); config.uo_datafile_root = normalized_dir_form( config.uo_datafile_root ); } else { cout << "Reading pol.cfg." << endl; ConfigFile cf( "pol.cfg" ); ConfigElem elem; cf.readraw( elem ); config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" ); config.uo_datafile_root = normalized_dir_form( config.uo_datafile_root ); unsigned short max_tile = elem.remove_ushort( "MaxTileID", 0x3FFF ); if (max_tile != 0x3FFF && max_tile != 0x7FFF) config.max_tile_id = 0x3FFF; else config.max_tile_id = max_tile; } string main_cfg = "uoconvert.cfg"; if (FileExists( main_cfg.c_str() ) ) { string temp; ConfigElem elem; cout << "Reading uoconvert.cfg." << endl; ConfigFile cf_main( main_cfg.c_str() ); while( cf_main.read( elem ) ) { if (elem.type_is( "MultiTypes" )) { temp = elem.remove_string( "Boats" ); ISTRINGSTREAM is_boats( temp ); string graphicnum; while (is_boats >> graphicnum) BoatTypes.insert(strtoul(graphicnum.c_str(),NULL,0)); temp = elem.remove_string( "Houses" ); ISTRINGSTREAM is_houses( temp ); while (is_houses >> graphicnum) HouseTypes.insert(strtoul(graphicnum.c_str(),NULL,0)); temp = elem.remove_string( "Stairs" ); ISTRINGSTREAM is_stairs( temp ); while (is_stairs >> graphicnum) StairTypes.insert(strtoul(graphicnum.c_str(),NULL,0)); } else if (elem.type_is( "LOSOptions" ))
void read_stacking_cfg(ConfigFile& cf) { ConfigElem elem; if( cf.read( elem ) ) { if (elem.type_is( "Stacking" )) { string temp = elem.remove_string( "IgnoreCprops" ); ISTRINGSTREAM is( temp ); string cprop_name; while (is >> cprop_name) Global_Ignore_CProps.insert(cprop_name); } }
bool ConfigSection::matches( const ConfigElem& elem ) { if( elem.type_is( _sectname.c_str() ) ) { if( _found && ( _flags & CST_UNIQUE ) ) { elem.throw_error( "Section type " + _sectname + " found more than once" ); } _found = true; return true; } else { return false; } }