mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 23:26:23 +00:00
Merge branch 'azerothcore:master' into Playerbot
This commit is contained in:
@@ -103,6 +103,7 @@ public:
|
||||
{ "los", HandleDebugLoSCommand, SEC_ADMINISTRATOR, Console::No },
|
||||
{ "moveflags", HandleDebugMoveflagsCommand, SEC_ADMINISTRATOR, Console::No },
|
||||
{ "unitstate", HandleDebugUnitStateCommand, SEC_ADMINISTRATOR, Console::No },
|
||||
{ "objectcount", HandleDebugObjectCountCommand, SEC_ADMINISTRATOR, Console::Yes},
|
||||
{ "dummy", HandleDebugDummyCommand, SEC_ADMINISTRATOR, Console::No }
|
||||
};
|
||||
static ChatCommandTable commandTable =
|
||||
@@ -1244,6 +1245,84 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugObjectCountCommand(ChatHandler* handler, Optional<uint32> mapId)
|
||||
{
|
||||
if (mapId)
|
||||
{
|
||||
sMapMgr->DoForAllMapsWithMapId(mapId.value(),
|
||||
[handler](Map* map) -> void
|
||||
{
|
||||
HandleDebugObjectCountMap(handler, map);
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
sMapMgr->DoForAllMaps(
|
||||
[handler](Map* map) -> void
|
||||
{
|
||||
HandleDebugObjectCountMap(handler, map);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class CreatureCountWorker
|
||||
{
|
||||
public:
|
||||
CreatureCountWorker() { }
|
||||
|
||||
void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap)
|
||||
{
|
||||
for (auto const& p : creatureMap)
|
||||
{
|
||||
uint32& count = creatureIds[p.second->GetEntry()];
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Visit(std::unordered_map<ObjectGuid, T*>&) { }
|
||||
|
||||
std::vector<std::pair<uint32, uint32>> GetTopCreatureCount(uint32 count)
|
||||
{
|
||||
auto comp = [](std::pair<uint32, uint32> const& a, std::pair<uint32, uint32> const& b)
|
||||
{
|
||||
return a.second > b.second;
|
||||
};
|
||||
std::set<std::pair<uint32, uint32>, decltype(comp)> set(creatureIds.begin(), creatureIds.end(), comp);
|
||||
|
||||
count = std::min(count, uint32(set.size()));
|
||||
std::vector<std::pair<uint32, uint32>> result(count);
|
||||
std::copy_n(set.begin(), count, result.begin());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<uint32, uint32> creatureIds;
|
||||
};
|
||||
|
||||
static void HandleDebugObjectCountMap(ChatHandler* handler, Map* map)
|
||||
{
|
||||
handler->PSendSysMessage("Map Id: %u Name: '%s' Instance Id: %u Creatures: %u GameObjects: %u SetActive Objects: %u",
|
||||
map->GetId(), map->GetMapName(), map->GetInstanceId(),
|
||||
uint64(map->GetObjectsStore().Size<Creature>()),
|
||||
uint64(map->GetObjectsStore().Size<GameObject>()),
|
||||
uint64(map->GetActiveNonPlayersCount()));
|
||||
|
||||
CreatureCountWorker worker;
|
||||
TypeContainerVisitor<CreatureCountWorker, MapStoredObjectTypesContainer> visitor(worker);
|
||||
visitor.Visit(map->GetObjectsStore());
|
||||
|
||||
handler->PSendSysMessage("Top Creatures count:");
|
||||
|
||||
for (auto&& p : worker.GetTopCreatureCount(5))
|
||||
handler->PSendSysMessage("Entry: %u Count: %u", p.first, p.second);
|
||||
}
|
||||
|
||||
static bool HandleDebugDummyCommand(ChatHandler* handler)
|
||||
{
|
||||
handler->SendSysMessage("This command does nothing right now. Edit your local core (cs_debug.cpp) to make it do whatever you need for testing.");
|
||||
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
uint32 factionid = target->GetFaction();
|
||||
uint32 flag = target->GetUnitFlags();
|
||||
uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
|
||||
uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
|
||||
uint32 dyflag = target->GetDynamicFlags();
|
||||
handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().GetCounter(), factionid, flag, npcflag, dyflag);
|
||||
return true;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
|
||||
auto pdyflag = dynamicFlagID;
|
||||
if (!pdyflag)
|
||||
dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
|
||||
dyflag = target->GetDynamicFlags();
|
||||
else
|
||||
dyflag = *dynamicFlagID;
|
||||
|
||||
@@ -307,7 +307,7 @@ public:
|
||||
target->SetFaction(factionid);
|
||||
target->ReplaceAllUnitFlags(flag);
|
||||
target->SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
|
||||
target->SetUInt32Value(UNIT_DYNAMIC_FLAGS, dyflag);
|
||||
target->ReplaceAllDynamicFlags(dyflag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ public:
|
||||
handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
|
||||
handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId());
|
||||
handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
|
||||
handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->GetFaction());
|
||||
handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetDynamicFlags(), target->GetFaction());
|
||||
handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
|
||||
handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
|
||||
handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId());
|
||||
|
||||
Reference in New Issue
Block a user