summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-19 19:50:14 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-19 19:52:24 +0300
commitd6c4e13c4b2225572ac61edbc5311c84cbb19ef5 (patch)
treef8cda2563a9b8c45e57f0d78a33068524140c31a
parent06c100e280e7174095ce40745231f14326862010 (diff)
downloadplus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.tar.gz
plus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.tar.bz2
plus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.tar.xz
plus-d6c4e13c4b2225572ac61edbc5311c84cbb19ef5.zip
Load inherit commands in groupdb from other group.
-rw-r--r--src/resources/db/groupdb.cpp34
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);
}
}
}