MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / parseFromEntityDef

Method parseFromEntityDef

plugins/dm.difficulty/DifficultySettings.cpp:338–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338void DifficultySettings::parseFromEntityDef(const IEntityClassPtr& def)
339{
340 // Construct the prefix for the desired difficulty level
341 std::string diffPrefix = "diff_" + string::to_string(_level) + "_";
342 std::string prefix = diffPrefix + "change_";
343
344 eclass::AttributeList spawnargs = eclass::getSpawnargsWithPrefix(def, prefix);
345
346 for (eclass::AttributeList::iterator i = spawnargs.begin();
347 i != spawnargs.end(); ++i)
348 {
349 EntityClassAttribute& attr = *i;
350
351 if (attr.getValue().empty()) {
352 continue; // empty spawnarg attribute => invalid
353 }
354
355 // Get the index from the string's tail
356 std::string indexStr = attr.getName().substr(prefix.length());
357
358 SettingPtr setting = createSetting(
359 def->getAttributeValue(diffPrefix + "class_" + indexStr)
360 );
361 setting->spawnArg = attr.getValue();
362 setting->argument = def->getAttributeValue(diffPrefix + "arg_" + indexStr);
363
364 // This has been parsed from the default entityDef
365 setting->isDefault = true;
366
367 // Interpret/parse the argument string
368 setting->parseAppType();
369 }
370
371 clearTreeModel();
372 updateTreeModel();
373}
374
375void DifficultySettings::parseFromMapEntity(Entity* entity) {
376 // Construct the prefix for the desired difficulty level

Callers 1

loadDefaultSettingsMethod · 0.80

Calls 10

getSpawnargsWithPrefixFunction · 0.85
lengthMethod · 0.80
parseAppTypeMethod · 0.80
to_stringFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
getValueMethod · 0.45
getNameMethod · 0.45
getAttributeValueMethod · 0.45

Tested by

no test coverage detected