diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 10 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 9 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 60 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 3 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 3 |
5 files changed, 85 insertions, 0 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 1914b641c5f..4d419ac1e97 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -296,6 +296,16 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u SetGoAnimProgress(animprogress); break; } + + if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(guidlow)) + { + if (addon->InvisibilityType && addon->InvisibilityValue) + { + m_invisibility.AddFlag(addon->InvisibilityType); + m_invisibility.AddValue(addon->InvisibilityType, addon->InvisibilityValue); + } + } + LastUsedScriptID = GetGOInfo()->ScriptId; AIM_Initialize(); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 02349990d12..3d57c9823c9 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -798,6 +798,15 @@ struct GameObjectLocale StringVector CastBarCaption; }; +// `gameobject_addon` table +struct GameObjectAddon +{ + InvisibilityType InvisibilityType; + uint32 InvisibilityValue; +}; + +typedef std::unordered_map<ObjectGuid::LowType, GameObjectAddon> GameObjectAddonContainer; + // client side GO show states enum GOState { diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 2d6a338c732..bd32f0b70ea 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1082,6 +1082,66 @@ void ObjectMgr::LoadCreatureAddons() TC_LOG_INFO("server.loading", ">> Loaded %u creature addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadGameObjectAddons() +{ + uint32 oldMSTime = getMSTime(); + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 gameobject addon definitions. DB table `gameobject_addon` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + ObjectGuid::LowType guid = fields[0].GetUInt64(); + + const GameObjectData* goData = GetGOData(guid); + if (!goData) + { + TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") does not exist but has a record in `gameobject_addon`", guid); + continue; + } + + GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid]; + gameObjectAddon.InvisibilityType = InvisibilityType(fields[1].GetUInt8()); + gameObjectAddon.InvisibilityValue = InvisibilityType(fields[2].GetUInt32()); + + if (gameObjectAddon.InvisibilityType >= TOTAL_INVISIBILITY_TYPES) + { + TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") has invalid InvisibilityType in `gameobject_addon`", guid); + gameObjectAddon.InvisibilityType = INVISIBILITY_GENERAL; + gameObjectAddon.InvisibilityValue = 0; + } + + if (gameObjectAddon.InvisibilityType && !gameObjectAddon.InvisibilityValue) + { + TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid); + gameObjectAddon.InvisibilityValue = 1; + } + + ++count; + } + while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u gameobject addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + +GameObjectAddon const* ObjectMgr::GetGameObjectAddon(ObjectGuid::LowType lowguid) +{ + GameObjectAddonContainer::const_iterator itr = _gameObjectAddonStore.find(lowguid); + if (itr != _gameObjectAddonStore.end()) + return &(itr->second); + + return NULL; +} + CreatureAddon const* ObjectMgr::GetCreatureAddon(ObjectGuid::LowType lowguid) { CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 57de8720c3d..49d7b024b19 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -708,6 +708,7 @@ class ObjectMgr static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = NULL); EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id); CreatureAddon const* GetCreatureAddon(ObjectGuid::LowType lowguid); + GameObjectAddon const* GetGameObjectAddon(ObjectGuid::LowType lowguid); CreatureAddon const* GetCreatureTemplateAddon(uint32 entry); ItemTemplate const* GetItemTemplate(uint32 entry); ItemTemplateContainer const* GetItemTemplateStore() const { return &_itemTemplateStore; } @@ -934,6 +935,7 @@ class ObjectMgr void LoadLinkedRespawn(); bool SetCreatureLinkedRespawn(ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid); void LoadCreatureAddons(); + void LoadGameObjectAddons(); void LoadCreatureModelInfo(); void LoadEquipmentTemplates(); void LoadGameObjectLocales(); @@ -1398,6 +1400,7 @@ class ObjectMgr CreatureTemplateContainer _creatureTemplateStore; CreatureModelContainer _creatureModelStore; CreatureAddonContainer _creatureAddonStore; + GameObjectAddonContainer _gameObjectAddonStore; CreatureTemplateAddonContainer _creatureTemplateAddonStore; EquipmentInfoContainer _equipmentInfoStore; LinkedRespawnContainer _linkedRespawnStore; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index bd0e023af0e..dc40e5f3c2b 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1619,6 +1619,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Gameobject Data..."); sObjectMgr->LoadGameobjects(); + + TC_LOG_INFO("server.loading", "Loading GameObject Addon Data..."); + sObjectMgr->LoadGameObjectAddons(); // must be after LoadGameObjectTemplate() and LoadGameobjects() TC_LOG_INFO("server.loading", "Loading Creature Linked Respawn..."); sObjectMgr->LoadLinkedRespawn(); // must be after LoadCreatures(), LoadGameObjects() |