MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / getWeaponForTuning

Method getWeaponForTuning

source/gamemap/GameMap.cpp:447–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447Weapon* GameMap::getWeaponForTuning(const std::string& name)
448{
449 for (std::pair<const Weapon*,Weapon*>& def : mWeapons)
450 {
451 if(def.second != nullptr)
452 {
453 if (def.second->getName().compare(name) == 0)
454 return def.second;
455 }
456 else if(def.first->getName().compare(name) == 0)
457 {
458 // If the definition is not a copy, we make one because we want to keep the original so we are able
459 // to save the changes if the map is saved
460 def.second = new Weapon(*def.first);
461 return def.second;
462 }
463 }
464
465 // It is a new definition
466 Weapon* def = new Weapon(name);
467 mWeapons.push_back(std::pair<const Weapon*,Weapon*>(nullptr, def));
468 return def;
469}
470
471uint32_t GameMap::numWeapons()
472{

Callers 1

readGameMapFromFileFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected