diff options
author | ShinDarth <borzifrancesco@gmail.com> | 2014-09-19 22:36:50 +0100 |
---|---|---|
committer | DDuarte <dnpd.dd@gmail.com> | 2014-09-19 22:36:50 +0100 |
commit | 83f82b4a040430d13c6e2ec24730e556f6d8feb9 (patch) | |
tree | 0baf665c0654bf15198cf6c042009b2951c7ad0f | |
parent | 0f2e63852c5dba46c61e4ca51091bfbeb353ac2a (diff) |
Core/ObjectMgr: check creature.orientation and gameobject.orientation range in loading
Closes #13156
-rw-r--r-- | sql/updates/world/2014_09_19_06_world_normalize_orientation.sql | 2 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/sql/updates/world/2014_09_19_06_world_normalize_orientation.sql b/sql/updates/world/2014_09_19_06_world_normalize_orientation.sql new file mode 100644 index 00000000000..cf808c3ad82 --- /dev/null +++ b/sql/updates/world/2014_09_19_06_world_normalize_orientation.sql @@ -0,0 +1,2 @@ +UPDATE `creature` SET `orientation` = MOD(`orientation`, 2*PI()) WHERE `guid` IN (42160, 207528); +UPDATE `gameobject` SET `orientation` = MOD(`orientation`, 2*PI()) WHERE `guid` = 7607; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 50d8ffec5ae..da63150df5d 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -34,6 +34,7 @@ #include "LFGMgr.h" #include "Log.h" #include "MapManager.h" +#include "Object.h" #include "ObjectMgr.h" #include "Pet.h" #include "PoolMgr.h" @@ -1727,6 +1728,12 @@ void ObjectMgr::LoadCreatures() data.phaseMask = 1; } + if (std::abs(data.orientation) > 2 * float(M_PI)) + { + TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with abs(`orientation`) > 2*PI (orientation is expressed in radians), normalized.", guid, data.id); + data.orientation = Position::NormalizeOrientation(data.orientation); + } + // Add to grid if not managed by the game event or pool system if (gameEvent == 0 && PoolId == 0) AddCreatureToGrid(guid, &data); @@ -2009,6 +2016,12 @@ void ObjectMgr::LoadGameobjects() int16 gameEvent = fields[16].GetInt8(); uint32 PoolId = fields[17].GetUInt32(); + if (std::abs(data.orientation) > 2 * float(M_PI)) + { + TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) with abs(`orientation`) > 2*PI (orientation is expressed in radians), normalized.", guid, data.id); + data.orientation = Position::NormalizeOrientation(data.orientation); + } + if (data.rotation2 < -1.0f || data.rotation2 > 1.0f) { TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) with invalid rotation2 (%f) value, skip", guid, data.id, data.rotation2); |