Entities/Unit: Add overload to NearTeleportTo taking Position const&.

This commit is contained in:
Aokromes
2016-08-27 09:30:32 +02:00
parent e12a7116f8
commit 9feafe00bb
3 changed files with 13 additions and 7 deletions

View File

@@ -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()) { }

View File

@@ -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

View File

@@ -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);