From 9feafe00bb2082501cbda450a7cbfc13488f41e8 Mon Sep 17 00:00:00 2001 From: Aokromes Date: Sat, 27 Aug 2016 09:30:32 +0200 Subject: [PATCH] Entities/Unit: Add overload to NearTeleportTo taking Position const&. --- src/server/game/Entities/Object/Object.h | 3 +++ src/server/game/Entities/Unit/Unit.cpp | 12 +++++++----- src/server/game/Entities/Unit/Unit.h | 5 +++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 72441cb14de..03fda176f50 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -348,6 +348,9 @@ class WorldLocation : public Position explicit WorldLocation(uint32 _mapId = MAPID_INVALID, float _x = 0.f, float _y = 0.f, float _z = 0.f, float _o = 0.f) : Position(_x, _y, _z, _o), m_mapId(_mapId) { } + WorldLocation(uint32 mapId, Position const& position) + : Position(position), m_mapId(mapId) { } + WorldLocation(WorldLocation const& loc) : Position(loc), m_mapId(loc.GetMapId()) { } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5943b0edf33..51f89f3c374 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -15876,16 +15876,18 @@ bool Unit::IsFalling() const return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR) || movespline->isFalling(); } -void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/) +void Unit::NearTeleportTo(Position const& pos, bool casting /*= false*/) { DisableSpline(); if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); + { + WorldLocation target(GetMapId(), pos); + ToPlayer()->TeleportTo(target, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); + } else { - Position pos = {x, y, z, orientation}; SendTeleportPacket(pos); - UpdatePosition(x, y, z, orientation, true); + UpdatePosition(pos, true); UpdateObjectVisibility(); } } @@ -16109,7 +16111,7 @@ void Unit::WriteMovementInfo(WorldPacket& data, Movement::ExtraMovementStatusEle } } -void Unit::SendTeleportPacket(Position& pos) +void Unit::SendTeleportPacket(Position const& pos) { // SMSG_MOVE_UPDATE_TELEPORT is sent to nearby players to signal the teleport // MSG_MOVE_TELEPORT is sent to self in order to trigger MSG_MOVE_TELEPORT_ACK and update the position server side diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 93632ea43c4..9841e0c9cae 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1592,8 +1592,9 @@ class TC_GAME_API Unit : public WorldObject void SendSpellDamageResist(Unit* target, uint32 spellId); void SendSpellDamageImmune(Unit* target, uint32 spellId); - void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); - void SendTeleportPacket(Position& pos); + void NearTeleportTo(Position const& pos, bool casting = false); + void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false) { NearTeleportTo(Position(x, y, z, orientation), casting); } + void SendTeleportPacket(Position const& pos); virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); // returns true if unit's position really changed virtual bool UpdatePosition(const Position &pos, bool teleport = false);