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_bannedips_config( bool initial_load) { if (!initial_load) { banned_ips.clear(); } if (!FileExists( "config/bannedips.cfg" )) return; ConfigFile cf( "config/bannedips.cfg" ); ConfigElem elem; while (cf.read( elem )) { IPRule CurrentEntry; string iptext = elem.remove_string( "IPMatch" ); string::size_type delim = iptext.find_first_of( "/" ); if (delim != string::npos) { string ipaddr_str = iptext.substr( 0, delim ); string ipmask_str = iptext.substr( delim+1 ); CurrentEntry.ipMatch = inet_addr( ipaddr_str.c_str() ); CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() ); banned_ips.push_back(CurrentEntry); } else { string ipmask_str = "255.255.255.255"; CurrentEntry.ipMatch = inet_addr( iptext.c_str() ); CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() ); banned_ips.push_back(CurrentEntry); } } }
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); } }
UOSkill::UOSkill( const Package* pkg, ConfigElem& elem ) : inited(true), skillid( strtoul( elem.rest(), NULL, 10 ) ), attributename(elem.remove_string( "Attribute", "" )), pAttr(NULL), pkg(pkg) { if (skillid < 0 || skillid >= 500) elem.throw_error( "SkillID must be < 500" ); if (!attributename.empty()) { bool required = false; if (attributename[0] == '+') { required = true; attributename = attributename.substr( 1, std::string::npos ); } pAttr = FindAttribute( attributename ); if (!pAttr) { if (required) { elem.throw_error( "Attribute " + tostring(attributename) + " not found." ); } else { elem.warn( "Attribute " + tostring(attributename) + " not found." ); } } } }
void CompilerConfig::Read( const string& path ) { ConfigFile cf( path.c_str() ); ConfigElem elem; cf.readraw( elem ); PackageRoot.clear(); IncludeDirectory.clear(); string tmp; while (elem.remove_prop( "PackageRoot", &tmp )) { PackageRoot.push_back( normalized_dir_form(tmp) ); } if (elem.remove_prop( "IncludeDirectory", &tmp )) { IncludeDirectory = normalized_dir_form(tmp); } ModuleDirectory = normalized_dir_form(elem.remove_string( "ModuleDirectory" )); PolScriptRoot = normalized_dir_form(elem.remove_string( "PolScriptRoot" )); GenerateListing = elem.remove_bool( "GenerateListing", false ); GenerateDebugInfo = elem.remove_bool( "GenerateDebugInfo", false ); GenerateDebugTextInfo = elem.remove_bool( "GenerateDebugTextInfo", false ); DisplayWarnings = elem.remove_bool( "DisplayWarnings", false ); CompileAspPages = elem.remove_bool( "CompileAspPages", false ); AutoCompileByDefault = elem.remove_bool( "AutoCompileByDefault", false ); UpdateOnlyOnAutoCompile = elem.remove_bool( "UpdateOnlyOnAutoCompile", false ); OnlyCompileUpdatedScripts = elem.remove_bool( "OnlyCompileUpdatedScripts", false ); DisplaySummary = elem.remove_bool( "DisplaySummary", false ); OptimizeObjectMembers = elem.remove_bool( "OptimizeObjectMembers", true); GenerateDependencyInfo = elem.remove_bool( "GenerateDependencyInfo", OnlyCompileUpdatedScripts ); ThreadedCompilation = elem.remove_bool( "ThreadedCompilation", false ); DisplayUpToDateScripts = elem.remove_bool( "DisplayUpToDateScripts", true ); // This is where we TRY to validate full paths from what was provided in the // ecompile.cfg. Maybe Turley or Shini can find the best way to do this in *nix. #ifdef WIN32 string MyPath = path.c_str(); // If it's just "ecompile.cfg", let's change it to the exe's path which it SHOULD be // with. if (stricmp(MyPath.c_str(), "ecompile.cfg") == 0) { // Let's find the NEXT-TO-LAST / in the path, and remove from there on. Oh yay! // To bad we can't just force everyone to use ABSOLUTE PATHS NANDO. :o MyPath = xmain_exedir.substr(0, xmain_exedir.length()-1); MyPath = MyPath.substr(0, MyPath.find_last_of( '/')+1); } if (IncludeDirectory.find(':') == string::npos) { if (IncludeDirectory.substr(0, 1) != ".") // Let's make sure they didn't try using this method { IncludeDirectory = MyPath + IncludeDirectory; } } if (ModuleDirectory.find(':') == string::npos) { if (ModuleDirectory.substr(0, 1) != ".") // Let's make sure they didn't try using this method { ModuleDirectory = MyPath + ModuleDirectory; } } if (PolScriptRoot.find(':') == string::npos) { if (PolScriptRoot.substr(0, 1) != ".") // Let's make sure they didn't try using this method { PolScriptRoot = MyPath + PolScriptRoot; } } for( unsigned pr = 0; pr < PackageRoot.size(); ++pr ) { if (PackageRoot[pr].find(':') == string::npos) { if (PackageRoot[pr].substr(0, 1) != ".") // Let's make sure they didn't try using this method { PackageRoot[pr] = MyPath + PackageRoot[pr]; } } } #endif }
int xmain( int argc, char* argv[] ) { StoreCmdArgs( argc, argv ); 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; if (argc <= 1) return Usage(1); if (argv[1][0] == '/' || argv[1][1] == ':') { config.uo_datafile_root = argv[1]; --argc; ++argv; } if (stricmp( argv[1], "tiledump" ) == 0) { return tiledump( argc, argv ); } else if (stricmp( argv[1], "vertile" ) == 0) { return vertile( argc, argv ); } else if (stricmp( argv[1], "verlandtile" ) == 0) { return verlandtile( argc, argv ); } else if (stricmp( argv[1], "landtilehist" ) == 0) { return landtilehist( argc, argv ); } else if (stricmp( argv[1], "flagsearch" ) == 0) { return flagsearch( argc, argv ); } else if (stricmp( argv[1], "landtileflagsearch" ) == 0) { return landtileflagsearch( argc, argv ); } else if (stricmp( argv[1], "loschange" ) == 0) { return loschange( argc, argv ); } else if (stricmp( argv[1], "rawdump" ) == 0) { return rawdump( argc, argv ); } else if (stricmp( argv[1], "ctable" ) == 0) { return print_ctable(); } else if (stricmp( argv[1], "sndlist" ) == 0) { return print_sndlist(argc, argv); } else if (stricmp( argv[1], "statics" ) == 0) { return print_statics(); } else if (stricmp( argv[1], "verdata" ) == 0) { return print_verdata_info(); } else if (stricmp( argv[1], "multis" ) == 0) { return print_multis(); } else if (stricmp( argv[1], "water" ) == 0) { return print_water_data(); } else if (stricmp( argv[1], "newstatics" ) == 0) { return write_pol_static_files( "main" ); } else if (stricmp( argv[1], "staticsmax" ) == 0) { void staticsmax(); open_uo_data_files(); staticsmax(); return 0; } else if (stricmp( argv[1], "watersearch" ) == 0) { return water_search(argc,argv); } else if (stricmp( argv[1], "zhist" ) == 0) { return z_histogram(); } else if (stricmp( argv[1], "staticshist" ) == 0) { return statics_histogram(); } else if (stricmp( argv[1], "writedungmap" ) == 0) { return write_polmap(); } else if (stricmp( argv[1], "writekeys" ) == 0) { printf( "Keys written to current.key" ); return 0; } else if (stricmp( argv[1], "mapdump" ) == 0) { return mapdump( argc, argv ); } else if (stricmp( argv[1], "contour" ) == 0) { return contour( argc, argv ); } else if (stricmp( argv[1], "findlandtile" ) == 0) { return findlandtile( argc-1, argv+1 ); } else if (stricmp( argv[1], "findlandtileflags" ) == 0) { return findlandtileflags( argc-1, argv+1 ); } else if (stricmp( argv[1], "findgraphic" ) == 0) { return findgraphic( argc-1, argv+1 ); } else if (stricmp( argv[1], "defragstatics" ) == 0) { return defragstatics( argc-1, argv+1 ); } return 0; }