Core/Units: Properly update passenger position if vehicle uses waypoint movement. Fixes e.g. Icefang path

This commit is contained in:
Machiavelli
2012-03-01 17:06:41 +01:00
parent 844e2ca857
commit 6bb689b494
4 changed files with 15 additions and 6 deletions
+8 -4
View File
@@ -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())
+1
View File
@@ -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);
+1 -2
View File
@@ -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;
+5
View File
@@ -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);
}