aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-02-08 20:22:37 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-21 15:16:26 +0100
commit94a79bac7a06aa0f931e9d651928de7eea0a8b5c (patch)
tree0f28508689237d951d0a44ae05c85ab3a29d8c62 /src/server/game/Globals/ObjectMgr.cpp
parentfe489e2be1312bc559d0c38691c9741ad69cfec8 (diff)
Core/Misc: Some refactoring, #23603 prep: (#23676)
- Split SpawnMetadata off from SpawnData - No longer allocate Creature/Gameobject objects in ObjectGridLoader just to check their typeid and delete them afterwards Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> (cherry picked from commit 9304e496cbf6ab6c028671fb8526c732ae5d799f)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp138
1 files changed, 78 insertions, 60 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 032573ed81a..f9e20a9a420 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1757,8 +1757,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- MapEntry const* const map = sMapStore.LookupEntry(master->spawnPoint.GetMapId());
- if (!map || !map->Instanceable() || (master->spawnPoint.GetMapId() != slave->spawnPoint.GetMapId()))
+ MapEntry const* const map = sMapStore.LookupEntry(master->mapId);
+ if (!map || !map->Instanceable() || (master->mapId != slave->mapId))
{
TC_LOG_ERROR("sql.sql", "LinkedRespawn: Creature '" UI64FMTD "' linking to Creature '" UI64FMTD "' on an unpermitted map.", guidLow, linkedGuidLow);
error = true;
@@ -1773,8 +1773,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = ObjectGuid::Create<HighGuid::Creature>(slave->spawnPoint.GetMapId(), slave->id, guidLow);
- linkedGuid = ObjectGuid::Create<HighGuid::Creature>(master->spawnPoint.GetMapId(), master->id, linkedGuidLow);
+ guid = ObjectGuid::Create<HighGuid::Creature>(slave->mapId, slave->id, guidLow);
+ linkedGuid = ObjectGuid::Create<HighGuid::Creature>(master->mapId, master->id, linkedGuidLow);
break;
}
case LINKED_RESPAWN_CREATURE_TO_GO:
@@ -1795,8 +1795,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- MapEntry const* const map = sMapStore.LookupEntry(master->spawnPoint.GetMapId());
- if (!map || !map->Instanceable() || (master->spawnPoint.GetMapId() != slave->spawnPoint.GetMapId()))
+ MapEntry const* const map = sMapStore.LookupEntry(master->mapId);
+ if (!map || !map->Instanceable() || (master->mapId != slave->mapId))
{
TC_LOG_ERROR("sql.sql", "LinkedRespawn: Creature '" UI64FMTD "' linking to Gameobject '" UI64FMTD "' on an unpermitted map.", guidLow, linkedGuidLow);
error = true;
@@ -1811,8 +1811,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = ObjectGuid::Create<HighGuid::Creature>(slave->spawnPoint.GetMapId(), slave->id, guidLow);
- linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->spawnPoint.GetMapId(), master->id, linkedGuidLow);
+ guid = ObjectGuid::Create<HighGuid::Creature>(slave->mapId, slave->id, guidLow);
+ linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->mapId, master->id, linkedGuidLow);
break;
}
case LINKED_RESPAWN_GO_TO_GO:
@@ -1833,8 +1833,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- MapEntry const* const map = sMapStore.LookupEntry(master->spawnPoint.GetMapId());
- if (!map || !map->Instanceable() || (master->spawnPoint.GetMapId() != slave->spawnPoint.GetMapId()))
+ MapEntry const* const map = sMapStore.LookupEntry(master->mapId);
+ if (!map || !map->Instanceable() || (master->mapId != slave->mapId))
{
TC_LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '" UI64FMTD "' linking to Gameobject '" UI64FMTD "' on an unpermitted map.", guidLow, linkedGuidLow);
error = true;
@@ -1849,8 +1849,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = ObjectGuid::Create<HighGuid::GameObject>(slave->spawnPoint.GetMapId(), slave->id, guidLow);
- linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->spawnPoint.GetMapId(), master->id, linkedGuidLow);
+ guid = ObjectGuid::Create<HighGuid::GameObject>(slave->mapId, slave->id, guidLow);
+ linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->mapId, master->id, linkedGuidLow);
break;
}
case LINKED_RESPAWN_GO_TO_CREATURE:
@@ -1871,8 +1871,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- MapEntry const* const map = sMapStore.LookupEntry(master->spawnPoint.GetMapId());
- if (!map || !map->Instanceable() || (master->spawnPoint.GetMapId() != slave->spawnPoint.GetMapId()))
+ MapEntry const* const map = sMapStore.LookupEntry(master->mapId);
+ if (!map || !map->Instanceable() || (master->mapId != slave->mapId))
{
TC_LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '" UI64FMTD "' linking to Creature '" UI64FMTD "' on an unpermitted map.", guidLow, linkedGuidLow);
error = true;
@@ -1887,8 +1887,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = ObjectGuid::Create<HighGuid::GameObject>(slave->spawnPoint.GetMapId(), slave->id, guidLow);
- linkedGuid = ObjectGuid::Create<HighGuid::Creature>(master->spawnPoint.GetMapId(), master->id, linkedGuidLow);
+ guid = ObjectGuid::Create<HighGuid::GameObject>(slave->mapId, slave->id, guidLow);
+ linkedGuid = ObjectGuid::Create<HighGuid::Creature>(master->mapId, master->id, linkedGuidLow);
break;
}
}
@@ -1908,7 +1908,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid
CreatureData const* master = GetCreatureData(guidLow);
ASSERT(master);
- ObjectGuid guid = ObjectGuid::Create<HighGuid::Creature>(master->spawnPoint.GetMapId(), master->id, guidLow);
+ ObjectGuid guid = ObjectGuid::Create<HighGuid::Creature>(master->mapId, master->id, guidLow);
if (!linkedGuidLow) // we're removing the linking
{
@@ -1927,8 +1927,8 @@ bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid
return false;
}
- MapEntry const* map = sMapStore.LookupEntry(master->spawnPoint.GetMapId());
- if (!map || !map->Instanceable() || (master->spawnPoint.GetMapId() != slave->spawnPoint.GetMapId()))
+ MapEntry const* map = sMapStore.LookupEntry(master->mapId);
+ if (!map || !map->Instanceable() || (master->mapId != slave->mapId))
{
TC_LOG_ERROR("sql.sql", "Creature '" UI64FMTD "' linking to '" UI64FMTD "' on an unpermitted map.", guidLow, linkedGuidLow);
return false;
@@ -1941,7 +1941,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid
return false;
}
- ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Creature>(slave->spawnPoint.GetMapId(), slave->id, linkedGuidLow);
+ ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Creature>(slave->mapId, slave->id, linkedGuidLow);
_linkedRespawnStore[guid] = linkedGuid;
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_LINKED_RESPAWN);
@@ -2117,7 +2117,8 @@ void ObjectMgr::LoadCreatures()
CreatureData& data = _creatureDataStore[guid];
data.spawnId = guid;
data.id = entry;
- data.spawnPoint.WorldRelocate(fields[2].GetUInt16(), fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat());
+ data.mapId = fields[2].GetUInt16();
+ data.spawnPoint.Relocate(fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat());
data.displayid = fields[7].GetUInt32();
data.equipmentId = fields[8].GetInt8();
data.spawntimesecs = fields[9].GetUInt32();
@@ -2126,7 +2127,7 @@ void ObjectMgr::LoadCreatures()
data.curhealth = fields[12].GetUInt32();
data.curmana = fields[13].GetUInt32();
data.movementType = fields[14].GetUInt8();
- data.spawnDifficulties = ParseSpawnDifficulties(fields[15].GetString(), "creature", guid, data.spawnPoint.GetMapId(), spawnMasks[data.spawnPoint.GetMapId()]);
+ data.spawnDifficulties = ParseSpawnDifficulties(fields[15].GetString(), "creature", guid, data.mapId, spawnMasks[data.mapId]);
int16 gameEvent = fields[16].GetInt8();
uint32 PoolId = fields[17].GetUInt32();
data.npcflag = fields[18].GetUInt64();
@@ -2139,12 +2140,12 @@ void ObjectMgr::LoadCreatures()
data.phaseGroup = fields[25].GetUInt32();
data.terrainSwapMap = fields[26].GetInt32();
data.scriptId = GetScriptId(fields[27].GetString());
- data.spawnGroupData = &_spawnGroupDataStore[IsTransportMap(data.spawnPoint.GetMapId()) ? 1 : 0]; // transport spawns default to compatibility group
+ data.spawnGroupData = IsTransportMap(data.mapId) ? GetLegacySpawnGroup() : GetDefaultSpawnGroup(); // transport spawns default to compatibility group
- MapEntry const* mapEntry = sMapStore.LookupEntry(data.spawnPoint.GetMapId());
+ MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapId);
if (!mapEntry)
{
- TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD ") that spawned at nonexistent map (Id: %u), skipped.", guid, data.spawnPoint.GetMapId());
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD ") that spawned at nonexistent map (Id: %u), skipped.", guid, data.mapId);
continue;
}
@@ -2152,16 +2153,16 @@ void ObjectMgr::LoadCreatures()
{
if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager())
{
- if (vmgr->isMapLoadingEnabled() && !IsTransportMap(data.spawnPoint.GetMapId()))
+ if (vmgr->isMapLoadingEnabled() && !IsTransportMap(data.mapId))
{
GridCoord gridCoord = Trinity::ComputeGridCoord(data.spawnPoint.GetPositionX(), data.spawnPoint.GetPositionY());
int gx = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.x_coord;
int gy = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.y_coord;
- VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), data.spawnPoint.GetMapId(), gx, gy);
+ VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), data.mapId, gx, gy);
if (result != VMAP::LoadResult::Success)
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u MapID: %u) spawned on a possible invalid position (%s)",
- guid, data.id, data.spawnPoint.GetMapId(), data.spawnPoint.ToString().c_str());
+ guid, data.id, data.mapId, data.spawnPoint.ToString().c_str());
}
}
}
@@ -2274,7 +2275,7 @@ void ObjectMgr::LoadCreatures()
TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: " UI64FMTD " Entry: %u) with `terrainSwapMap` %u does not exist, set to -1", guid, data.id, data.terrainSwapMap);
data.terrainSwapMap = -1;
}
- else if (terrainSwapEntry->ParentMapID != int16(data.spawnPoint.GetMapId()))
+ else if (terrainSwapEntry->ParentMapID != int16(data.mapId))
{
TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: " UI64FMTD " Entry: %u) with `terrainSwapMap` %u which cannot be used on spawn map, set to -1", guid, data.id, data.terrainSwapMap);
data.terrainSwapMap = -1;
@@ -2286,7 +2287,7 @@ void ObjectMgr::LoadCreatures()
uint32 zoneId = 0;
uint32 areaId = 0;
PhasingHandler::InitDbVisibleMapId(phaseShift, data.terrainSwapMap);
- sMapMgr->GetZoneAndAreaId(phaseShift, zoneId, areaId, data.spawnPoint);
+ sMapMgr->GetZoneAndAreaId(phaseShift, zoneId, areaId, data.mapId, data.spawnPoint);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ZONE_AREA_DATA);
@@ -2311,7 +2312,7 @@ void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const*
for (Difficulty difficulty : data->spawnDifficulties)
{
CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY());
- CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->spawnPoint.GetMapId(), difficulty)][cellCoord.GetId()];
+ CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()];
cell_guids.creatures.insert(guid);
}
}
@@ -2321,7 +2322,7 @@ void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData co
for (Difficulty difficulty : data->spawnDifficulties)
{
CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY());
- CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->spawnPoint.GetMapId(), difficulty)][cellCoord.GetId()];
+ CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()];
cell_guids.creatures.erase(guid);
}
}
@@ -2340,7 +2341,8 @@ ObjectGuid::LowType ObjectMgr::AddGameObjectData(uint32 entry, uint32 mapId, Pos
GameObjectData& data = NewOrExistGameObjectData(spawnId);
data.spawnId = spawnId;
data.id = entry;
- data.spawnPoint.WorldRelocate(mapId,pos);
+ data.mapId = mapId;
+ data.spawnPoint.Relocate(pos);
data.rotation = rot;
data.spawntimesecs = spawntimedelay;
data.animprogress = 100;
@@ -2388,7 +2390,8 @@ ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, Posit
CreatureData& data = NewOrExistCreatureData(spawnId);
data.spawnId = spawnId;
data.id = entry;
- data.spawnPoint.WorldRelocate(mapId, pos);
+ data.mapId = mapId;
+ data.spawnPoint.Relocate(pos);
data.displayid = 0;
data.equipmentId = 0;
data.spawntimesecs = spawntimedelay;
@@ -2486,18 +2489,19 @@ void ObjectMgr::LoadGameObjects()
data.spawnId = guid;
data.id = entry;
- data.spawnPoint.WorldRelocate(fields[2].GetUInt16(), fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat());
+ data.mapId = fields[2].GetUInt16();
+ data.spawnPoint.Relocate(fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat());
data.rotation.x = fields[7].GetFloat();
data.rotation.y = fields[8].GetFloat();
data.rotation.z = fields[9].GetFloat();
data.rotation.w = fields[10].GetFloat();
data.spawntimesecs = fields[11].GetInt32();
- data.spawnGroupData = &_spawnGroupDataStore[IsTransportMap(data.spawnPoint.GetMapId()) ? 1 : 0]; // transport spawns default to compatibility group
+ data.spawnGroupData = IsTransportMap(data.mapId) ? GetLegacySpawnGroup() : GetDefaultSpawnGroup(); // transport spawns default to compatibility group
- MapEntry const* mapEntry = sMapStore.LookupEntry(data.spawnPoint.GetMapId());
+ MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapId);
if (!mapEntry)
{
- TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) spawned on a non-existed map (Id: %u), skip", guid, data.id, data.spawnPoint.GetMapId());
+ TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) spawned on a non-existed map (Id: %u), skip", guid, data.id, data.mapId);
continue;
}
@@ -2505,16 +2509,16 @@ void ObjectMgr::LoadGameObjects()
{
if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager())
{
- if (vmgr->isMapLoadingEnabled() && !IsTransportMap(data.spawnPoint.GetMapId()))
+ if (vmgr->isMapLoadingEnabled() && !IsTransportMap(data.mapId))
{
GridCoord gridCoord = Trinity::ComputeGridCoord(data.spawnPoint.GetPositionX(), data.spawnPoint.GetPositionY());
int gx = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.x_coord;
int gy = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.y_coord;
- VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), data.spawnPoint.GetMapId(), gx, gy);
+ VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), data.mapId, gx, gy);
if (result != VMAP::LoadResult::Success)
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u MapID: %u) spawned on a possible invalid position (%s)",
- guid, data.id, data.spawnPoint.GetMapId(), data.spawnPoint.ToString().c_str());
+ guid, data.id, data.mapId, data.spawnPoint.ToString().c_str());
}
}
}
@@ -2538,7 +2542,7 @@ void ObjectMgr::LoadGameObjects()
}
data.goState = GOState(go_state);
- data.spawnDifficulties = ParseSpawnDifficulties(fields[14].GetString(), "gameobject", guid, data.spawnPoint.GetMapId(), spawnMasks[data.spawnPoint.GetMapId()]);
+ data.spawnDifficulties = ParseSpawnDifficulties(fields[14].GetString(), "gameobject", guid, data.mapId, spawnMasks[data.mapId]);
if (data.spawnDifficulties.empty())
{
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD ") that is not spawned in any difficulty, skipped.", guid);
@@ -2597,7 +2601,7 @@ void ObjectMgr::LoadGameObjects()
TC_LOG_ERROR("sql.sql", "Table `gameobject` have gameobject (GUID: " UI64FMTD " Entry: %u) with `terrainSwapMap` %u does not exist, set to -1", guid, data.id, data.terrainSwapMap);
data.terrainSwapMap = -1;
}
- else if (terrainSwapEntry->ParentMapID != int16(data.spawnPoint.GetMapId()))
+ else if (terrainSwapEntry->ParentMapID != int16(data.mapId))
{
TC_LOG_ERROR("sql.sql", "Table `gameobject` have gameobject (GUID: " UI64FMTD " Entry: %u) with `terrainSwapMap` %u which cannot be used on spawn map, set to -1", guid, data.id, data.terrainSwapMap);
data.terrainSwapMap = -1;
@@ -2630,7 +2634,7 @@ void ObjectMgr::LoadGameObjects()
continue;
}
- if (!MapManager::IsValidMapCoord(data.spawnPoint))
+ if (!MapManager::IsValidMapCoord(data.mapId, data.spawnPoint))
{
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid coordinates, skip", guid, data.id);
continue;
@@ -2647,7 +2651,7 @@ void ObjectMgr::LoadGameObjects()
uint32 zoneId = 0;
uint32 areaId = 0;
PhasingHandler::InitDbVisibleMapId(phaseShift, data.terrainSwapMap);
- sMapMgr->GetZoneAndAreaId(phaseShift, zoneId, areaId, data.spawnPoint);
+ sMapMgr->GetZoneAndAreaId(phaseShift, zoneId, areaId, data.mapId, data.spawnPoint);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA);
@@ -2743,19 +2747,15 @@ void ObjectMgr::LoadSpawnGroups()
{
Field* fields = result->Fetch();
uint32 groupId = fields[0].GetUInt32();
- SpawnObjectType spawnType;
+ SpawnObjectType spawnType = SpawnObjectType(fields[1].GetUInt8());
+ if (!SpawnData::TypeIsValid(spawnType))
{
- uint32 type = fields[1].GetUInt8();
- if (type >= SPAWN_TYPE_MAX)
- {
- TC_LOG_ERROR("sql.sql", "Spawn data with invalid type %u listed for spawn group %u. Skipped.", type, groupId);
- continue;
- }
- spawnType = SpawnObjectType(type);
+ TC_LOG_ERROR("sql.sql", "Spawn data with invalid type %u listed for spawn group %u. Skipped.", uint32(spawnType), groupId);
+ continue;
}
ObjectGuid::LowType spawnId = fields[2].GetUInt64();
- SpawnData const* data = GetSpawnData(spawnType, spawnId);
+ SpawnMetadata const* data = GetSpawnMetadata(spawnType, spawnId);
if (!data)
{
TC_LOG_ERROR("sql.sql", "Spawn data with ID (%u," UI64FMTD ") not found, but is listed as a member of spawn group %u!", uint32(spawnType), spawnId, groupId);
@@ -2776,13 +2776,13 @@ void ObjectMgr::LoadSpawnGroups()
{
SpawnGroupTemplateData& groupTemplate = it->second;
if (groupTemplate.mapId == SPAWNGROUP_MAP_UNSET)
- groupTemplate.mapId = data->spawnPoint.GetMapId();
- else if (groupTemplate.mapId != data->spawnPoint.GetMapId() && !(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
+ groupTemplate.mapId = data->mapId;
+ else if (groupTemplate.mapId != data->mapId && !(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
{
- TC_LOG_ERROR("sql.sql", "Spawn group %u has map ID %u, but spawn (%u," UI64FMTD ") has map id %u - spawn NOT added to group!", groupId, groupTemplate.mapId, uint32(spawnType), spawnId, data->spawnPoint.GetMapId());
+ TC_LOG_ERROR("sql.sql", "Spawn group %u has map ID %u, but spawn (%u," UI64FMTD ") has map id %u - spawn NOT added to group!", groupId, groupTemplate.mapId, uint32(spawnType), spawnId, data->mapId);
continue;
}
- const_cast<SpawnData*>(data)->spawnGroupData = &groupTemplate;
+ const_cast<SpawnMetadata*>(data)->spawnGroupData = &groupTemplate;
if (!(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
_spawnGroupMapStore.emplace(groupId, data);
++numMembers;
@@ -2849,6 +2849,24 @@ void ObjectMgr::LoadInstanceSpawnGroups()
TC_LOG_INFO("server.loading", ">> Loaded %u instance spawn groups in %u ms", n, GetMSTimeDiffToNow(oldMSTime));
}
+SpawnData const* ObjectMgr::GetSpawnData(SpawnObjectType type, ObjectGuid::LowType spawnId) const
+{
+ if (!SpawnData::TypeHasData(type))
+ return nullptr;
+ switch (type)
+ {
+ case SPAWN_TYPE_CREATURE:
+ return GetCreatureData(spawnId);
+ case SPAWN_TYPE_GAMEOBJECT:
+ return GetGameObjectData(spawnId);
+ case SPAWN_TYPE_AREATRIGGER:
+ return sAreaTriggerDataStore->GetAreaTriggerSpawn(spawnId);
+ default:
+ ASSERT(false, "Invalid spawn object type %u", uint32(type));
+ return nullptr;
+ }
+}
+
void ObjectMgr::OnDeleteSpawnData(SpawnData const* data)
{
auto templateIt = _spawnGroupDataStore.find(data->spawnGroupData->groupId);
@@ -2872,7 +2890,7 @@ void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData con
for (Difficulty difficulty : data->spawnDifficulties)
{
CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY());
- CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->spawnPoint.GetMapId(), difficulty)][cellCoord.GetId()];
+ CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()];
cell_guids.gameobjects.insert(guid);
}
}
@@ -2882,7 +2900,7 @@ void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectDat
for (Difficulty difficulty : data->spawnDifficulties)
{
CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY());
- CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->spawnPoint.GetMapId(), difficulty)][cellCoord.GetId()];
+ CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()];
cell_guids.gameobjects.erase(guid);
}
}