diff options
author | funjoker <torti-esser@web.de> | 2017-11-05 20:24:45 +0100 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-11-05 20:24:45 +0100 |
commit | c77e76fa61a620affdfe60ae2dae639f95091e1b (patch) | |
tree | 20a7d4748969f0140ad62b7407a9566c3cebe3ed /src | |
parent | 983b0a5fcf48494a113a108cd6ccc9230094cc4c (diff) |
Core/Gameobject: Add WorldEffectID to Gameobject (#20785)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/database/Database/Implementation/HotfixDatabase.cpp | 4 | ||||
-rw-r--r-- | src/server/database/Database/Implementation/HotfixDatabase.h | 2 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2LoadInfo.h | 19 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 2 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 1 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Structure.h | 11 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 14 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 4 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObjectData.h | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 24 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Updates/UpdateData.h | 2 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 30 |
12 files changed, 96 insertions, 19 deletions
diff --git a/src/server/database/Database/Implementation/HotfixDatabase.cpp b/src/server/database/Database/Implementation/HotfixDatabase.cpp index 425de74eda7..6556274fc8a 100644 --- a/src/server/database/Database/Implementation/HotfixDatabase.cpp +++ b/src/server/database/Database/Implementation/HotfixDatabase.cpp @@ -1004,6 +1004,10 @@ void HotfixDatabaseConnection::DoPrepareStatements() "UWAmbience, NameSet, SoundProviderPref, SoundProviderPrefUnderwater, Flags, ID, UWZoneMusic FROM wmo_area_table ORDER BY ID DESC", CONNECTION_SYNCH); PREPARE_LOCALE_STMT(HOTFIX_SEL_WMO_AREA_TABLE, "SELECT ID, AreaName_lang FROM wmo_area_table_locale WHERE locale = ?", CONNECTION_SYNCH); + // WorldEffect.db2 + PrepareStatement(HOTFIX_SEL_WORLD_EFFECT, "SELECT ID, TargetAsset, CombatConditionID, TargetType, WhenToDisplay, QuestFeedbackEffectID, " + "PlayerConditionID FROM world_effect ORDER BY ID DESC", CONNECTION_SYNCH); + // WorldMapArea.db2 PrepareStatement(HOTFIX_SEL_WORLD_MAP_AREA, "SELECT AreaName, LocLeft, LocRight, LocTop, LocBottom, MapID, AreaID, DisplayMapID, " "DefaultDungeonFloor, ParentWorldMapID, Flags, LevelRangeMin, LevelRangeMax, BountySetID, BountyBoardLocation, ID, PlayerConditionID" diff --git a/src/server/database/Database/Implementation/HotfixDatabase.h b/src/server/database/Database/Implementation/HotfixDatabase.h index 6d987d0f1f2..84f4c131ff3 100644 --- a/src/server/database/Database/Implementation/HotfixDatabase.h +++ b/src/server/database/Database/Implementation/HotfixDatabase.h @@ -533,6 +533,8 @@ enum HotfixDatabaseStatements : uint32 HOTFIX_SEL_WMO_AREA_TABLE, HOTFIX_SEL_WMO_AREA_TABLE_LOCALE, + HOTFIX_SEL_WORLD_EFFECT, + HOTFIX_SEL_WORLD_MAP_AREA, HOTFIX_SEL_WORLD_MAP_OVERLAY, diff --git a/src/server/game/DataStores/DB2LoadInfo.h b/src/server/game/DataStores/DB2LoadInfo.h index c37a2ab3aab..4be50cfefac 100644 --- a/src/server/game/DataStores/DB2LoadInfo.h +++ b/src/server/game/DataStores/DB2LoadInfo.h @@ -5096,6 +5096,25 @@ struct WmoAreaTableLoadInfo } }; +struct WorldEffectLoadInfo +{ + static DB2LoadInfo const* Instance() + { + static DB2FieldMeta const fields[] = + { + { false, FT_INT, "ID" }, + { false, FT_INT, "TargetAsset" }, + { false, FT_SHORT, "CombatConditionID" }, + { false, FT_BYTE, "TargetType" }, + { false, FT_BYTE, "WhenToDisplay" }, + { false, FT_INT, "QuestFeedbackEffectID" }, + { false, FT_INT, "PlayerConditionID" }, + }; + static DB2LoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, WorldEffectMeta::Instance(), HOTFIX_SEL_WORLD_EFFECT); + return &loadInfo; + } +}; + struct WorldMapAreaLoadInfo { static DB2LoadInfo const* Instance() diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index 11fbdd008b1..ebde5fbb1b5 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -252,6 +252,7 @@ DB2Storage<UnitPowerBarEntry> sUnitPowerBarStore("UnitPowerBar DB2Storage<VehicleEntry> sVehicleStore("Vehicle.db2", VehicleLoadInfo::Instance()); DB2Storage<VehicleSeatEntry> sVehicleSeatStore("VehicleSeat.db2", VehicleSeatLoadInfo::Instance()); DB2Storage<WMOAreaTableEntry> sWMOAreaTableStore("WMOAreaTable.db2", WmoAreaTableLoadInfo::Instance()); +DB2Storage<WorldEffectEntry> sWorldEffectStore("WorldEffect.db2", WorldEffectLoadInfo::Instance()); DB2Storage<WorldMapAreaEntry> sWorldMapAreaStore("WorldMapArea.db2", WorldMapAreaLoadInfo::Instance()); DB2Storage<WorldMapOverlayEntry> sWorldMapOverlayStore("WorldMapOverlay.db2", WorldMapOverlayLoadInfo::Instance()); DB2Storage<WorldMapTransformsEntry> sWorldMapTransformsStore("WorldMapTransforms.db2", WorldMapTransformsLoadInfo::Instance()); @@ -661,6 +662,7 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale) LOAD_DB2(sVehicleStore); LOAD_DB2(sVehicleSeatStore); LOAD_DB2(sWMOAreaTableStore); + LOAD_DB2(sWorldEffectStore); LOAD_DB2(sWorldMapAreaStore); LOAD_DB2(sWorldMapOverlayStore); LOAD_DB2(sWorldMapTransformsStore); diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index b25655d3ddc..c9f1bcd1eba 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -202,6 +202,7 @@ TC_GAME_API extern DB2Storage<TransportRotationEntry> sTransportRo TC_GAME_API extern DB2Storage<UnitPowerBarEntry> sUnitPowerBarStore; TC_GAME_API extern DB2Storage<VehicleEntry> sVehicleStore; TC_GAME_API extern DB2Storage<VehicleSeatEntry> sVehicleSeatStore; +TC_GAME_API extern DB2Storage<WorldEffectEntry> sWorldEffectStore; TC_GAME_API extern DB2Storage<WorldMapOverlayEntry> sWorldMapOverlayStore; TC_GAME_API extern DB2Storage<WorldSafeLocsEntry> sWorldSafeLocsStore; diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h index 341758af3ab..ba6bf40090a 100644 --- a/src/server/game/DataStores/DB2Structure.h +++ b/src/server/game/DataStores/DB2Structure.h @@ -2989,6 +2989,17 @@ struct WMOAreaTableEntry uint32 UWZoneMusic; }; +struct WorldEffectEntry +{ + uint32 ID; + uint32 TargetAsset; + uint16 CombatConditionID; + uint8 TargetType; + uint8 WhenToDisplay; + uint32 QuestFeedbackEffectID; + uint32 PlayerConditionID; +}; + struct WorldMapAreaEntry { char const* AreaName; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index e5bcf6623c4..023e827754f 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -55,7 +55,7 @@ QuaternionData QuaternionData::fromEulerAnglesZYX(float Z, float Y, float X) } GameObject::GameObject() : WorldObject(false), MapObject(), - m_model(nullptr), m_goValue(), m_AI(nullptr), _animKitId(0) + m_model(nullptr), m_goValue(), m_AI(nullptr), _animKitId(0), _worldEffectID(0) { m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; @@ -267,6 +267,12 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, Position { SetUInt32Value(GAMEOBJECT_FACTION, m_goTemplateAddon->faction); SetUInt32Value(GAMEOBJECT_FLAGS, m_goTemplateAddon->flags); + + if (m_goTemplateAddon->WorldEffectID) + { + m_updateFlag |= UPDATEFLAG_GAMEOBJECT; + SetWorldEffectID(m_goTemplateAddon->WorldEffectID); + } } SetEntry(goinfo->entry); @@ -359,6 +365,12 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, Position m_invisibility.AddValue(gameObjectAddon->invisibilityType, gameObjectAddon->InvisibilityValue); } + if (gameObjectAddon && gameObjectAddon->WorldEffectID) + { + m_updateFlag |= UPDATEFLAG_GAMEOBJECT; + SetWorldEffectID(gameObjectAddon->WorldEffectID); + } + LastUsedScriptID = GetGOInfo()->ScriptId; AIM_Initialize(); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index f91aa3d4672..5aa46577ccb 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -286,6 +286,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> uint16 GetAIAnimKitId() const override { return _animKitId; } void SetAnimKitId(uint16 animKitId, bool oneshot); + uint32 GetWorldEffectID() const { return _worldEffectID; } + void SetWorldEffectID(uint32 worldEffectID) { _worldEffectID = worldEffectID; } + void AIM_Destroy(); bool AIM_Initialize(); @@ -338,5 +341,6 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> GameObjectAI* m_AI; uint16 _animKitId; + uint32 _worldEffectID; }; #endif diff --git a/src/server/game/Entities/GameObject/GameObjectData.h b/src/server/game/Entities/GameObject/GameObjectData.h index 70d6ac14ee8..b1f4cb0fdf2 100644 --- a/src/server/game/Entities/GameObject/GameObjectData.h +++ b/src/server/game/Entities/GameObject/GameObjectData.h @@ -817,6 +817,7 @@ struct GameObjectTemplateAddon uint32 flags; uint32 mingold; uint32 maxgold; + uint32 WorldEffectID; }; @@ -844,6 +845,7 @@ struct GameObjectAddon QuaternionData ParentRotation; InvisibilityType invisibilityType; uint32 InvisibilityValue; + uint32 WorldEffectID; }; // from `gameobject` diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 03a0602da38..7c8e163d170 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -350,7 +350,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const bool AnimKitCreate = (flags & UPDATEFLAG_ANIMKITS) != 0; bool Rotation = (flags & UPDATEFLAG_ROTATION) != 0; bool HasAreaTrigger = (flags & UPDATEFLAG_AREATRIGGER) != 0; - bool HasGameObject = false; + bool HasGameObject = (flags & UPDATEFLAG_GAMEOBJECT) != 0;; bool ThisIsYou = (flags & UPDATEFLAG_SELF) != 0; bool SmoothPhasing = false; bool SceneObjCreate = false; @@ -667,14 +667,20 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const } } - //if (HasGameObject) - //{ - // *data << uint32(WorldEffectID); - // data->WriteBit(bit8); - // data->FlushBits(); - // if (bit8) - // *data << uint32(Int1); - //} + if (HasGameObject) + { + bool bit8 = false; + uint32 Int1 = 0; + + GameObject const* gameObject = ToGameObject(); + + *data << uint32(gameObject->GetWorldEffectID()); + + data->WriteBit(bit8); + data->FlushBits(); + if (bit8) + *data << uint32(Int1); + } //if (SmoothPhasing) //{ diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h index ca3bdcd4cce..b3d02b590bc 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.h +++ b/src/server/game/Entities/Object/Updates/UpdateData.h @@ -47,7 +47,7 @@ enum OBJECT_UPDATE_FLAGS UPDATEFLAG_ROTATION = 0x0080, UPDATEFLAG_ANIMKITS = 0x0100, UPDATEFLAG_AREATRIGGER = 0x0200, - //UPDATEFLAG_GAMEOBJECT = 0x0400, + UPDATEFLAG_GAMEOBJECT = 0x0400, //UPDATEFLAG_REPLACE_ACTIVE = 0x0800, //UPDATEFLAG_NO_BIRTH_ANIM = 0x1000, //UPDATEFLAG_ENABLE_PORTALS = 0x2000, diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 928de3d872e..c2020bbba10 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1201,8 +1201,8 @@ void ObjectMgr::LoadGameObjectAddons() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 5 6 - QueryResult result = WorldDatabase.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue FROM gameobject_addon"); + // 0 1 2 3 4 5 6 7 + QueryResult result = WorldDatabase.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue, WorldEffectID FROM gameobject_addon"); if (!result) { @@ -1228,6 +1228,7 @@ void ObjectMgr::LoadGameObjectAddons() gameObjectAddon.ParentRotation = QuaternionData(fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat()); gameObjectAddon.invisibilityType = InvisibilityType(fields[5].GetUInt8()); gameObjectAddon.InvisibilityValue = fields[6].GetUInt32(); + gameObjectAddon.WorldEffectID = fields[7].GetUInt32(); if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES) { @@ -1248,6 +1249,12 @@ void ObjectMgr::LoadGameObjectAddons() gameObjectAddon.ParentRotation = QuaternionData(); } + if (gameObjectAddon.WorldEffectID && !sWorldEffectStore.LookupEntry(gameObjectAddon.WorldEffectID)) + { + TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") has invalid WorldEffectID (%u) in `gameobject_addon`, set to 0.", guid, gameObjectAddon.WorldEffectID); + gameObjectAddon.WorldEffectID = 0; + } + ++count; } while (result->NextRow()); @@ -7132,8 +7139,8 @@ void ObjectMgr::LoadGameObjectTemplateAddons() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 - QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold FROM gameobject_template_addon"); + // 0 1 2 3 4 5 + QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, WorldEffectID FROM gameobject_template_addon"); if (!result) { @@ -7156,10 +7163,11 @@ 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(); // checks if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction)) @@ -7178,6 +7186,12 @@ void ObjectMgr::LoadGameObjectTemplateAddons() } } + if (gameObjectAddon.WorldEffectID && !sWorldEffectStore.LookupEntry(gameObjectAddon.WorldEffectID)) + { + TC_LOG_ERROR("sql.sql", "GameObject (Entry: %u) has invalid WorldEffectID (%u) defined in `gameobject_template_addon`, set to 0.", entry, gameObjectAddon.WorldEffectID); + gameObjectAddon.WorldEffectID = 0; + } + ++count; } while (result->NextRow()); |