diff options
author | ariel- <ariel.silva305@gmail.com> | 2016-07-30 11:34:02 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-02-11 19:10:43 +0100 |
commit | 02cef6f034804eb7291f7539936226c0552cad7f (patch) | |
tree | 6fb33c17902d8fd6e7435a6199c21eefc989fd82 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 07f2f37329dc62944a9c22df7c76f5e0e85e7886 (diff) |
Core/GameObjects: Gameobject rotation (from cmangos/mangos-wotlk@2bcbc0f) (#14146)
cmangos/mangos-wotlk@0fe88f35dfb: [11531] Normalize gameobject's quaternion, thanks to zergtmn for pointing
cmangos/mangos-wotlk@060dfb791b: [11667] Implement transport path rotation
cmangos/mangos-wotlk@565f52c6c1: [11806] A bit gameobject code refactoring
cmangos/mangos-wotlk@6874951: [11807] Add gameobject_addon table
Closes #14146
(cherry picked from commit 2967bf59b4a47837b85c995b732a6761c9c35f7e)
# Conflicts:
# src/server/game/Battlefield/Battlefield.cpp
# src/server/game/Battlegrounds/Battleground.cpp
# src/server/game/Entities/GameObject/GameObject.cpp
# src/server/game/Entities/GameObject/GameObject.h
# src/server/game/Entities/Object/Object.cpp
# src/server/game/Globals/ObjectMgr.cpp
# src/server/game/Spells/SpellEffects.cpp
# src/server/scripts/Commands/cs_gobject.cpp
# src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp
# src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 05ebcbb8c04..b71daece32b 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1120,8 +1120,8 @@ void ObjectMgr::LoadGameObjectAddons() { uint32 oldMSTime = getMSTime(); - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon"); + // 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"); if (!result) { @@ -1136,7 +1136,7 @@ void ObjectMgr::LoadGameObjectAddons() ObjectGuid::LowType guid = fields[0].GetUInt64(); - const GameObjectData* goData = GetGOData(guid); + GameObjectData const* goData = GetGOData(guid); if (!goData) { TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") does not exist but has a record in `gameobject_addon`", guid); @@ -1144,12 +1144,13 @@ void ObjectMgr::LoadGameObjectAddons() } GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid]; - gameObjectAddon.invisibilityType = InvisibilityType(fields[1].GetUInt8()); - gameObjectAddon.InvisibilityValue = fields[2].GetUInt32(); + gameObjectAddon.ParentRotation = G3D::Quat(fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat()); + gameObjectAddon.invisibilityType = InvisibilityType(fields[5].GetUInt8()); + gameObjectAddon.InvisibilityValue = fields[6].GetUInt32(); if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES) { - TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") has invalid InvisibilityType in `gameobject_addon`", guid); + TC_LOG_ERROR("sql.sql", "GameObject (GUID: " UI64FMTD ") has invalid InvisibilityType in `gameobject_addon`, disabled invisibility", guid); gameObjectAddon.invisibilityType = INVISIBILITY_GENERAL; gameObjectAddon.InvisibilityValue = 0; } @@ -1160,6 +1161,12 @@ void ObjectMgr::LoadGameObjectAddons() gameObjectAddon.InvisibilityValue = 1; } + if (!gameObjectAddon.ParentRotation.isUnit()) + { + TC_LOG_ERROR("sql.sql", "GameObject (GUID: %u) has invalid parent rotation, set to default", guid); + gameObjectAddon.ParentRotation = G3D::Quat(); + } + ++count; } while (result->NextRow()); @@ -2003,10 +2010,10 @@ ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, fl data.posY = y; data.posZ = z; data.orientation = o; - data.rotation0 = rotation0; - data.rotation1 = rotation1; - data.rotation2 = rotation2; - data.rotation3 = rotation3; + data.rotation.x = rotation0; + data.rotation.y = rotation1; + data.rotation.z = rotation2; + data.rotation.w = rotation3; data.spawntimesecs = spawntimedelay; data.animprogress = 100; data.spawnMask = 1; @@ -2153,10 +2160,10 @@ void ObjectMgr::LoadGameobjects() data.posY = fields[4].GetFloat(); data.posZ = fields[5].GetFloat(); data.orientation = fields[6].GetFloat(); - data.rotation0 = fields[7].GetFloat(); - data.rotation1 = fields[8].GetFloat(); - data.rotation2 = fields[9].GetFloat(); - data.rotation3 = fields[10].GetFloat(); + data.rotation.x = fields[7].GetFloat(); + data.rotation.y = fields[8].GetFloat(); + data.rotation.z = fields[9].GetFloat(); + data.rotation.w = fields[10].GetFloat(); data.spawntimesecs = fields[11].GetInt32(); MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid); @@ -2241,15 +2248,27 @@ void ObjectMgr::LoadGameobjects() data.orientation = Position::NormalizeOrientation(data.orientation); } - if (data.rotation2 < -1.0f || data.rotation2 > 1.0f) + if (data.rotation.x < -1.0f || data.rotation.x > 1.0f) + { + TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid rotationX (%f) value, skip", guid, data.id, data.rotation.x); + continue; + } + + if (data.rotation.y < -1.0f || data.rotation.y > 1.0f) + { + TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid rotationY (%f) value, skip", guid, data.id, data.rotation.y); + continue; + } + + if (data.rotation.z < -1.0f || data.rotation.z > 1.0f) { - TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid rotation2 (%f) value, skip", guid, data.id, data.rotation2); + TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid rotationZ (%f) value, skip", guid, data.id, data.rotation.z); continue; } - if (data.rotation3 < -1.0f || data.rotation3 > 1.0f) + if (data.rotation.w < -1.0f || data.rotation.w > 1.0f) { - TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid rotation3 (%f) value, skip", guid, data.id, data.rotation3); + TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with invalid rotationW (%f) value, skip", guid, data.id, data.rotation.w); continue; } |