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" ))
int UoConvertMain::main() { const std::vector<std::string>& binArgs = programArgs(); /********************************************** * show help **********************************************/ if ( binArgs.size() == 1 ) { showHelp(); return 0; // return "okay" } /********************************************** * TODO: rework the following cruft from former uoconvert.cpp **********************************************/ Plib::systemstate.config.max_tile_id = UOBJ_DEFAULT_MAX; // default std::string argvalue = programArgsFindEquals( "uodata=", "" ); if ( !argvalue.empty() ) { Plib::systemstate.config.uo_datafile_root = argvalue; Plib::systemstate.config.uo_datafile_root = Clib::normalized_dir_form( Plib::systemstate.config.uo_datafile_root ); } else { INFO_PRINT << "Reading pol.cfg.\n"; Clib::ConfigFile cf( "pol.cfg" ); Clib::ConfigElem elem; cf.readraw( elem ); Plib::systemstate.config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" ); Plib::systemstate.config.uo_datafile_root = Clib::normalized_dir_form( Plib::systemstate.config.uo_datafile_root ); unsigned short max_tile = elem.remove_ushort( "MaxTileID", UOBJ_DEFAULT_MAX ); if ( max_tile == UOBJ_DEFAULT_MAX || max_tile == UOBJ_SA_MAX || max_tile == UOBJ_HSA_MAX ) Plib::systemstate.config.max_tile_id = max_tile; } unsigned short max_tile = static_cast<unsigned short>( programArgsFindEquals( "maxtileid=", UOBJ_DEFAULT_MAX, true ) ); if ( max_tile == UOBJ_DEFAULT_MAX || max_tile == UOBJ_SA_MAX || max_tile == UOBJ_HSA_MAX ) Plib::systemstate.config.max_tile_id = max_tile; std::string main_cfg = "uoconvert.cfg"; if ( Clib::FileExists( main_cfg.c_str() ) ) { std::string temp; Clib::ConfigElem elem; INFO_PRINT << "Reading uoconvert.cfg.\n"; Clib::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 ); std::string graphicnum; while ( is_boats >> graphicnum ) UoConvert::BoatTypes.insert( strtoul( graphicnum.c_str(), NULL, 0 ) ); temp = elem.remove_string( "Houses" ); ISTRINGSTREAM is_houses( temp ); while ( is_houses >> graphicnum ) UoConvert::HouseTypes.insert( strtoul( graphicnum.c_str(), NULL, 0 ) ); temp = elem.remove_string( "Stairs" ); ISTRINGSTREAM is_stairs( temp ); while ( is_stairs >> graphicnum ) UoConvert::StairTypes.insert( strtoul( graphicnum.c_str(), NULL, 0 ) ); } else if ( elem.type_is( "LOSOptions" ) )