Skip to content

Commit

Permalink
Changed permission for bot cheat command
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Mar 8, 2024
1 parent be76514 commit 0d24a8c
Showing 1 changed file with 38 additions and 36 deletions.
74 changes: 38 additions & 36 deletions playerbot/strategy/actions/CheatAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> splitted = split(param, ',');
for (std::vector<std::string>::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<string> splitted = split(param, ',');
for (vector<string>::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<std::string> cheatName = { "taxi", "gold", "health", "mana", "power", "item", "cooldown", "repair", "movespeed", "attackspeed", "breath", "maxMask"};
vector<string> 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)
Expand All @@ -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<std::string> cheatName = { "taxi", "gold", "health", "mana", "power", "item", "cooldown", "repair", "movespeed", "attackspeed", "breath", "maxMask" };
vector<string> 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);
Expand Down

0 comments on commit 0d24a8c

Please sign in to comment.