bool ReconConfig::Load (CfgList *rootcfg) { CfgList *rinfo = dynamic_cast<CfgList*> (rootcfg->GetValue ("reconinfo")); if (rinfo) { scouts = dynamic_cast<CfgBuildOptions*> (rinfo->GetValue ("scouts")); if (scouts) { scouts->InitIDs (); } updateInterval = rinfo->GetInt ("updateinterval", 4); maxForce = rinfo->GetInt ("maxforce", 5); minMetal = rinfo->GetNumeric ("minmetal"); minEnergy = rinfo->GetNumeric ("minenergy"); CfgList* hcfg = dynamic_cast<CfgList*> (rinfo->GetValue ("SearchHeuristic")); if (hcfg) { searchHeuristic.DistanceFactor = hcfg->GetNumeric ("DistanceFactor"); searchHeuristic.ThreatFactor = hcfg->GetNumeric ("ThreatFactor"); searchHeuristic.TimeFactor = hcfg->GetNumeric ("TimeFactor"); searchHeuristic.SpreadFactor = hcfg->GetNumeric ("SpreadFactor"); } else { logPrintf ("Error: No search heuristic info in recon config node.\n"); return false; } return true; } return false; }
bool AIConfig::Load (const char *file, IGlobalAICallback *cb) { CfgList *info = 0; root = CfgValue::LoadFile (file); if (root) info = dynamic_cast<CfgList*> (root->GetValue ("info")); if (info) { infoblocksize=info->GetInt ("infoblocksize", -1); if (infoblocksize < 8) { ChatMsgPrintf (cb->GetAICallback(), "AIConfig: invalid infoblocksize: %d\n", infoblocksize); return false; } debug = info->GetInt ("debug",0)!=0; showDebugWindow = info->GetInt ("showdebugwindow",0) != 0; showMetalSpots=info->GetInt ("showmetalspots", 0)!=0; safeSectorRadius = info->GetInt ("safesectorradius", 15); mexSectorRadius = info->GetInt ("mexsectorradius", 15); cacheBuildTable = !!info->GetInt ("cachebuildtable", 1); builderMoveTimeout = info->GetInt ("buildermovetimeout", 200); builderMoveMinDistance = info->GetNumeric("buildermovemindistance", 100); threatDecay = info->GetNumeric ("threatdecay", 0.1f); } else { ChatMsgPrintf (cb->GetAICallback(), "Error: Unable to read configuration file %s. Aborting global AI.\n", file); return false; } return true; }
bool BuildHandlerConfig::Load(CfgList *sidecfg) { assert (NUM_TASK_TYPES == 4); float sum = 0.0f; CfgList* cfg = modConfig.root; CfgList *weights = dynamic_cast<CfgList*>(cfg->GetValue ("BuildWeights")); CfgList *maxtasks = dynamic_cast<CfgList*>(cfg->GetValue ("MaxTasks")); for (int a=0;a<NUM_TASK_TYPES;a++) { BuildWeights[a] = weights ? weights->GetNumeric (handlerStr[a], 1.0f) : 1.0f; MaxTasks[a] = maxtasks ? maxtasks->GetInt (handlerStr[a], 1) : 1; sum += BuildWeights[a]; } for (int a=0;a<NUM_TASK_TYPES;a++) BuildWeights[a] /= sum; logPrintf ("Building weights: Resources=%f, Forces=%f, Defenses=%f\n", BuildWeights [0], BuildWeights[1], BuildWeights [2]); BuildSpeedPerMetalIncome = cfg->GetNumeric ("BuildSpeedPerMetalIncome", 33); InitialOrders = dynamic_cast<CfgBuildOptions*>(sidecfg->GetValue("InitialBuildOrders")); if (InitialOrders) InitialOrders->InitIDs(); return true; }
void EditorViewWindow::Serialize(CfgList& cfg, bool store) { ViewWindow::Serialize (cfg, store); Camera::CtlMode& camCtlMode=cam.ctlmode; if (store) { CFG_STOREN(cfg,mode); CFG_STOREN(cfg,rendermode); cfg.AddNumeric ("camCtlMode", (int)camCtlMode); CFG_STORE(cfg, bDrawCenters); CFG_STORE(cfg, bCullFaces); CFG_STORE(cfg, bLighting); CFG_STORE(cfg, bHideGrid); CFG_STORE(cfg, bDrawRadius); } else { CFG_LOADN(cfg,mode); SetMode(mode); CFG_LOADN(cfg,rendermode); camCtlMode=(Camera::CtlMode)cfg.GetInt ("camCtlMode",0); CFG_LOAD(cfg, bDrawCenters); CFG_LOAD(cfg, bCullFaces); CFG_LOAD(cfg, bLighting); CFG_LOAD(cfg, bHideGrid); CFG_LOAD(cfg, bDrawRadius); } }