aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
authorRat <gmstreetrat@gmail.com>2015-04-05 23:51:46 +0200
committerRat <gmstreetrat@gmail.com>2015-04-05 23:51:46 +0200
commit9d59d038f8b09ed036448e755cb0b102396a4ca1 (patch)
treef1aaf46803a901ad1ed7d7532efd5e7b8a3b52c3 /src/server/game/Globals/ObjectMgr.cpp
parente7eab4bd0713096e16dc36013b15f5bcb39e684c (diff)
Core/GameObjects: Implemented gameobject_addon table, you can now set invisibility for gameobjects for quests
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp60
1 files changed, 60 insertions, 0 deletions
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);