diff --git a/playerbot/strategy/actions/CheatAction.cpp b/playerbot/strategy/actions/CheatAction.cpp index 6c12b3dae..7c850cfab 100644 --- a/playerbot/strategy/actions/CheatAction.cpp +++ b/playerbot/strategy/actions/CheatAction.cpp @@ -7,48 +7,50 @@ using namespace ai; bool CheatAction::Execute(Event& event) { Player* requester = event.getOwner() ? event.getOwner() : GetMaster(); - std::string param = event.getParam(); - - uint32 cheatMask = (uint32)ai->GetCheat(); - - std::vector splitted = split(param, ','); - for (std::vector::iterator i = splitted.begin(); i != splitted.end(); i++) + if (requester && requester->GetSession()->GetSecurity() >= SEC_GAMEMASTER) { - const char* name = i->c_str(); - BotCheatMask newCheat = GetCheatMask(name + 1); - - switch (name[0]) + string param = event.getParam() + uint32 cheatMask = (uint32)ai->GetCheat(); + vector splitted = split(param, ','); + for (vector::iterator i = splitted.begin(); i != splitted.end(); i++) { - case '+': - AddCheat(newCheat); - cheatMask |= (uint32)newCheat; - break; - case '-': - RemCheat(newCheat); - cheatMask &= ~(uint32)newCheat; - break; - case '~': - if (ai->HasCheat(newCheat)) - RemCheat(newCheat); - else - AddCheat(newCheat); + const char* name = i->c_str(); + BotCheatMask newCheat = GetCheatMask(name + 1); - cheatMask ^= (uint32)newCheat; - break; - case '?': - ListCheats(requester); - return true; + switch (name[0]) + { + case '+': + AddCheat(newCheat); + cheatMask |= (uint32)newCheat; + break; + case '-': + RemCheat(newCheat); + cheatMask &= ~(uint32)newCheat; + break; + case '~': + if (ai->HasCheat(newCheat)) + RemCheat(newCheat); + else + AddCheat(newCheat); + + cheatMask ^= (uint32)newCheat; + break; + case '?': + ListCheats(requester); + return true; + } } - } - ai->SetCheat(BotCheatMask(cheatMask)); + ai->SetCheat(BotCheatMask(cheatMask)); + return true; + } - return true; + return false; } -BotCheatMask CheatAction::GetCheatMask(std::string cheat) +BotCheatMask CheatAction::GetCheatMask(string cheat) { - std::vector cheatName = { "taxi", "gold", "health", "mana", "power", "item", "cooldown", "repair", "movespeed", "attackspeed", "breath", "maxMask"}; + vector cheatName = { "taxi", "gold", "health", "mana", "power", "item", "cooldown", "repair", "movespeed", "attackspeed", "breath", "maxMask"}; for (int i = 0; i < log2((uint32)BotCheatMask::maxMask); i++) { if (cheatName[i] == cheat) @@ -58,15 +60,15 @@ BotCheatMask CheatAction::GetCheatMask(std::string cheat) return BotCheatMask::none; } -std::string CheatAction::GetCheatName(BotCheatMask cheatMask) +string CheatAction::GetCheatName(BotCheatMask cheatMask) { - std::vector cheatName = { "taxi", "gold", "health", "mana", "power", "item", "cooldown", "repair", "movespeed", "attackspeed", "breath", "maxMask" }; + vector cheatName = { "taxi", "gold", "health", "mana", "power", "item", "cooldown", "repair", "movespeed", "attackspeed", "breath", "maxMask" }; return cheatName[log2(((uint32)cheatMask))]; } void CheatAction::ListCheats(Player* requester) { - std::ostringstream out; + ostringstream out; for (int i = 0; i < log2((uint32)BotCheatMask::maxMask); i++) { BotCheatMask cheatMask = BotCheatMask(1 << i);