aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-07-24 18:56:40 +0200
committerShauren <shauren.trinity@gmail.com>2022-07-24 18:56:40 +0200
commitfbe0b8efebca3bc2662b477bdf45627f9783d6c2 (patch)
tree6f5662045be0c4e5f06d8a97f9669b7f93cf2df1 /src/server/scripts/Commands
parent8f2c5413d7a3775a304c793653d41caabf3ba997 (diff)
Core/Maps: Removed MapInstanced - no longer neccessary for grid data reference counting (moved to TerrainInfo)
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp18
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp1
-rw-r--r--src/server/scripts/Commands/cs_instance.cpp1
-rw-r--r--src/server/scripts/Commands/cs_list.cpp46
4 files changed, 29 insertions, 37 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index b3879bafd56..72e3ffc6838 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -37,6 +37,7 @@ EndScriptData */
#include "DB2Stores.h"
#include "GameTime.h"
#include "GridNotifiersImpl.h"
+#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "Language.h"
#include "Log.h"
@@ -1233,17 +1234,26 @@ public:
static bool HandleDebugLoadCellsCommand(ChatHandler* handler, Optional<uint32> mapId, Optional<uint32> tileX, Optional<uint32> tileY)
{
- Map* map = nullptr;
if (mapId)
{
- map = sMapMgr->FindBaseNonInstanceMap(*mapId);
+ sMapMgr->DoForAllMapsWithMapId(*mapId, [&](Map* map)
+ {
+ HandleDebugLoadCellsCommandHelper(handler, map, tileX, tileY);
+ });
+ return true;
}
- else if (Player* player = handler->GetPlayer())
+
+ if (Player* player = handler->GetPlayer())
{
// Fallback to player's map if no map has been specified
- map = player->GetMap();
+ return HandleDebugLoadCellsCommandHelper(handler, player->GetMap(), tileX, tileY);
}
+ return false;
+ }
+
+ static bool HandleDebugLoadCellsCommandHelper(ChatHandler* handler, Map* map, Optional<uint32> tileX, Optional<uint32> tileY)
+ {
if (!map)
return false;
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index e389f535569..027c72e1c23 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -33,6 +33,7 @@ EndScriptData */
#include "GameTime.h"
#include "Language.h"
#include "Log.h"
+#include "Map.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp
index eb5173b1daf..a00853298c0 100644
--- a/src/server/scripts/Commands/cs_instance.cpp
+++ b/src/server/scripts/Commands/cs_instance.cpp
@@ -31,6 +31,7 @@ EndScriptData */
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "Language.h"
+#include "Map.h"
#include "MapManager.h"
#include "Player.h"
#include "RBAC.h"
diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp
index 61668b98973..5ca3df7caca 100644
--- a/src/server/scripts/Commands/cs_list.cpp
+++ b/src/server/scripts/Commands/cs_list.cpp
@@ -32,7 +32,7 @@ EndScriptData */
#include "GameObject.h"
#include "GameTime.h"
#include "Language.h"
-#include "MapManager.h"
+#include "Map.h"
#include "ObjectMgr.h"
#include "PhasingHandler.h"
#include "Player.h"
@@ -120,28 +120,18 @@ public:
bool liveFound = false;
// Get map (only support base map from console)
- Map* thisMap;
+ Map* thisMap = nullptr;
if (handler->GetSession())
thisMap = handler->GetSession()->GetPlayer()->GetMap();
- else
- thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
// If map found, try to find active version of this creature
if (thisMap)
{
- auto const creBounds = thisMap->GetCreatureBySpawnIdStore().equal_range(guid);
- if (creBounds.first != creBounds.second)
- {
- for (std::unordered_multimap<ObjectGuid::LowType, Creature*>::const_iterator itr = creBounds.first; itr != creBounds.second;)
- {
- if (handler->GetSession())
- handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), cInfo->Name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->IsAlive() ? "*" : " ");
- else
- handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, std::to_string(guid).c_str(), cInfo->Name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->IsAlive() ? "*" : " ");
- ++itr;
- }
- liveFound = true;
- }
+ auto const creBounds = Trinity::Containers::MapEqualRange(thisMap->GetCreatureBySpawnIdStore(), guid);
+ for (auto& [spawnId, creature] : creBounds)
+ handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), cInfo->Name.c_str(),
+ x, y, z, mapId, creature->GetGUID().ToString().c_str(), creature->IsAlive() ? "*" : " ");
+ liveFound = creBounds.begin() != creBounds.end();
}
if (!liveFound)
@@ -401,28 +391,18 @@ public:
bool liveFound = false;
// Get map (only support base map from console)
- Map* thisMap;
+ Map* thisMap = nullptr;
if (handler->GetSession())
thisMap = handler->GetSession()->GetPlayer()->GetMap();
- else
- thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
// If map found, try to find active version of this object
if (thisMap)
{
- auto const goBounds = thisMap->GetGameObjectBySpawnIdStore().equal_range(guid);
- if (goBounds.first != goBounds.second)
- {
- for (std::unordered_multimap<ObjectGuid::LowType, GameObject*>::const_iterator itr = goBounds.first; itr != goBounds.second;)
- {
- if (handler->GetSession())
- handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->isSpawned() ? "*" : " ");
- else
- handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->isSpawned() ? "*" : " ");
- ++itr;
- }
- liveFound = true;
- }
+ auto const goBounds = Trinity::Containers::MapEqualRange(thisMap->GetGameObjectBySpawnIdStore(), guid);
+ for (auto& [spawnId, go] : goBounds)
+ handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId,
+ go->GetGUID().ToString().c_str(), go->isSpawned() ? "*" : " ");
+ liveFound = goBounds.begin() != goBounds.end();
}
if (!liveFound)