MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / loadFile

Method loadFile

src/Ruleset/Ruleset.cpp:214–497  ·  view source on GitHub ↗

* Loads a ruleset's contents from a YAML file. * Rules that match pre-existing rules overwrite them. * @param filename YAML filename. */

Source from the content-addressed store, hash-verified

212 * @param filename YAML filename.
213 */
214void Ruleset::loadFile(const std::string &filename)
215{
216 YAML::Node doc = YAML::LoadFile(filename);
217
218 for (YAML::const_iterator i = doc["countries"].begin(); i != doc["countries"].end(); ++i)
219 {
220 RuleCountry *rule = loadRule(*i, &_countries, &_countriesIndex);
221 if (rule != 0)
222 {
223 rule->load(*i);
224 }
225 }
226 for (YAML::const_iterator i = doc["regions"].begin(); i != doc["regions"].end(); ++i)
227 {
228 RuleRegion *rule = loadRule(*i, &_regions, &_regionsIndex);
229 if (rule != 0)
230 {
231 rule->load(*i);
232 }
233 }
234 for (YAML::const_iterator i = doc["facilities"].begin(); i != doc["facilities"].end(); ++i)
235 {
236 RuleBaseFacility *rule = loadRule(*i, &_facilities, &_facilitiesIndex);
237 if (rule != 0)
238 {
239 _facilityListOrder += 100;
240 rule->load(*i, _modIndex, _facilityListOrder);
241 }
242 }
243 for (YAML::const_iterator i = doc["crafts"].begin(); i != doc["crafts"].end(); ++i)
244 {
245 RuleCraft *rule = loadRule(*i, &_crafts, &_craftsIndex);
246 if (rule != 0)
247 {
248 _craftListOrder += 100;
249 rule->load(*i, this, _modIndex, _craftListOrder);
250 }
251 }
252 for (YAML::const_iterator i = doc["craftWeapons"].begin(); i != doc["craftWeapons"].end(); ++i)
253 {
254 RuleCraftWeapon *rule = loadRule(*i, &_craftWeapons, &_craftWeaponsIndex);
255 if (rule != 0)
256 {
257 rule->load(*i, _modIndex);
258 }
259 }
260 for (YAML::const_iterator i = doc["items"].begin(); i != doc["items"].end(); ++i)
261 {
262 RuleItem *rule = loadRule(*i, &_items, &_itemsIndex);
263 if (rule != 0)
264 {
265 _itemListOrder += 100;
266 rule->load(*i, _modIndex, _itemListOrder);
267 }
268 }
269 for (YAML::const_iterator i = doc["ufos"].begin(); i != doc["ufos"].end(); ++i)
270 {
271 RuleUfo *rule = loadRule(*i, &_ufos, &_ufosIndex);

Callers

nothing calls this directly

Calls 3

getPsiLaboratoriesMethod · 0.80
NodeClass · 0.50
loadMethod · 0.45

Tested by

no test coverage detected