diff options
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index ca4dd814e01..570f4587ae8 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -35,8 +35,10 @@ EndScriptData */ #include "Language.h" #include "MapManager.h" #include "M2Stores.h" +#include "BattlefieldMgr.h" #include <fstream> +#include <limits> class debug_commandscript : public CommandScript { @@ -95,7 +97,8 @@ public: { "transport", rbac::RBAC_PERM_COMMAND_DEBUG_TRANSPORT, false, &HandleDebugTransportCommand, "" }, { "loadcells", rbac::RBAC_PERM_COMMAND_DEBUG_LOADCELLS, false, &HandleDebugLoadCellsCommand, "" }, { "boundary", rbac::RBAC_PERM_COMMAND_DEBUG_BOUNDARY, false, &HandleDebugBoundaryCommand, "" }, - { "raidreset", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleDebugRaidResetCommand, "" } + { "raidreset", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleDebugRaidResetCommand, "" }, + { "neargraveyard", rbac::RBAC_PERM_COMMAND_NEARGRAVEYARD, false, &HandleDebugNearGraveyard, "" }, }; static std::vector<ChatCommand> commandTable = { @@ -1485,6 +1488,53 @@ public: sInstanceSaveMgr->ForceGlobalReset(mEntry->MapID, Difficulty(difficulty)); return true; } + + static bool HandleDebugNearGraveyard(ChatHandler* handler, char const* args) + { + Player* player = handler->GetSession()->GetPlayer(); + const WorldSafeLocsEntry* nearestLoc = nullptr; + + if (stricmp(args, "linked")) + { + if (Battleground* bg = player->GetBattleground()) + nearestLoc = bg->GetClosestGraveYard(player); + else + { + if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId())) + nearestLoc = bf->GetClosestGraveYard(player); + else + nearestLoc = sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam()); + } + } + else + { + float x = player->GetPositionX(); + float y = player->GetPositionY(); + float z = player->GetPositionZ(); + float distNearest = std::numeric_limits<float>::max(); + + for (uint32 i = 0; i < sWorldSafeLocsStore.GetNumRows(); ++i) + { + const WorldSafeLocsEntry* loc = sWorldSafeLocsStore.LookupEntry(i); + if (loc && loc->map_id == player->GetMapId()) + { + float dist = (loc->x - x) * (loc->x - x) + (loc->y - y) * (loc->y - y) + (loc->z - z) * (loc->z - z); + if (dist < distNearest) + { + distNearest = dist; + nearestLoc = loc; + } + } + } + } + + if (nearestLoc) + handler->PSendSysMessage(LANG_COMMAND_NEARGRAVEYARD, nearestLoc->ID, nearestLoc->x, nearestLoc->y, nearestLoc->z); + else + handler->PSendSysMessage(LANG_COMMAND_NEARGRAVEYARD_NOTFOUND); + + return true; + } }; void AddSC_debug_commandscript() |
