From c57df2bd7ba96719438bbc34e1362f0f91622921 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sun, 17 Jan 2010 19:13:23 +0100 Subject: Removed last traces of hardcoded access levels form game-server, begun with using the permission manager in the account-server. --- src/game-server/commandhandler.cpp | 102 ++++++++----------------------------- 1 file changed, 20 insertions(+), 82 deletions(-) (limited to 'src/game-server/commandhandler.cpp') diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index 169e3221..5e582498 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -59,7 +59,6 @@ static void handleMoney(Character*, std::string&); static void handleSpawn(Character*, std::string&); static void handleAttribute(Character*, std::string&); static void handleReload(Character*, std::string&); -static void handleSetGroup(Character*, std::string&); static void handleGivePermission(Character*, std::string&); static void handleTakePermission(Character*, std::string&); static void handleAnnounce(Character*, std::string&); @@ -95,8 +94,6 @@ static CmdRef const cmdRef[] = "Changes the character attributes of a character", &handleAttribute}, {"reload", "", "Makes the server reload all configuration files", &handleReload}, - {"setgroup", " ", - "Changes the permission mask of the account the character belongs to", &handleSetGroup}, {"givepermission", " ", "Gives a permission class to the account a character belongs to", &handleGivePermission}, {"takepermission", " ", @@ -651,76 +648,6 @@ static void handleBan(Character *player, std::string &args) accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_BAN, msg); } -static void handleSetGroup(Character *player, std::string &args) -{ - Character *other; - int level = 0; - - // get the arguments - std::string character = getArgument(args); - std::string levelstr = getArgument(args); - - // check all arguments are there - if (character == "" || levelstr == "") - { - say("Invalid number of arguments given.", player); - say("Usage: @setgroup ", player); - return; - } - - // check if its to effect the player - if (character == "#") - { - other = player; - } - else - { - // check for valid player - other = getPlayer(character); - if (!other) - { - say("Invalid character", player); - return; - } - } - - // check which level they should be - // refer to defines.h for level info - if (levelstr == "AL_PLAYER") - { - level = AL_PLAYER; - } - else if (levelstr == "AL_TESTER") - { - level = AL_PLAYER | AL_TESTER; - } - else if (levelstr == "AL_GM") - { - level = AL_PLAYER | AL_TESTER | AL_GM; - } - else if (levelstr == "AL_DEV") - { - level = AL_PLAYER | AL_TESTER | AL_DEV; - } - else if (levelstr == "AL_ADMIN") - { - level = 255; - } - - if (level == 0) - { - say("Invalid group", player); - return; - } - - // change the player's account level - accountHandler->changeAccountLevel(other, level); - - // log transaction - std::string msg = "User changed account level of " + other->getName() + " to " + levelstr; - accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_SETGROUP, msg); -} - static void handleGivePermission(Character *player, std::string &args) { Character *other; @@ -756,6 +683,12 @@ static void handleGivePermission(Character *player, std::string &args) unsigned char permission = PermissionManager::getMaskFromAlias(strPermission); + if (permission == 0x00) + { + say ("Unknown permission class: "+strPermission, player); + return; + } + if (permission & other->getAccountLevel()) { say(player->getName()+" already has the permission "+strPermission, player); @@ -809,7 +742,7 @@ static void handleTakePermission(Character *player, std::string &args) if (permission == 0x00) { - say("Unknown permission class", player); + say("Unknown permission class: "+strPermission, player); return; } @@ -935,17 +868,22 @@ static void handleWhere(Character *player, std::string &args) static void handleRights(Character *player, std::string &args) { + std::listclasses; + classes = PermissionManager::getClassList(player); + std::stringstream str; str << "Your rights level is: " - << player->getAccountLevel() - << " (AL_PLAYER"; - if (player->getAccountLevel() & AL_TESTER) - str << ", AL_TESTER"; - if (player->getAccountLevel() & AL_GM) - str << ", AL_GM"; - if (player->getAccountLevel() & AL_ADMIN) - str << ", AL_ADMIN"; + << (unsigned int)player->getAccountLevel() + << " ( "; + + for (std::list::iterator i = classes.begin(); + i != classes.end(); + i++) + { + str << (*i) << " "; + } str << ")"; + say(str.str(), player); } -- cgit v1.2.3-70-g09d2