diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 232438ebf40..2d2db26ef89 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -15902,7 +15902,7 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca // FIXME: this interrupts spell visual DestroyForNearbyPlayers(); - GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation); + SetPosition(x, y, z, orientation, true); //ObjectAccessor::UpdateObjectVisibility(this); //WorldPacket data; @@ -15913,6 +15913,40 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca } } +bool Unit::SetPosition(float x, float y, float z, float orientation, bool teleport) +{ + // prevent crash when a bad coord is sent by the client + if (!Trinity::IsValidMapCoord(x,y)) + { + sLog.outDebug("Unit::SetPosition(%f, %f, %f) .. bad coordinates!",x,y,z); + return false; + } + + bool turn = (GetOrientation() != orientation); + bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || GetPositionZ() != z); + + if (turn) + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING); + + if (relocated) + { + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE); + + // move and update visible state if need + if(GetTypeId() == TYPEID_PLAYER) + GetMap()->PlayerRelocation((Player*)this, x, y, z, orientation); + else + GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation); + } + else if(turn) + SetOrientation(orientation); + + if ((relocated || turn) && IsVehicle()) + GetVehicleKit()->RelocatePassengers(x,y,z,orientation); + + return true; +} + void Unit::SendThreatListUpdate() { if (uint32 count = getThreatManager().getThreatList().size()) |