summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-13 20:50:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-13 20:50:34 +0300
commit5525260f78c1fcab1887cdc95ebcc6790fb34b5b (patch)
treebd8ee201beef1fc3bbbe48890f9695b6c39c874b
parent1f72c8a3f380325f5f4a82137f8bac02362916df (diff)
downloadmanaverse-5525260f78c1fcab1887cdc95ebcc6790fb34b5b.tar.gz
manaverse-5525260f78c1fcab1887cdc95ebcc6790fb34b5b.tar.bz2
manaverse-5525260f78c1fcab1887cdc95ebcc6790fb34b5b.tar.xz
manaverse-5525260f78c1fcab1887cdc95ebcc6790fb34b5b.zip
Allow use different badges for each group in groups.xml
-rw-r--r--src/being/being.cpp2
-rw-r--r--src/resources/db/groupdb.cpp14
-rw-r--r--src/resources/db/groupdb.h7
-rw-r--r--src/resources/groupinfo.h2
4 files changed, 21 insertions, 4 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 147be14a4..56f22a1d5 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -3504,7 +3504,7 @@ void Being::showGmBadge(const bool show) restrict2
mShowBadges != 0u &&
GroupDb::getShowBadge(mGroupId))
{
- const std::string gmBadge = paths.getStringValue("gmbadge");
+ const std::string gmBadge = GroupDb::getBadge(mGroupId);
if (!gmBadge.empty())
{
mBadges[BadgeIndex::Gm] = AnimatedSprite::load(
diff --git a/src/resources/db/groupdb.cpp b/src/resources/db/groupdb.cpp
index c65406841..bd78e117c 100644
--- a/src/resources/db/groupdb.cpp
+++ b/src/resources/db/groupdb.cpp
@@ -96,6 +96,9 @@ void GroupDb::loadXmlFile(const std::string &fileName,
mGroups[id].longName = XML::langProperty(node,
"longName",
"");
+ mGroups[id].badge = XML::langProperty(node,
+ "badge",
+ paths.getStringValue("gmbadge"));
mGroups[id].showBadge = XML::getBoolProperty(node,
"showBadge",
false);
@@ -142,6 +145,17 @@ bool GroupDb::getShowBadge(const int id)
return (*it).second.showBadge;
}
+const std::string &GroupDb::getBadge(const int id)
+{
+ GroupInfos::const_iterator it = mGroups.find(id);
+ if (it == mGroups.end())
+ {
+ reportAlways("Unknown group id requested: %d", id);
+ return mEmptyGroup.badge;
+ }
+ return (*it).second.badge;
+}
+
#ifdef UNITTESTS
GroupDb::GroupInfos &GroupDb::getGroups()
{
diff --git a/src/resources/db/groupdb.h b/src/resources/db/groupdb.h
index 4e687dea9..3db3b1921 100644
--- a/src/resources/db/groupdb.h
+++ b/src/resources/db/groupdb.h
@@ -38,9 +38,10 @@ namespace GroupDb
void loadXmlFile(const std::string &fileName,
const SkipError skipError);
- const std::string &getName(const int id);
- const std::string &getLongName(const int id);
- bool getShowBadge(const int id);
+ const std::string &getName(const int id) A_WARN_UNUSED;
+ const std::string &getLongName(const int id) A_WARN_UNUSED;
+ bool getShowBadge(const int id) A_WARN_UNUSED;
+ const std::string &getBadge(const int id) A_WARN_UNUSED;
typedef std::map<int, GroupInfo> GroupInfos;
diff --git a/src/resources/groupinfo.h b/src/resources/groupinfo.h
index 59a79a9bd..973249d19 100644
--- a/src/resources/groupinfo.h
+++ b/src/resources/groupinfo.h
@@ -30,6 +30,7 @@ struct GroupInfo final
GroupInfo() :
name(),
longName(),
+ badge(),
showBadge(false)
{ }
@@ -37,6 +38,7 @@ struct GroupInfo final
std::string name;
std::string longName;
+ std::string badge;
bool showBadge;
};