aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRat <gmstreetrat@gmail.com>2015-05-19 11:22:07 +0100
committerDDuarte <dnpd.dd@gmail.com>2015-05-19 11:22:51 +0100
commit95b5e357451985fbc350bf1321ce96d6c02f9d44 (patch)
tree0339a143683b44c5fbc3238afc95dc39f88c8235 /src
parent8c61e51fe53f6429a7a8d532a5c675ff72f438ad (diff)
Core/GameObjects: Implemented gameobject_addon table, you can now set invisibility for gameobjects for quests
(cherry picked from commit 9d59d038f8b09ed036448e755cb0b102396a4ca1) Conflicts: sql/updates/world/2015_04_05_07_world.sql src/server/game/Globals/ObjectMgr.cpp src/server/game/Globals/ObjectMgr.h Core/GameObjects: fixed typo and logic (0 is a valid invisibility type) (cherry picked from commit 23e8a3ce2928458649d94408d5deffb67339b1d6)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp10
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h9
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp60
-rw-r--r--src/server/game/Globals/ObjectMgr.h3
-rw-r--r--src/server/game/World/World.cpp3
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 1290b5f0019..5ebb10e76c7 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -271,6 +271,16 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
SetGoAnimProgress(animprogress);
break;
}
+
+ if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(guidlow))
+ {
+ if (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 b3e8510e2fb..fa081369334 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -576,6 +576,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 59e4e871970..8593f3d9c0b 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1039,6 +1039,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 = 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(uint32 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 f9562a12335..a2f8ade2d9a 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -732,6 +732,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(uint32 lowguid);
+ GameObjectAddon const* GetGameObjectAddon(ObjectGuid::LowType lowguid);
CreatureAddon const* GetCreatureTemplateAddon(uint32 entry);
ItemTemplate const* GetItemTemplate(uint32 entry);
ItemTemplateContainer const* GetItemTemplateStore() const { return &_itemTemplateStore; }
@@ -974,6 +975,7 @@ class ObjectMgr
void LoadLinkedRespawn();
bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid);
void LoadCreatureAddons();
+ void LoadGameObjectAddons();
void LoadCreatureModelInfo();
void LoadEquipmentTemplates();
void LoadGameObjectLocales();
@@ -1419,6 +1421,7 @@ class ObjectMgr
CreatureModelContainer _creatureModelStore;
CreatureAddonContainer _creatureAddonStore;
CreatureAddonContainer _creatureTemplateAddonStore;
+ GameObjectAddonContainer _gameObjectAddonStore;
EquipmentInfoContainer _equipmentInfoStore;
LinkedRespawnContainer _linkedRespawnStore;
CreatureLocaleContainer _creatureLocaleStore;
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 9a84fa1670d..5f54154fab1 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1523,6 +1523,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()