Core/Commands: Add .debug guidlimits <optional map id> chat command

Add .debug guidlimits <optional map id> chat command to show the highest low guid counter for Creature and GameObject, useful when reaching Respawn.GuidWarnLevel

(cherry picked from commit 7421ccaf7e)
This commit is contained in:
jackpoz
2019-07-13 18:15:39 +02:00
committed by Shauren
parent 1e84edde39
commit e7b94603f2
3 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
--
DELETE FROM `command` WHERE `name`='debug guidlimits';
INSERT INTO `command` (`name`,`permission`,`help`) VALUES
('debug guidlimits',300,'Syntax: .debug guidlimits <optional map id>
Shows the current Creature and GameObject highest Guid for the specified map id or for all maps if none is specified
');

View File

@@ -568,6 +568,13 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
return GetGuidSequenceGenerator<high>().Generate();
}
template<HighGuid high>
inline ObjectGuid::LowType GetMaxLowGuid()
{
static_assert(ObjectGuidTraits<high>::SequenceSource.HasFlag(ObjectGuidSequenceSource::Map), "Only map specific guid can be retrieved in Map context");
return GetGuidSequenceGenerator<high>().GetNextAfterMaxUsed();
}
void AddUpdateObject(Object* obj)
{
_updateObjects.insert(obj);

View File

@@ -122,6 +122,7 @@ public:
{ "wsexpression" , rbac::RBAC_PERM_COMMAND_DEBUG, false, &HandleDebugWSExpressionCommand, "" },
{ "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, "" },
};
static std::vector<ChatCommand> commandTable =
{
@@ -1723,6 +1724,39 @@ public:
return true;
}
static bool HandleDebugGuidLimitsCommand(ChatHandler* handler, CommandArgs* args)
{
auto mapId = args->TryConsume<uint32>();
if (mapId)
{
sMapMgr->DoForAllMapsWithMapId(mapId.get(),
[handler](Map* map) -> void
{
HandleDebugGuidLimitsMap(handler, map);
}
);
}
else
{
sMapMgr->DoForAllMaps(
[handler](Map* map) -> void
{
HandleDebugGuidLimitsMap(handler, map);
}
);
}
handler->PSendSysMessage("Guid Warn Level: %u", sWorld->getIntConfig(CONFIG_RESPAWN_GUIDWARNLEVEL));
handler->PSendSysMessage("Guid Alert Level: %u", sWorld->getIntConfig(CONFIG_RESPAWN_GUIDALERTLEVEL));
return true;
}
static void HandleDebugGuidLimitsMap(ChatHandler* handler, Map* map)
{
handler->PSendSysMessage("Map Id: %u Name: '%s' Instance Id: %u Highest Guid Creature: " UI64FMTD " GameObject: " UI64FMTD,
map->GetId(), map->GetMapName(), map->GetInstanceId(), uint64(map->GenerateLowGuid<HighGuid::Creature>()), uint64(map->GetMaxLowGuid<HighGuid::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.");