diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-04 21:39:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-04 21:39:09 +0300 |
commit | a09b3062b06c400a0774f02ae1b784da5108f783 (patch) | |
tree | 861a14b37585ab73f4ee85d8e5ca27952869f31e | |
parent | 31fd786e7eb5097814eab4df03c32be354fb203d (diff) | |
download | manaplus-a09b3062b06c400a0774f02ae1b784da5108f783.tar.gz manaplus-a09b3062b06c400a0774f02ae1b784da5108f783.tar.bz2 manaplus-a09b3062b06c400a0774f02ae1b784da5108f783.tar.xz manaplus-a09b3062b06c400a0774f02ae1b784da5108f783.zip |
Add support for attr attributes in stats.xml
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/resources/db/statdb.cpp | 59 |
2 files changed, 45 insertions, 17 deletions
diff --git a/src/client.cpp b/src/client.cpp index 930446140..e9e1e96c6 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -41,6 +41,8 @@ #include "const/net/net.h" +#include "enums/being/attributesstrings.h" + #include "input/inputmanager.h" #include "input/joystick.h" #include "input/keyboardconfig.h" @@ -1321,6 +1323,7 @@ int Client::gameExec() delete spellShortcut; spellShortcut = new SpellShortcut; + AttributesEnum::init(); // Load XML databases CharDB::load(); StatDb::load(); diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp index 0e7175310..ac5aed781 100644 --- a/src/resources/db/statdb.cpp +++ b/src/resources/db/statdb.cpp @@ -22,6 +22,8 @@ #include "configuration.h" +#include "enums/being/attributesstrings.h" + #include "utils/checkutils.h" #include "resources/beingcommon.h" @@ -102,17 +104,29 @@ static void loadBasicStats(const XmlNodePtr rootNode) if (xmlNameEqual(node, "stat")) { const std::string name = XML::getProperty(node, "name", ""); - const int id = XML::getProperty(node, "id", 0); - if (id <= 0 || id >= maxAttr) + const std::string attr = XML::getProperty(node, "attr", ""); + if (attr.empty() || AttributesEnum::find(attr) == false) + { + const int id = XML::getProperty(node, "id", 0); + if (id <= 0 || id >= maxAttr) + { + reportAlways("Wrong attr or id for basic " + "stat with name %s", + name.c_str()); + continue; + } + const std::string tag = XML::getProperty(node, "tag", ""); + mBasicStats.push_back(BasicStat(static_cast<AttributesT>(id), + tag, + name)); + } + else { - reportAlways("Wrong id for basic stat with name %s", - name.c_str()); - continue; + const std::string tag = XML::getProperty(node, "tag", ""); + mBasicStats.push_back(BasicStat(AttributesEnum::get(attr), + tag, + name)); } - const std::string tag = XML::getProperty(node, "tag", ""); - mBasicStats.push_back(BasicStat(static_cast<AttributesT>(id), - tag, - name)); } } } @@ -128,16 +142,27 @@ static void loadStats(const XmlNodePtr rootNode, if (xmlNameEqual(node, "stat")) { const std::string name = XML::getProperty(node, "name", ""); - const int id = XML::getProperty(node, "id", 0); - if (id <= 0 || id >= maxAttr) + const std::string attr = XML::getProperty(node, "attr", ""); + if (attr.empty() || AttributesEnum::find(attr) == false) + { + const int id = XML::getProperty(node, "id", 0); + if (id <= 0 || id >= maxAttr) + { + reportAlways("Wrong attr or id for extended " + "stat with name %s", + name.c_str()); + continue; + } + stats.push_back(BasicStat(static_cast<AttributesT>(id), + std::string(), + name)); + } + else { - reportAlways("Wrong id for extended stat with name %s", - name.c_str()); - continue; + stats.push_back(BasicStat(AttributesEnum::get(attr), + std::string(), + name)); } - stats.push_back(BasicStat(static_cast<AttributesT>(id), - std::string(), - name)); } } } |