aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2020-06-14 15:41:01 +0200
committerjackpoz <giacomopoz@gmail.com>2020-06-14 15:41:01 +0200
commitcd37a17103b88a56ec1fde2156c4325b74989e08 (patch)
treecae9a1eb9f6b8bea0262d460c64039f35bdab3ba
parent988fe4c86cc65a605a732ba94f9a7cd5337048f9 (diff)
Scripts/Commands: Add .debug objectcount <optional map id> chat command
Add .debug objectcount <optional map id> chat command to show the number of Creatures and GameObjects
-rw-r--r--sql/updates/world/3.3.5/2020_06_14_00_world.sql6
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp34
2 files changed, 40 insertions, 0 deletions
diff --git a/sql/updates/world/3.3.5/2020_06_14_00_world.sql b/sql/updates/world/3.3.5/2020_06_14_00_world.sql
new file mode 100644
index 00000000000..47a04e605ca
--- /dev/null
+++ b/sql/updates/world/3.3.5/2020_06_14_00_world.sql
@@ -0,0 +1,6 @@
+--
+DELETE FROM `command` WHERE `name`='debug objectcount';
+INSERT INTO `command` (`name`,`permission`,`help`) VALUES
+('debug objectcount',300,'Syntax: .debug objectcount <optional map id>
+Shows the number of Creatures and GameObjects for the specified map id or for all maps if none is specified
+');
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index a6ba2cc64a5..4eeae6a9075 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -120,6 +120,7 @@ public:
{ "dummy", rbac::RBAC_PERM_COMMAND_DEBUG_DUMMY, false, &HandleDebugDummyCommand, "" },
{ "asan", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, nullptr, "", debugAsanCommandTable },
{ "guidlimits", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugGuidLimitsCommand, "" },
+ { "objectcount", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugObjectCountCommand, "" },
{ "questreset", rbac::RBAC_PERM_COMMAND_DEBUG_QUESTRESET, true, &HandleDebugQuestResetCommand, "" }
};
static std::vector<ChatCommand> commandTable =
@@ -1944,6 +1945,39 @@ public:
map->GetId(), map->GetMapName(), map->GetInstanceId(), uint64(map->GetMaxLowGuid<HighGuid::Unit>()), uint64(map->GetMaxLowGuid<HighGuid::GameObject>()));
}
+ static bool HandleDebugObjectCountCommand(ChatHandler* handler, CommandArgs* args)
+ {
+ auto mapId = args->TryConsume<uint32>();
+ if (mapId)
+ {
+ sMapMgr->DoForAllMapsWithMapId(mapId.get(),
+ [handler](Map* map) -> void
+ {
+ HandleDebugObjectCountMap(handler, map);
+ }
+ );
+ }
+ else
+ {
+ sMapMgr->DoForAllMaps(
+ [handler](Map* map) -> void
+ {
+ HandleDebugObjectCountMap(handler, map);
+ }
+ );
+ }
+
+ return true;
+ }
+
+ static void HandleDebugObjectCountMap(ChatHandler* handler, Map* map)
+ {
+ handler->PSendSysMessage("Map Id: %u Name: '%s' Instance Id: %u Creatures: " UI64FMTD " GameObjects: " UI64FMTD,
+ map->GetId(), map->GetMapName(), map->GetInstanceId(),
+ uint64(map->GetObjectsStore().Size<Creature>()),
+ uint64(map->GetObjectsStore().Size<GameObject>()));
+ }
+
static bool HandleDebugDummyCommand(ChatHandler* handler, CommandArgs* /*args*/)
{
handler->SendSysMessage("This command does nothing right now. Edit your local core (cs_debug.cpp) to make it do whatever you need for testing.");