feat(Core/Spawns): introduce SpawnData base struct and spawn group infrastructure (#25152)

Co-authored-by: r00ty-tc <r00ty-tc@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Andrew
2026-03-23 01:30:22 -03:00
committed by GitHub
parent 27b0ecc6dc
commit 9757174460
5 changed files with 120 additions and 27 deletions
+20
View File
@@ -310,6 +310,9 @@ ObjectMgr::ObjectMgr():
{
_playerClassInfo[i] = nullptr;
}
// Initialize default spawn group
_spawnGroupDataStore[0] = {0, "Default Group", 0, SpawnGroupFlags(SPAWNGROUP_FLAG_SYSTEM)};
}
ObjectMgr::~ObjectMgr()
@@ -2400,6 +2403,7 @@ void ObjectMgr::LoadCreatures()
data.unit_flags = fields[21].Get<uint32>();
data.dynamicflags = fields[22].Get<uint32>();
data.ScriptId = GetScriptId(fields[23].Get<std::string>());
data.spawnGroupId = 0;
if (!data.ScriptId)
data.ScriptId = cInfo->ScriptID;
@@ -2578,6 +2582,7 @@ CreatureData const* ObjectMgr::LoadCreatureDataFromDB(ObjectGuid::LowType spawnI
creatureData.unit_flags = fields[19].Get<uint32>();
creatureData.dynamicflags = fields[20].Get<uint32>();
creatureData.ScriptId = GetScriptId(fields[21].Get<std::string>());
creatureData.spawnGroupId = 0;
if (!creatureData.ScriptId)
creatureData.ScriptId = cInfo->ScriptID;
@@ -2760,6 +2765,7 @@ ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, fl
data.phaseMask = PHASEMASK_NORMAL;
data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
data.dbData = false;
data.spawnGroupId = 0;
AddGameobjectToGrid(spawnId, &data);
@@ -2915,6 +2921,7 @@ void ObjectMgr::LoadGameobjects()
data.rotation.w = fields[10].Get<float>();
data.spawntimesecs = fields[11].Get<int32>();
data.ScriptId = GetScriptId(fields[18].Get<std::string>());
data.spawnGroupId = 0;
if (!data.ScriptId)
data.ScriptId = gInfo->ScriptId;
@@ -8683,6 +8690,19 @@ void ObjectMgr::DeleteGOData(ObjectGuid::LowType guid)
_gameObjectDataStore.erase(guid);
}
SpawnData const* ObjectMgr::GetSpawnData(SpawnObjectType type, ObjectGuid::LowType spawnId) const
{
switch (type)
{
case SPAWN_TYPE_CREATURE:
return GetCreatureData(spawnId);
case SPAWN_TYPE_GAMEOBJECT:
return GetGameObjectData(spawnId);
default:
return nullptr;
}
}
void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go)
{
uint32 oldMSTime = getMSTime();
+10
View File
@@ -506,6 +506,7 @@ struct AcoreString
typedef std::map<ObjectGuid, ObjectGuid> LinkedRespawnContainer;
typedef std::unordered_map<ObjectGuid::LowType, CreatureData> CreatureDataContainer;
typedef std::unordered_map<ObjectGuid::LowType, GameObjectData> GameObjectDataContainer;
typedef std::unordered_map<uint32, SpawnGroupTemplateData> SpawnGroupDataContainer;
typedef std::map<TempSummonGroupKey, std::vector<TempSummonData> > TempSummonDataContainer;
typedef std::map<TempSummonGroupKey, std::vector<GameObjectSummonData> > GameObjectSummonDataContainer;
typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer;
@@ -1269,6 +1270,14 @@ public:
if (itr == _gameObjectDataStore.end()) return nullptr;
return &itr->second;
}
[[nodiscard]] SpawnData const* GetSpawnData(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
[[nodiscard]] SpawnGroupTemplateData const* GetSpawnGroupData(uint32 groupId) const
{
auto itr = _spawnGroupDataStore.find(groupId);
return itr != _spawnGroupDataStore.end() ? &itr->second : nullptr;
}
[[nodiscard]] CreatureLocale const* GetCreatureLocale(uint32 entry) const
{
CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry);
@@ -1643,6 +1652,7 @@ private:
LinkedRespawnContainer _linkedRespawnStore;
CreatureLocaleContainer _creatureLocaleStore;
GameObjectDataContainer _gameObjectDataStore;
SpawnGroupDataContainer _spawnGroupDataStore;
GameObjectLocaleContainer _gameObjectLocaleStore;
GameObjectTemplateContainer _gameObjectTemplateStore;
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore;