diff options
| author | Takenbacon <revoke1336@live.com> | 2025-09-07 04:02:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-07 08:02:03 -0300 |
| commit | a28824df85040e68f35938c3e085f0f107c84ef5 (patch) | |
| tree | 220177010140f8bb8710f2433da76f79e8ee5186 /src/server/scripts/Commands | |
| parent | d55851c513df8a337e2c77719003324cc3c51b69 (diff) | |
feat(Core/Visibility): Far visibility worldobjects (#22828)
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index a18e01e0bd..40bb89b93b 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -99,7 +99,8 @@ public: { "objectcount", HandleDebugObjectCountCommand, SEC_ADMINISTRATOR, Console::Yes}, { "dummy", HandleDebugDummyCommand, SEC_ADMINISTRATOR, Console::No }, { "mapdata", HandleDebugMapDataCommand, SEC_ADMINISTRATOR, Console::No }, - { "boundary", HandleDebugBoundaryCommand, SEC_ADMINISTRATOR, Console::No } + { "boundary", HandleDebugBoundaryCommand, SEC_ADMINISTRATOR, Console::No }, + { "visibilitydata", HandleDebugVisibilityDataCommand, SEC_ADMINISTRATOR, Console::No } }; static ChatCommandTable commandTable = { @@ -1403,6 +1404,36 @@ public: return true; } + + static bool HandleDebugVisibilityDataCommand(ChatHandler* handler) + { + Player* player = handler->GetPlayer(); + if (!player) + return false; + + std::array<uint32, NUM_CLIENT_OBJECT_TYPES> objectByTypeCount = {}; + + ObjectVisibilityContainer const& objectVisibilityContainer = player->GetObjectVisibilityContainer(); + for (auto const& kvPair : *objectVisibilityContainer.GetVisibleWorldObjectsMap()) + { + WorldObject const* obj = kvPair.second; + ++objectByTypeCount[obj->GetTypeId()]; + } + + uint32 zoneWideVisibleObjectsInZone = 0; + if (ZoneWideVisibleWorldObjectsSet const* farVisibleSet = player->GetMap()->GetZoneWideVisibleWorldObjectsForZone(player->GetZoneId())) + zoneWideVisibleObjectsInZone = farVisibleSet->size(); + + handler->PSendSysMessage("Visibility Range: {}", player->GetVisibilityRange()); + handler->PSendSysMessage("Visible Creatures: {}", objectByTypeCount[TYPEID_UNIT]); + handler->PSendSysMessage("Visible Players: {}", objectByTypeCount[TYPEID_PLAYER]); + handler->PSendSysMessage("Visible GameObjects: {}", objectByTypeCount[TYPEID_GAMEOBJECT]); + handler->PSendSysMessage("Visible DynamicObjects: {}", objectByTypeCount[TYPEID_DYNAMICOBJECT]); + handler->PSendSysMessage("Visible Corpses: {}", objectByTypeCount[TYPEID_CORPSE]); + handler->PSendSysMessage("Players we are visible to: {}", objectVisibilityContainer.GetVisiblePlayersMap().size()); + handler->PSendSysMessage("Zone wide visible objects in zone: {}", zoneWideVisibleObjectsInZone); + return true; + } }; void AddSC_debug_commandscript() |
