From 3363acba6f1e8e51937ae2e354a8086c5c56b8cd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 20 May 2018 06:11:17 +0300 Subject: Show gm revive button in death dialog if player have rights for @alive command. --- src/resources/db/groupdb.cpp | 30 ++++++++++++++++++++++++++++++ src/resources/db/groupdb.h | 3 +++ 2 files changed, 33 insertions(+) (limited to 'src/resources/db') 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 @@ -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 GroupInfos; typedef GroupInfos::iterator GroupInfosIter; -- cgit v1.2.3-60-g2f50