diff options
Diffstat (limited to 'src/resources/db/groupdb.cpp')
-rw-r--r-- | src/resources/db/groupdb.cpp | 30 |
1 files changed, 30 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() { |