From 7fc0338c3733aa0b5c216a440a856435a62cb8c6 Mon Sep 17 00:00:00 2001 From: MDIC Date: Fri, 29 Apr 2022 11:06:25 -0400 Subject: [PATCH] fix (commands): crash fix crash fix when using select gm cmds from console --- src/cs_anticheat.cpp | 67 +++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/src/cs_anticheat.cpp b/src/cs_anticheat.cpp index 17bfeba..f3fe0ef 100644 --- a/src/cs_anticheat.cpp +++ b/src/cs_anticheat.cpp @@ -155,39 +155,7 @@ public: return true; } - static bool HandleAntiCheatDeleteCommand(ChatHandler* handler, const char* args) - { - if (!sConfigMgr->GetOption("Anticheat.Enabled", 0)) - return false; - - std::string strCommand; - - char* command = strtok((char*)args, " "); // get entered name - - if (!command) - return true; - - strCommand = command; - - if (strCommand.compare("deleteall") == 0) - sAnticheatMgr->AnticheatDeleteCommand(ObjectGuid::Empty); - else - { - normalizePlayerName(strCommand); - Player* player = ObjectAccessor::FindPlayerByName(strCommand.c_str()); // get player by name - if (!player) - handler->PSendSysMessage("Player doesn't exist"); - else - { - sAnticheatMgr->AnticheatDeleteCommand(player->GetGUID()); - handler->PSendSysMessage("Anticheat Reports deleted for player {}", player->GetName().c_str()); - } - } - - return true; - } - - static bool HandleAntiCheatPlayerCommand(ChatHandler* handler, Optional player) + static bool HandleAntiCheatDeleteCommand(ChatHandler* handler, Optional player) { if (!sConfigMgr->GetOption("Anticheat.Enabled", 0)) return false; @@ -200,9 +168,28 @@ public: handler->SetSentErrorMessage(true); return false; } + sAnticheatMgr->AnticheatDeleteCommand(player->GetGUID()); + handler->PSendSysMessage("Anticheat Reports deleted for player %s", player->GetName().c_str()); + sAnticheatMgr->AnticheatDeleteCommand(player->GetGUID());// deletes auto reports on player + return true; + } + + static bool HandleAntiCheatPlayerCommand(ChatHandler* handler, Optional player) + { + if (!sConfigMgr->GetOption("Anticheat.Enabled", 0)) + return false; ObjectGuid guid; + if (!player) + player = PlayerIdentifier::FromTarget(handler); + if (!player) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + float average = sAnticheatMgr->GetAverage(guid); uint32 total_reports = sAnticheatMgr->GetTotalReports(guid); uint32 speed_reports = sAnticheatMgr->GetTypeReports(guid, 0); @@ -214,14 +201,12 @@ public: uint32 teleport_reports = sAnticheatMgr->GetTypeReports(guid, 6); uint32 ignorecontrol_reports = sAnticheatMgr->GetTypeReports(guid, 7); uint32 zaxis_reports = sAnticheatMgr->GetTypeReports(guid, 8); - - handler->PSendSysMessage("Information about player {}", player->GetName().c_str()); - handler->PSendSysMessage("Average: {} || Total Reports: {} ", average, total_reports); - handler->PSendSysMessage("Speed Reports: {} || Fly Reports: {} || Jump Reports: {} ", speed_reports, fly_reports, jump_reports); - handler->PSendSysMessage("Walk On Water Reports: {} || Teleport To Plane Reports: {}", waterwalk_reports, teleportplane_reports); - handler->PSendSysMessage("Teleport Reports: {} || Climb Reports: {}", teleport_reports, climb_reports); - handler->PSendSysMessage("Ignore Control Reports: {} || Ignore Z-Axis Reports: {}", ignorecontrol_reports, zaxis_reports); - + handler->PSendSysMessage("Information about player %s", player->GetName().c_str()); + handler->PSendSysMessage("Average: %f || Total Reports: %u ", average, total_reports); + handler->PSendSysMessage("Speed Reports: %u || Fly Reports: %u || Jump Reports: %u ", speed_reports, fly_reports, jump_reports); + handler->PSendSysMessage("Walk On Water Reports: %u || Teleport To Plane Reports: %u", waterwalk_reports, teleportplane_reports); + handler->PSendSysMessage("Teleport Reports: %u || Climb Reports: %u", teleport_reports, climb_reports); + handler->PSendSysMessage("Ignore Control Reports: %u || Ignore Z-Axis Reports: %u", ignorecontrol_reports, zaxis_reports); return true; }