aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Player/Player.cpp25
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp4
-rw-r--r--src/server/game/Spells/SpellEffects.cpp11
3 files changed, 32 insertions, 8 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 71523c72842..eaee6dc090a 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2178,8 +2178,26 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!(options & TELE_TO_NOT_LEAVE_COMBAT))
CombatStop();
+ // new final coordinates
+ float final_x = x;
+ float final_y = y;
+ float final_z = z;
+ float final_o = orientation;
+
+ // Calculate final positions if on transport
+ if (m_transport)
+ {
+ float tx, ty, tz, to;
+ m_movementInfo.transport.pos.GetPosition(tx, ty, tz, to);
+
+ final_x = x + tx * std::cos(orientation) - ty * std::sin(orientation);
+ final_y = y + ty * std::cos(orientation) + tx * std::sin(orientation);
+ final_z = z + tz;
+ final_o = Position::NormalizeOrientation(orientation + m_movementInfo.transport.pos.GetOrientation());
+ }
+
// this will be used instead of the current location in SaveToDB
- m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
+ m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
SetFallInformation(0, z);
// code for finish transfer called in WorldSession::HandleMovementOpcodes()
@@ -2190,7 +2208,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
{
Position oldPos;
GetPosition(&oldPos);
- Relocate(x, y, z, orientation);
+ Relocate(final_x, final_y, final_z, final_o);
SendTeleportAckPacket();
SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place
}
@@ -2292,6 +2310,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
float final_z = z;
float final_o = orientation;
+ // Calculate final positions if on transport
if (m_transport)
{
float tx, ty, tz, to;
@@ -2304,7 +2323,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
}
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
- SetFallInformation(0, final_z);
+ SetFallInformation(0, z);
// if the player is saved before worldportack (at logout for example)
// this will be used instead of the current location in SaveToDB
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index e7853964542..30b7b61f574 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -181,8 +181,8 @@ void Transport::Update(uint32 diff)
float t = CalculateSegmentPos(float(timer) * 0.001f);
G3D::Vector3 pos, dir;
_currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
- //_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
- UpdatePosition(pos.x, pos.y, pos.z, 0.0f/*atan2(dir.x, dir.y)*/);
+ _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
+ UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.x, dir.y));
}
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 562d7fee518..0732c389bfa 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1150,10 +1150,15 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
orientation = m_targets.GetUnitTarget()->GetOrientation();
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation);
- if (mapid == unitTarget->GetMapId())
- unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
- else if (unitTarget->GetTypeId() == TYPEID_PLAYER)
+ if (unitTarget->GetTypeId() == TYPEID_PLAYER)
unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0);
+ else if (mapid == unitTarget->GetMapId())
+ unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
+ else
+ {
+ TC_LOG_ERROR(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - spellId %u attempted to teleport creature to a different map.", m_spellInfo->Id);
+ return;
+ }
// post effects for TARGET_DEST_DB
switch (m_spellInfo->Id)