diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-05-20 06:11:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-05-20 06:11:17 +0300 |
commit | 3363acba6f1e8e51937ae2e354a8086c5c56b8cd (patch) | |
tree | cc2429241a3e7cba7a90ba1ae1b76e0abf8e5345 /src/resources/db | |
parent | 1f5ca54b8f60e112c2043160700055290c8ce912 (diff) | |
download | manaverse-3363acba6f1e8e51937ae2e354a8086c5c56b8cd.tar.gz manaverse-3363acba6f1e8e51937ae2e354a8086c5c56b8cd.tar.bz2 manaverse-3363acba6f1e8e51937ae2e354a8086c5c56b8cd.tar.xz manaverse-3363acba6f1e8e51937ae2e354a8086c5c56b8cd.zip |
Show gm revive button in death dialog if player have rights for @alive command.
Diffstat (limited to 'src/resources/db')
-rw-r--r-- | src/resources/db/groupdb.cpp | 30 | ||||
-rw-r--r-- | src/resources/db/groupdb.h | 3 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/resources/db/groupdb.cpp b/src/resources/db/groupdb.cpp index 1d1d1bffa..d8dc1117f 100644 --- a/src/resources/db/groupdb.cpp +++ b/src/resources/db/groupdb.cpp @@ -22,6 +22,10 @@ #include "configuration.h" +#include "being/localplayer.h" + +#include "net/net.h" + #include "utils/checkutils.h" #include "resources/beingcommon.h" @@ -400,6 +404,32 @@ const GroupInfo *GroupDb::getGroup(const int id) return (*it).second; } +bool GroupDb::isAllowCommand(const ServerCommandTypeT command) +{ + const int groupId = localPlayer->getGroupId(); + const GroupInfo *const group = GroupDb::getGroup(groupId); + if (group == nullptr) + return false; + +#ifdef TMWA_SUPPORT + // allow any commands for legacy if group > 0 + if (Net::getNetworkType() == ServerType::TMWATHENA && + localPlayer != nullptr && + localPlayer->isGM()) + { + return true; + } +#endif + if (group->mPermissions[CAST_SIZE(ServerPermissionType::all_commands)] == + Enable_true) + { + return true; + } + const ServerCommandEnable::Type enabled = + group->mCommands[CAST_SIZE(command)]; + return (enabled & ServerCommandEnable::Self) != 0; +} + #ifdef UNITTESTS GroupDb::GroupInfos &GroupDb::getGroups() { diff --git a/src/resources/db/groupdb.h b/src/resources/db/groupdb.h index f447baa96..19a186911 100644 --- a/src/resources/db/groupdb.h +++ b/src/resources/db/groupdb.h @@ -21,6 +21,8 @@ #ifndef RESOURCES_DB_GROUPDB_H #define RESOURCES_DB_GROUPDB_H +#include "enums/resources/servercommandtype.h" + #include "enums/simpletypes/skiperror.h" #include <map> @@ -44,6 +46,7 @@ namespace GroupDb bool getHighlightName(const int id) A_WARN_UNUSED; const std::string &getBadge(const int id) A_WARN_UNUSED; const GroupInfo *getGroup(const int id) A_WARN_UNUSED RETURNS_NONNULL; + bool isAllowCommand(const ServerCommandTypeT command); typedef std::map<int, GroupInfo*> GroupInfos; typedef GroupInfos::iterator GroupInfosIter; |