From d6c4e13c4b2225572ac61edbc5311c84cbb19ef5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 19 Jul 2017 19:50:14 +0300 Subject: Load inherit commands in groupdb from other group. --- src/resources/db/groupdb.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src') 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 parts; + splitToIntVector(parts, inherit, ','); + FOR_EACH (STD_VECTOR::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); } } } -- cgit v1.2.3-70-g09d2