Core/Units: Properly update passenger position if vehicle uses waypoint movement. Fixes e.g. Icefang path
This commit is contained in:
@@ -17171,14 +17171,18 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
GetMap()->CreatureRelocation(ToCreature(), x, y, z, orientation);
|
||||
}
|
||||
else if (turn)
|
||||
SetOrientation(orientation);
|
||||
|
||||
if ((relocated || turn) && IsVehicle())
|
||||
GetVehicleKit()->RelocatePassengers(x, y, z, orientation);
|
||||
UpdateOrientation(orientation);
|
||||
|
||||
return (relocated || turn);
|
||||
}
|
||||
|
||||
void Unit::UpdateOrientation(float orientation)
|
||||
{
|
||||
SetOrientation(orientation);
|
||||
if (IsVehicle())
|
||||
GetVehicleKit()->RelocatePassengers(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||
}
|
||||
|
||||
void Unit::SendThreatListUpdate()
|
||||
{
|
||||
if (!getThreatManager().isThreatListEmpty())
|
||||
|
||||
@@ -1614,6 +1614,7 @@ class Unit : public WorldObject
|
||||
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false);
|
||||
// returns true if unit's position really changed
|
||||
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
|
||||
void UpdateOrientation(float orientation);
|
||||
|
||||
void KnockbackFrom(float x, float y, float speedXY, float speedZ);
|
||||
void JumpTo(float speedXY, float speedZ, bool forward = true);
|
||||
|
||||
@@ -431,6 +431,7 @@ void Vehicle::RemovePassenger(Unit* unit)
|
||||
sScriptMgr->OnRemovePassenger(this, unit);
|
||||
}
|
||||
|
||||
//! Must be called after m_base::Relocate
|
||||
void Vehicle::RelocatePassengers(float x, float y, float z, float ang)
|
||||
{
|
||||
ASSERT(_me->GetMap());
|
||||
@@ -440,8 +441,6 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang)
|
||||
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger))
|
||||
{
|
||||
ASSERT(passenger->IsInWorld());
|
||||
ASSERT(passenger->IsOnVehicle(GetBase()));
|
||||
ASSERT(GetSeatForPassenger(passenger));
|
||||
|
||||
float px = x + passenger->m_movementInfo.t_pos.m_positionX;
|
||||
float py = y + passenger->m_movementInfo.t_pos.m_positionY;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "Group.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "DynamicTree.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
union u_map_magic
|
||||
{
|
||||
@@ -702,6 +703,8 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie
|
||||
Cell new_cell(x, y);
|
||||
|
||||
player->Relocate(x, y, z, orientation);
|
||||
if (player->IsVehicle())
|
||||
player->GetVehicleKit()->RelocatePassengers(x, y, z, orientation);
|
||||
|
||||
if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
|
||||
{
|
||||
@@ -740,6 +743,8 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa
|
||||
else
|
||||
{
|
||||
creature->Relocate(x, y, z, ang);
|
||||
if (creature->IsVehicle())
|
||||
creature->GetVehicleKit()->RelocatePassengers(x, y, z, ang);
|
||||
creature->UpdateObjectVisibility(false);
|
||||
RemoveCreatureFromMoveList(creature);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user