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

Method update

source/entities/Weapon.cpp:42–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 return weapon;
41}
42bool Weapon::update(Weapon* weapon, std::stringstream& defFile)
43{
44 std::string nextParam;
45 bool exit = false;
46 // Parameters that should not be overriden if a Creature definition is extended. They will be set after
47 // the class is copied if there is a base class
48 std::string name = weapon->mName;
49 std::string baseDefinition;
50 while (defFile.good())
51 {
52 if (exit)
53 break;
54
55 if(!(defFile >> nextParam))
56 break;
57
58 if (nextParam == "[/Equipment]" || nextParam == "[/EquipmentDefinitions]")
59 break;
60
61 if (nextParam == "Name")
62 {
63 defFile >> name;
64 continue;
65 }
66
67 if (nextParam == "BaseDefinition")
68 {
69 defFile >> baseDefinition;
70 const Weapon* def = ConfigManager::getSingleton().getWeapon(baseDefinition);
71 if(def == nullptr)
72 {
73 OD_LOG_ERR("Couldn't find base class " + baseDefinition);
74 return false;
75 }
76
77 *weapon = *def;
78 continue;
79 }
80
81 if (nextParam != "[Stats]")
82 continue;
83
84 while (defFile.good())
85 {
86 if (exit)
87 break;
88
89 if(!(defFile >> nextParam))
90 break;
91
92 if (nextParam == "[/Stats]")
93 break;
94
95 // Handle ill-formed files.
96 if (nextParam == "[/Equipment]" || nextParam == "[/EquipmentDefinitions]")
97 {
98 exit = true;
99 break;

Callers

nothing calls this directly

Calls 2

toDoubleFunction · 0.85
getWeaponMethod · 0.45

Tested by

no test coverage detected