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

Method parseFromMapEntity

plugins/dm.difficulty/DifficultySettings.cpp:375–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375void DifficultySettings::parseFromMapEntity(Entity* entity) {
376 // Construct the prefix for the desired difficulty level
377 std::string diffPrefix = "diff_" + string::to_string(_level) + "_";
378 std::string prefix = diffPrefix + "change_";
379
380 Entity::KeyValuePairs spawnargs = entity->getKeyValuePairs(prefix);
381
382 for (Entity::KeyValuePairs::iterator i = spawnargs.begin();
383 i != spawnargs.end(); ++i)
384 {
385 const std::string& key = i->first;
386 const std::string& value = i->second;
387
388 if (value.empty()) {
389 continue; // empty spawnarg attribute => invalid
390 }
391
392 // Get the index from the string's tail
393 std::string indexStr = key.substr(prefix.length());
394
395 std::string className = entity->getKeyValue(diffPrefix + "class_" + indexStr);
396 SettingPtr setting = createSetting(className);
397 setting->spawnArg = value;
398 setting->argument = entity->getKeyValue(diffPrefix + "arg_" + indexStr);
399
400 // This has been parsed from the default entityDef
401 setting->isDefault = false;
402
403 // Interpret/parse the argument string
404 setting->parseAppType();
405 }
406
407 clearTreeModel();
408 updateTreeModel();
409}
410
411void DifficultySettings::saveToEntity(DifficultyEntity& target)
412{

Callers 1

loadMapSettingsMethod · 0.80

Calls 8

lengthMethod · 0.80
parseAppTypeMethod · 0.80
to_stringFunction · 0.50
getKeyValuePairsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
getKeyValueMethod · 0.45

Tested by

no test coverage detected