diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-07-19 19:50:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-07-19 19:52:24 +0300 |
commit | d6c4e13c4b2225572ac61edbc5311c84cbb19ef5 (patch) | |
tree | f8cda2563a9b8c45e57f0d78a33068524140c31a /src/resources | |
parent | 06c100e280e7174095ce40745231f14326862010 (diff) | |
download | manaplus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.tar.gz manaplus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.tar.bz2 manaplus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.tar.xz manaplus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.zip |
Load inherit commands in groupdb from other group.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/groupdb.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/resources/db/groupdb.cpp b/src/resources/db/groupdb.cpp index f3e2852e0..d75a5f29d 100644 --- a/src/resources/db/groupdb.cpp +++ b/src/resources/db/groupdb.cpp @@ -144,6 +144,39 @@ static void loadSubNodes(XmlNodePtr groupNode, } } +static void parseInherit(XmlNodePtr groupNode, + const int id, + GroupInfo *groupInfo) A_NONNULL(3); +static void parseInherit(XmlNodePtr groupNode, + const int id, + GroupInfo *groupInfo) +{ + const std::string inherit = XML::langProperty(groupNode, + "inherit", + ""); + STD_VECTOR<int> parts; + splitToIntVector(parts, inherit, ','); + FOR_EACH (STD_VECTOR<int>::const_iterator, it, parts) + { + const int id2 = *it; + GroupDb::GroupInfos::const_iterator it2 = mGroups.find(id2); + if (it2 == mGroups.end()) + { + reportAlways("Unknown inherit group id '%d' in group '%d'", + id2, + id); + continue; + } + GroupInfo *const groupInfo2 = (*it2).second; + for (size_t f = 0; f < CAST_SIZE(ServerCommandType::Max); f ++) + { + ServerCommandEnable::Type enable = groupInfo2->mCommands[f]; + if (enable != ServerCommandEnable::No) + groupInfo->mCommands[f] = enable; + } + } +} + void GroupDb::loadXmlFile(const std::string &fileName, const SkipError skipError) { @@ -213,6 +246,7 @@ void GroupDb::loadXmlFile(const std::string &fileName, "showBadge", false); loadSubNodes(node, id, group); + parseInherit(node, id, group); } } } |