| 336 | } |
| 337 | |
| 338 | void 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 | |
| 375 | void DifficultySettings::parseFromMapEntity(Entity* entity) { |
| 376 | // Construct the prefix for the desired difficulty level |
no test coverage detected