diff options
author | ariel- <ariel-@users.noreply.github.com> | 2018-02-24 20:57:55 -0300 |
---|---|---|
committer | funjoker <funjoker109@gmail.com> | 2021-08-08 21:21:34 +0200 |
commit | 67a1a1d29b76acfcda505fe1a38761a335e93bc5 (patch) | |
tree | 4d74e6600201194e4fa52061efa42eeec7434263 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 4c8a49302fe5d5872cae716db0c91604bc95cad4 (diff) |
Core/GameObject: implemented gameobject_overrides table to change faction and flags values on a per-spawn basis
Updates #20957
Closes #20958
(cherry picked from commit 34967e9c32b2c7e871bb93f41609a3b08ad92931)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 42ac714018d..84117d199ca 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7432,18 +7432,18 @@ void ObjectMgr::LoadGameObjectTemplateAddons() } GameObjectTemplateAddon& gameObjectAddon = _gameObjectTemplateAddonStore[entry]; - gameObjectAddon.faction = uint32(fields[1].GetUInt16()); - gameObjectAddon.flags = fields[2].GetUInt32(); - gameObjectAddon.mingold = fields[3].GetUInt32(); - gameObjectAddon.maxgold = fields[4].GetUInt32(); + gameObjectAddon.Faction = uint32(fields[1].GetUInt16()); + gameObjectAddon.Flags = fields[2].GetUInt32(); + gameObjectAddon.Mingold = fields[3].GetUInt32(); + gameObjectAddon.Maxgold = fields[4].GetUInt32(); gameObjectAddon.WorldEffectID = fields[5].GetUInt32(); gameObjectAddon.AIAnimKitID = fields[6].GetUInt32(); // checks - if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction)) - TC_LOG_ERROR("sql.sql", "GameObject (Entry: %u) has invalid faction (%u) defined in `gameobject_template_addon`.", entry, gameObjectAddon.faction); + if (gameObjectAddon.Faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.Faction)) + TC_LOG_ERROR("sql.sql", "GameObject (Entry: %u) has invalid faction (%u) defined in `gameobject_template_addon`.", entry, gameObjectAddon.Faction); - if (gameObjectAddon.maxgold > 0) + if (gameObjectAddon.Maxgold > 0) { switch (got->type) { @@ -7475,6 +7475,44 @@ void ObjectMgr::LoadGameObjectTemplateAddons() TC_LOG_INFO("server.loading", ">> Loaded %u game object template addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadGameObjectOverrides() +{ + uint32 oldMSTime = getMSTime(); + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT spawnId, faction, flags FROM gameobject_overrides"); + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 gameobject faction and flags overrides. DB table `gameobject_overrides` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + ObjectGuid::LowType spawnId = fields[0].GetUInt64(); + GameObjectData const* goData = GetGameObjectData(spawnId); + if (!goData) + { + TC_LOG_ERROR("sql.sql", "GameObject (SpawnId: " UI64FMTD ") does not exist but has a record in `gameobject_overrides`", spawnId); + continue; + } + + GameObjectOverride& gameObjectOverride = _gameObjectOverrideStore[spawnId]; + gameObjectOverride.Faction = fields[1].GetUInt32(); + gameObjectOverride.Flags = fields[2].GetUInt32(); + + if (gameObjectOverride.Faction && !sFactionTemplateStore.LookupEntry(gameObjectOverride.Faction)) + TC_LOG_ERROR("sql.sql", "GameObject (SpawnId: " UI64FMTD ") has invalid faction (%u) defined in `gameobject_overrides`.", spawnId, gameObjectOverride.Faction); + + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u gameobject faction and flags overrides in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadExplorationBaseXP() { uint32 oldMSTime = getMSTime(); @@ -9934,6 +9972,11 @@ GameObjectTemplateAddon const* ObjectMgr::GetGameObjectTemplateAddon(uint32 entr return nullptr; } +GameObjectOverride const* ObjectMgr::GetGameObjectOverride(ObjectGuid::LowType spawnId) const +{ + return Trinity::Containers::MapGetValuePtr(_gameObjectOverrideStore, spawnId); +} + CreatureTemplate const* ObjectMgr::GetCreatureTemplate(uint32 entry) const { return Trinity::Containers::MapGetValuePtr(_creatureTemplateStore, entry); |