Core/Vehicles&Movement:
- Send correct SMSG_MONSTER_MOVE with newly discovered SPLINEFLAG_EXIT_VEHICLE on vehicle exit. Fixes the "stuck on exit" bug as a result of removing the previous hack in 04b656a44f.
- Use SMSG_SPLINE_MOVE_ROOT and SMSG_SPLINE_MOVE_UNROOT as root packets for creatures.
- Reimplement toggling of MOVEMENTFLAG_ROOT on root event (including enter vehicle)
- Speedup in fetching movementflags for vehicles depending on vehicleflags on object updates.
- Code cleanup and refactoring
This commit is contained in:
@@ -435,6 +435,27 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMoveExitVehicle(Position const* newPos)
|
||||
{
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, 1+12+4+1+4+4+4+12+GetPackGUID().size());
|
||||
data.append(GetPackGUID());
|
||||
|
||||
data << uint8(GetTypeId() == TYPEID_PLAYER ? 1 : 0); // new in 3.1, bool
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
data << getMSTime();
|
||||
|
||||
data << uint8(SPLINETYPE_FACING_ANGLE);
|
||||
data << float(GetOrientation()); // guess
|
||||
data << uint32(SPLINEFLAG_EXIT_VEHICLE);
|
||||
data << uint32(0); // Time in between points
|
||||
data << uint32(1); // 1 single waypoint
|
||||
data << newPos->GetPositionX();
|
||||
data << newPos->GetPositionY();
|
||||
data << newPos->GetPositionZ();
|
||||
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMoveTransport(Unit *vehicleOwner)
|
||||
{
|
||||
// TODO: Turn into BuildMonsterMoveTransport packet and allow certain variables (for npc movement aboard vehicles)
|
||||
@@ -442,7 +463,7 @@ void Unit::SendMonsterMoveTransport(Unit *vehicleOwner)
|
||||
data.append(GetPackGUID());
|
||||
data.append(vehicleOwner->GetPackGUID());
|
||||
data << int8(GetTransSeat());
|
||||
data << uint8(0); // unk boolean
|
||||
data << uint8(GetTypeId() == TYPEID_PLAYER ? 1 : 0); // boolean
|
||||
data << GetPositionX() - vehicleOwner->GetPositionX();
|
||||
data << GetPositionY() - vehicleOwner->GetPositionY();
|
||||
data << GetPositionZ() - vehicleOwner->GetPositionZ();
|
||||
@@ -451,7 +472,7 @@ void Unit::SendMonsterMoveTransport(Unit *vehicleOwner)
|
||||
data << GetTransOffsetO(); // facing angle?
|
||||
data << uint32(SPLINEFLAG_TRANSPORT);
|
||||
data << uint32(GetTransTime()); // move time
|
||||
data << uint32(0); // amount of waypoints
|
||||
data << uint32(1); // amount of waypoints
|
||||
data << uint32(0); // waypoint X
|
||||
data << uint32(0); // waypoint Y
|
||||
data << uint32(0); // waypoint Z
|
||||
@@ -15301,28 +15322,42 @@ void Unit::SetRooted(bool apply)
|
||||
if (m_rootTimes > 0) //blizzard internal check?
|
||||
m_rootTimes++;
|
||||
|
||||
// AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
|
||||
|
||||
WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
|
||||
data.append(GetPackGUID());
|
||||
data << m_rootTimes;
|
||||
SendMessageToSet(&data,true);
|
||||
|
||||
if (GetTypeId() != TYPEID_PLAYER)
|
||||
if (Player* thisPlr = this->ToPlayer())
|
||||
{
|
||||
WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
|
||||
data.append(GetPackGUID());
|
||||
data << m_rootTimes;
|
||||
SendMessageToSet(&data,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldPacket data(SMSG_SPLINE_MOVE_ROOT, 8);
|
||||
data.append(GetPackGUID());
|
||||
SendMessageToSet(&data,true);
|
||||
ToCreature()->StopMoving();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!HasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
|
||||
{
|
||||
m_rootTimes++; //blizzard internal check?
|
||||
if (Player* thisPlr = this->ToPlayer())
|
||||
{
|
||||
WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
|
||||
data.append(GetPackGUID());
|
||||
data << ++m_rootTimes;
|
||||
SendMessageToSet(&data,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8);
|
||||
data.append(GetPackGUID());
|
||||
SendMessageToSet(&data,true);
|
||||
}
|
||||
|
||||
WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
|
||||
data.append(GetPackGUID());
|
||||
data << m_rootTimes;
|
||||
SendMessageToSet(&data,true);
|
||||
|
||||
// RemoveUnitMovementFlag(MOVEMENTFLAG_ROOT);
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16465,6 +16500,12 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
|
||||
if (aurApp && aurApp->GetRemoveMode())
|
||||
return;
|
||||
|
||||
if (Player* thisPlr = this->ToPlayer())
|
||||
{
|
||||
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
|
||||
thisPlr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
ASSERT(!m_vehicle);
|
||||
m_vehicle = vehicle;
|
||||
if (!m_vehicle->AddPassenger(this, seatId))
|
||||
@@ -16472,19 +16513,6 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
|
||||
m_vehicle = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player* thisPlr = this->ToPlayer())
|
||||
{
|
||||
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
|
||||
thisPlr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
SendClearTarget();
|
||||
|
||||
SetControlled(true, UNIT_STAT_ROOT);
|
||||
//movementInfo is set in AddPassenger
|
||||
//packets are sent in AddPassenger
|
||||
|
||||
}
|
||||
|
||||
void Unit::ChangeSeat(int8 seatId, bool next)
|
||||
@@ -16531,23 +16559,31 @@ void Unit::ExitVehicle(Position const* exitPosition)
|
||||
Vehicle *vehicle = m_vehicle;
|
||||
m_vehicle = NULL;
|
||||
|
||||
SetControlled(false, UNIT_STAT_ROOT); // SMSG_MOVE_FORCE_UNROOT
|
||||
SetControlled(false, UNIT_STAT_ROOT); // SMSG_MOVE_FORCE_UNROOT, ~MOVEMENTFLAG_ROOT
|
||||
|
||||
if (exitPosition) // Exit position specified
|
||||
Relocate(exitPosition);
|
||||
Position pos;
|
||||
if (!exitPosition) // Exit position not specified
|
||||
vehicle->GetBase()->GetPosition(&pos);
|
||||
else
|
||||
Relocate(vehicle->GetBase()); // Relocate to vehicle base
|
||||
pos = *exitPosition;
|
||||
|
||||
AddUnitState(UNIT_STAT_MOVE);
|
||||
|
||||
//Send leave vehicle, not correct
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
//this->ToPlayer()->SetClientControl(this, 1);
|
||||
this->ToPlayer()->SetFallInformation(0, GetPositionZ());
|
||||
else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT))
|
||||
{
|
||||
WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8);
|
||||
data.append(GetPackGUID());
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
WorldPacket data;
|
||||
BuildHeartBeatMsg(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
SendMonsterMoveExitVehicle(&pos);
|
||||
Relocate(&pos);
|
||||
|
||||
WorldPacket data2;
|
||||
BuildHeartBeatMsg(&data2);
|
||||
SendMessageToSet(&data2, false);
|
||||
|
||||
if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
|
||||
if (((Minion*)vehicle->GetBase())->GetOwner() == this)
|
||||
@@ -16561,8 +16597,6 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
|
||||
case TYPEID_UNIT:
|
||||
if (canFly())
|
||||
const_cast<Unit*>(this)->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
|
||||
if (IsVehicle())
|
||||
const_cast<Unit*>(this)->AddExtraUnitMovementFlag(GetVehicleKit()->GetExtraMovementFlagsForBase());
|
||||
break;
|
||||
case TYPEID_PLAYER:
|
||||
// remove unknown, unused etc flags for now
|
||||
|
||||
@@ -721,7 +721,7 @@ enum SplineFlags
|
||||
SPLINEFLAG_UNKNOWN22 = 0x00200000,
|
||||
SPLINEFLAG_UNKNOWN23 = 0x00400000,
|
||||
SPLINEFLAG_TRANSPORT = 0x00800000,
|
||||
SPLINEFLAG_UNKNOWN25 = 0x01000000,
|
||||
SPLINEFLAG_EXIT_VEHICLE = 0x01000000,
|
||||
SPLINEFLAG_UNKNOWN26 = 0x02000000,
|
||||
SPLINEFLAG_UNKNOWN27 = 0x04000000,
|
||||
SPLINEFLAG_UNKNOWN28 = 0x08000000,
|
||||
@@ -1521,6 +1521,7 @@ class Unit : public WorldObject
|
||||
void SendMonsterStop(bool on_death = false);
|
||||
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL);
|
||||
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player *player = NULL);
|
||||
void SendMonsterMoveExitVehicle(Position const* newPos);
|
||||
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
|
||||
void SendMonsterMoveTransport(Unit *vehicleOwner);
|
||||
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
|
||||
|
||||
@@ -61,6 +61,8 @@ Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleI
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
InitMovementInfoForBase();
|
||||
}
|
||||
|
||||
Vehicle::~Vehicle()
|
||||
@@ -373,8 +375,10 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
|
||||
|
||||
if (me->IsInWorld())
|
||||
{
|
||||
// In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
|
||||
unit->SendMonsterMoveTransport(me);
|
||||
unit->SendClearTarget(); // SMSG_BREAK_TARGET
|
||||
unit->SetControlled(true, UNIT_STAT_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
|
||||
// also adds MOVEMENTFLAG_ROOT
|
||||
unit->SendMonsterMoveTransport(me); // SMSG_MONSTER_MOVE_TRANSPORT
|
||||
|
||||
if (me->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
@@ -476,29 +480,25 @@ void Vehicle::Dismiss()
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Dismiss %u", me->GetEntry());
|
||||
Uninstall();
|
||||
me->SendObjectDeSpawnAnim(me->GetGUID());
|
||||
me->DestroyForNearbyPlayers();
|
||||
me->CombatStop();
|
||||
me->AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
uint16 Vehicle::GetExtraMovementFlagsForBase() const
|
||||
void Vehicle::InitMovementInfoForBase()
|
||||
{
|
||||
uint16 movementMask = MOVEMENTFLAG2_NONE;
|
||||
uint32 vehicleFlags = GetVehicleInfo()->m_flags;
|
||||
|
||||
if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE)
|
||||
movementMask |= MOVEMENTFLAG2_NO_STRAFE;
|
||||
me->AddExtraUnitMovementFlag(MOVEMENTFLAG2_NO_STRAFE);
|
||||
if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING)
|
||||
movementMask |= MOVEMENTFLAG2_NO_JUMPING;
|
||||
me->AddExtraUnitMovementFlag(MOVEMENTFLAG2_NO_JUMPING);
|
||||
if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING)
|
||||
movementMask |= MOVEMENTFLAG2_FULL_SPEED_TURNING;
|
||||
me->AddExtraUnitMovementFlag(MOVEMENTFLAG2_FULL_SPEED_TURNING);
|
||||
if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING)
|
||||
movementMask |= MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING;
|
||||
me->AddExtraUnitMovementFlag( MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING);
|
||||
if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING)
|
||||
movementMask |= MOVEMENTFLAG2_FULL_SPEED_PITCHING;
|
||||
|
||||
sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::GetExtraMovementFlagsForBase() returned %u", movementMask);
|
||||
return movementMask;
|
||||
me->AddExtraUnitMovementFlag(MOVEMENTFLAG2_FULL_SPEED_PITCHING);
|
||||
}
|
||||
|
||||
VehicleSeatEntry const* Vehicle::GetSeatForPassenger(Unit* passenger)
|
||||
|
||||
@@ -145,6 +145,7 @@ class Vehicle
|
||||
|
||||
private:
|
||||
SeatMap::iterator GetSeatIteratorForPassenger(Unit* passenger);
|
||||
void InitMovementInfoForBase();
|
||||
|
||||
protected:
|
||||
Unit *me;
|
||||
|
||||
Reference in New Issue
Block a user