FileAccess::FileAccess( ConfigElem& elem ) : AllowWrite( elem.remove_bool( "AllowWrite", false ) ), AllowAppend( elem.remove_bool( "AllowAppend", false ) ), AllowRead( elem.remove_bool( "AllowRead", false ) ), AllowRemote( elem.remove_bool( "AllowRemote", false ) ), AllPackages( false ), AllDirectories( false ), AllExtensions( false ) { string tmp; while (elem.remove_prop( "Package", &tmp )) { if (tmp == "*") AllPackages = true; else Packages.insert( tmp ); } while (elem.remove_prop( "Directory", &tmp )) { if (tmp == "*") AllDirectories = true; else Directories.push_back( tmp ); } while (elem.remove_prop( "Extension", &tmp )) { if (tmp == "*") AllExtensions = true; else Extensions.push_back( tmp ); } }
void read_combat_config() { ConfigFile cf; ConfigElem elem; if (FileExists( "config/combat.cfg" )) { if ( config.loglevel > 1 ) { cout << "Loading combat.cfg options\n"; } cf.open( "config/combat.cfg" ); cf.readraw( elem ); } else if ( config.loglevel > 1 ) { cout << "File config/combat.cfg not found, skipping.\n"; } combat_config.display_parry_success_messages = elem.remove_bool("DisplayParrySuccessMessages", false); combat_config.warmode_inhibits_regen = elem.remove_bool("WarmodeInhibitsRegen", false); combat_config.attack_self = elem.remove_bool("SingleCombat", false); combat_config.warmode_delay = elem.remove_ulong("WarModeDelay", 1); combat_config.core_hit_sounds = elem.remove_bool("CoreHitSounds", false); combat_config.scripted_attack_checks = elem.remove_bool("ScriptedAttackChecks", false); combat_config.reset_swing_onturn = elem.remove_bool("ResetSwingOnTurn", false); combat_config.send_swing_packet = elem.remove_bool("SendSwingPacket", true); combat_config.send_damage_packet = elem.remove_bool("SendDamagePacket", false); combat_config.core_attack_effects = elem.remove_bool("CoreAttackEffects", true); }
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 }