aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Battlefield/Battlefield.cpp2
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp2
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp4
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp92
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h23
-rw-r--r--src/server/game/Entities/Object/Object.cpp4
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp3
-rw-r--r--src/server/game/Garrison/Garrison.cpp4
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp55
-rw-r--r--src/server/game/Spells/SpellEffects.cpp12
10 files changed, 111 insertions, 90 deletions
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index 62883b8cda5..9e6012c42c2 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -828,7 +828,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
// Create gameobject
GameObject* go = new GameObject;
- if (!go->Create(entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY))
+ if (!go->Create(entry, map, PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(), 100, GO_STATE_READY))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template %u! Battlefield has not been created!", entry);
delete go;
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index a6666dc1a04..85fab8e1ae5 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1457,7 +1457,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
// So we must create it specific for this instance
GameObject* go = new GameObject;
- if (!go->Create(entry, GetBgMap(), PHASEMASK_NORMAL, x, y, z, o, rotation0, rotation1, rotation2, rotation3, 100, goState))
+ if (!go->Create(entry, GetBgMap(), PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, goState))
{
TC_LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
index 57fb048ba18..0224adbdbea 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
@@ -151,8 +151,8 @@ bool BattlegroundSA::ResetObjs()
}
// MAD props for Kiper for discovering those values - 4 hours of his work.
- GetBGObject(BG_SA_BOAT_ONE)->UpdateRotationFields(1.0f, 0.0002f);
- GetBGObject(BG_SA_BOAT_TWO)->UpdateRotationFields(1.0f, 0.00001f);
+ GetBGObject(BG_SA_BOAT_ONE)->SetParentRotation(G3D::Quat(0.f, 0.f, 1.0f, 0.0002f));
+ GetBGObject(BG_SA_BOAT_TWO)->SetParentRotation(G3D::Quat(0.f, 0.f, 1.0f, 0.00001f));
SpawnBGObject(BG_SA_BOAT_ONE, RESPAWN_IMMEDIATELY);
SpawnBGObject(BG_SA_BOAT_TWO, RESPAWN_IMMEDIATELY);
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 1f5b11c022e..2e5f8b43280 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -55,10 +55,10 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_cooldownTime = 0;
m_goInfo = nullptr;
m_goData = nullptr;
+ m_packedRotation = 0;
m_goTemplateAddon = nullptr;
m_spawnId = UI64LIT(0);
- m_rotation = 0;
m_groupLootTimer = 0;
@@ -178,7 +178,7 @@ void GameObject::RemoveFromWorld()
}
}
-bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit)
+bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit)
{
ASSERT(map);
SetMap(map);
@@ -232,10 +232,15 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x,
return false;
}
- SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0);
- SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1);
+ SetWorldRotation(rotation);
+ GameObjectAddon const* gameObjectAddon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
- UpdateRotationFields(rotation2, rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3
+ // For most of gameobjects is (0, 0, 0, 1) quaternion, there are only some transports with not standard rotation
+ G3D::Quat parentRotation;
+ if (gameObjectAddon)
+ parentRotation = gameObjectAddon->ParentRotation;
+
+ SetParentRotation(parentRotation);
SetObjectScale(goinfo->size);
@@ -327,13 +332,10 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x,
break;
}
- if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId()))
+ if (gameObjectAddon && gameObjectAddon->InvisibilityValue)
{
- if (addon->InvisibilityValue)
- {
- m_invisibility.AddFlag(addon->invisibilityType);
- m_invisibility.AddValue(addon->invisibilityType, addon->InvisibilityValue);
- }
+ m_invisibility.AddFlag(gameObjectAddon->invisibilityType);
+ m_invisibility.AddValue(gameObjectAddon->invisibilityType, gameObjectAddon->InvisibilityValue);
}
LastUsedScriptID = GetGOInfo()->ScriptId;
@@ -844,10 +846,7 @@ void GameObject::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
data.posY = GetPositionY();
data.posZ = GetPositionZ();
data.orientation = GetOrientation();
- data.rotation0 = GetFloatValue(GAMEOBJECT_PARENTROTATION+0);
- data.rotation1 = GetFloatValue(GAMEOBJECT_PARENTROTATION+1);
- data.rotation2 = GetFloatValue(GAMEOBJECT_PARENTROTATION+2);
- data.rotation3 = GetFloatValue(GAMEOBJECT_PARENTROTATION+3);
+ data.rotation = m_worldRotation;
data.spawntimesecs = m_spawnedByDefault ? m_respawnDelayTime : -(int32)m_respawnDelayTime;
data.animprogress = GetGoAnimProgress();
data.go_state = GetGoState();
@@ -872,10 +871,10 @@ void GameObject::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
stmt->setFloat(index++, GetPositionY());
stmt->setFloat(index++, GetPositionZ());
stmt->setFloat(index++, GetOrientation());
- stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION));
- stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+1));
- stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+2));
- stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+3));
+ stmt->setFloat(index++, m_worldRotation.x);
+ stmt->setFloat(index++, m_worldRotation.y);
+ stmt->setFloat(index++, m_worldRotation.z);
+ stmt->setFloat(index++, m_worldRotation.w);
stmt->setInt32(index++, int32(m_respawnDelayTime));
stmt->setUInt8(index++, GetGoAnimProgress());
stmt->setUInt8(index++, uint8(GetGoState()));
@@ -901,17 +900,12 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
float z = data->posZ;
float ang = data->orientation;
- float rotation0 = data->rotation0;
- float rotation1 = data->rotation1;
- float rotation2 = data->rotation2;
- float rotation3 = data->rotation3;
-
uint32 animprogress = data->animprogress;
GOState go_state = data->go_state;
uint32 artKit = data->artKit;
m_spawnId = spawnId;
- if (!Create(entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
+ if (!Create(entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit))
return false;
if (data->phaseid)
@@ -2000,34 +1994,38 @@ std::string const & GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) cons
return GetName();
}
-void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 /*=0.0f*/)
+void GameObject::UpdatePackedRotation()
{
- static double const atan_pow = atan(pow(2.0f, -20.0f));
+ static const int32 PACK_YZ = 1 << 20;
+ static const int32 PACK_X = PACK_YZ << 1;
- double f_rot1 = std::sin(GetOrientation() / 2.0f);
- double f_rot2 = std::cos(GetOrientation() / 2.0f);
+ static const int32 PACK_YZ_MASK = (PACK_YZ << 1) - 1;
+ static const int32 PACK_X_MASK = (PACK_X << 1) - 1;
- int64 i_rot1 = int64(f_rot1 / atan_pow *(f_rot2 >= 0 ? 1.0f : -1.0f));
- int64 rotation = (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
-
- //float f_rot2 = std::sin(0.0f / 2.0f);
- //int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f));
- //rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000;
-
- //float f_rot3 = std::sin(0.0f / 2.0f);
- //int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f));
- //rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000;
+ int8 w_sign = (m_worldRotation.w >= 0.f ? 1 : -1);
+ int64 x = int32(m_worldRotation.x * PACK_X) * w_sign & PACK_X_MASK;
+ int64 y = int32(m_worldRotation.y * PACK_YZ) * w_sign & PACK_YZ_MASK;
+ int64 z = int32(m_worldRotation.z * PACK_YZ) * w_sign & PACK_YZ_MASK;
+ m_packedRotation = z | (y << 21) | (x << 42);
+}
- m_rotation = rotation;
+void GameObject::SetWorldRotation(G3D::Quat const& rot)
+{
+ m_worldRotation = rot.toUnit();
+ UpdatePackedRotation();
+}
- if (rotation2 == 0.0f && rotation3 == 0.0f)
- {
- rotation2 = (float)f_rot1;
- rotation3 = (float)f_rot2;
- }
+void GameObject::SetParentRotation(G3D::Quat const& rotation)
+{
+ SetFloatValue(GAMEOBJECT_PARENTROTATION + 0, rotation.x);
+ SetFloatValue(GAMEOBJECT_PARENTROTATION + 1, rotation.y);
+ SetFloatValue(GAMEOBJECT_PARENTROTATION + 2, rotation.z);
+ SetFloatValue(GAMEOBJECT_PARENTROTATION + 3, rotation.w);
+}
- SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
- SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
+void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
+{
+ SetWorldRotation(G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot)));
}
void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= nullptr*/, uint32 spellId /*= 0*/)
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 2020fac7ded..55c5c473e95 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -25,6 +25,7 @@
#include "Object.h"
#include "LootMgr.h"
#include "DatabaseEnv.h"
+#include <G3D/Quat.h>
class GameObjectAI;
class Group;
@@ -866,6 +867,7 @@ struct GameObjectLocale
// `gameobject_addon` table
struct GameObjectAddon
{
+ G3D::Quat ParentRotation;
InvisibilityType invisibilityType;
uint32 InvisibilityValue;
};
@@ -888,8 +890,7 @@ enum GOState
// from `gameobject`
struct GameObjectData
{
- explicit GameObjectData() : id(0), mapid(0), phaseMask(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f),
- rotation0(0.0f), rotation1(0.0f), rotation2(0.0f), rotation3(0.0f), spawntimesecs(0),
+ explicit GameObjectData() : id(0), mapid(0), phaseMask(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), phaseid(0), phaseGroup(0), dbData(true) { }
uint32 id; // entry in gamobject_template
uint16 mapid;
@@ -898,10 +899,7 @@ struct GameObjectData
float posY;
float posZ;
float orientation;
- float rotation0;
- float rotation1;
- float rotation2;
- float rotation3;
+ G3D::Quat rotation;
int32 spawntimesecs;
uint32 animprogress;
GOState go_state;
@@ -945,7 +943,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
void RemoveFromWorld() override;
void CleanupsBeforeDelete(bool finalCleanup = true) override;
- bool Create(uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0);
+ bool Create(uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0);
void Update(uint32 p_time) override;
GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
GameObjectTemplateAddon const* GetTemplateAddon() const { return m_goTemplateAddon; }
@@ -958,7 +956,11 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
ObjectGuid::LowType GetSpawnId() const { return m_spawnId; }
- void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f);
+ // z_rot, y_rot, x_rot - rotation angles around z, y and x axes
+ void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
+ void SetWorldRotation(G3D::Quat const& rot);
+ void SetParentRotation(G3D::Quat const& rotation); // transforms(rotates) transport's path
+ int64 GetPackedWorldRotation() const { return m_packedRotation; }
// overwrite WorldObject function for proper name localization
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
@@ -1114,7 +1116,6 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
void EventInform(uint32 eventId, WorldObject* invoker = NULL);
- uint64 GetRotation() const { return m_rotation; }
virtual uint32 GetScriptId() const { return GetGOInfo()->ScriptId; }
GameObjectAI* AI() const { return m_AI; }
@@ -1173,7 +1174,8 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
GameObjectData const* m_goData;
GameObjectValue m_goValue;
- uint64 m_rotation;
+ int64 m_packedRotation;
+ G3D::Quat m_worldRotation;
Position m_stationaryPosition;
ObjectGuid m_lootRecipient;
@@ -1182,6 +1184,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
private:
void RemoveFromOwner();
void SwitchDoorOrButton(bool activate, bool alternative = false);
+ void UpdatePackedRotation();
//! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size.
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const override
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index da3c9319180..67cde258ed9 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -498,7 +498,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const
}
if (Rotation)
- *data << uint64(ToGameObject()->GetRotation()); // Rotation
+ *data << uint64(ToGameObject()->GetPackedWorldRotation()); // Rotation
if (GameObject const* go = ToGameObject())
for (uint32 i = 0; i < PauseTimesCount; ++i)
@@ -2489,7 +2489,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
Map* map = GetMap();
GameObject* go = new GameObject();
- if (!go->Create(entry, map, GetPhaseMask(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
+ if (!go->Create(entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
{
delete go;
return NULL;
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index e9b850530e3..42112c9845d 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -95,7 +95,8 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid,
SetGoType(GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT);
SetGoAnimProgress(animprogress);
SetName(goinfo->name);
- UpdateRotationFields(0.0f, 1.0f);
+ SetWorldRotation(G3D::Quat());
+ SetParentRotation(G3D::Quat());
m_model = CreateModel();
return true;
diff --git a/src/server/game/Garrison/Garrison.cpp b/src/server/game/Garrison/Garrison.cpp
index a5b0089a10f..afc22e9c176 100644
--- a/src/server/game/Garrison/Garrison.cpp
+++ b/src/server/game/Garrison/Garrison.cpp
@@ -727,7 +727,7 @@ GameObject* Garrison::Plot::CreateGameObject(Map* map, GarrisonFactionIndex fact
Position const& pos = PacketInfo.PlotPos;
GameObject* building = new GameObject();
- if (!building->Create(entry, map, 0, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 255, GO_STATE_READY))
+ if (!building->Create(entry, map, 0, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), G3D::Quat(), 255, GO_STATE_READY))
{
delete building;
return nullptr;
@@ -740,7 +740,7 @@ GameObject* Garrison::Plot::CreateGameObject(Map* map, GarrisonFactionIndex fact
Position const& pos2 = finalizeInfo->FactionInfo[faction].Pos;
GameObject* finalizer = new GameObject();
if (finalizer->Create(finalizeInfo->FactionInfo[faction].GameObjectId, map, 0, pos2.GetPositionX(), pos2.GetPositionY(),
- pos2.GetPositionZ(), pos2.GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 255, GO_STATE_READY))
+ pos2.GetPositionZ(), pos2.GetOrientation(), G3D::Quat(), 255, GO_STATE_READY))
{
// set some spell id to make the object delete itself after use
finalizer->SetSpellId(finalizer->GetGOInfo()->goober.spell);
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;
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 2837d320d06..c9d7f5dc2c9 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3158,7 +3158,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
Map* map = target->GetMap();
- if (!pGameObj->Create(gameobject_id, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
+ if (!pGameObj->Create(gameobject_id, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY))
{
delete pGameObj;
return;
@@ -3184,7 +3184,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
{
GameObject* linkedGO = new GameObject;
- if (linkedGO->Create(linkedEntry, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
+ if (linkedGO->Create(linkedEntry, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY))
{
linkedGO->CopyPhaseFrom(m_caster);
@@ -3782,7 +3782,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2,
m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2,
m_caster->GetPositionZ(),
- m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
+ m_caster->GetOrientation(), G3D::Quat(), 0, GO_STATE_READY))
{
delete pGameObj;
return;
@@ -4117,7 +4117,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
Map* map = m_caster->GetMap();
- if (!go->Create(go_id, map, 0, x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
+ if (!go->Create(go_id, map, m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), G3D::Quat(), 0, GO_STATE_READY))
{
delete go;
return;
@@ -4785,7 +4785,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
GameObject* pGameObj = new GameObject;
- if (!pGameObj->Create(name_id, cMap, 0, fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
+ if (!pGameObj->Create(name_id, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY))
{
delete pGameObj;
return;
@@ -4852,7 +4852,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
{
GameObject* linkedGO = new GameObject;
- if (linkedGO->Create(linkedEntry, cMap, 0, fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
+ if (linkedGO->Create(linkedEntry, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY))
{
linkedGO->CopyPhaseFrom(m_caster);