diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-04-03 22:36:49 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-06-10 15:16:39 +0200 |
| commit | 36dde87249e87c5693162a6e890875d828f93d6d (patch) | |
| tree | 6b715382a474deb81b8179aeef1c45533e684b5d /src/server/game/Entities | |
| parent | 54b16f0d167a0c5a37c91dd7140fe97597a66ac8 (diff) | |
Core/Movement: Delay creating MoveSplineInit objects used by GenericMovementGenerator to spline launch time
* This fixes inconsistent transport state detection for players exiting vehicles that are on transport (ICC gunship battle), fixes players being telerpoted to middle of nowhere on that fight
(cherry picked from commit b1a94bf94c500b64a5c4ae92642a95d048d9f392)
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 31 | ||||
| -rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.cpp | 14 |
2 files changed, 25 insertions, 20 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b78cfb76e25..07a5fb86fe6 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -525,10 +525,12 @@ bool Unit::haveOffhandWeapon() const void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath, bool forceDestination) { - Movement::MoveSplineInit init(this); - init.MoveTo(x, y, z, generatePath, forceDestination); - init.SetVelocity(speed); - GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE); + std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init) + { + init.MoveTo(x, y, z, generatePath, forceDestination); + init.SetVelocity(speed); + }; + GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE); } void Unit::UpdateSplineMovement(uint32 t_diff) @@ -12179,18 +12181,19 @@ void Unit::_ExitVehicle(Position const* exitPosition) } } - float height = pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(); - - Movement::MoveSplineInit init(this); + std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init) + { + float height = pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(); - // Creatures without inhabit type air should begin falling after exiting the vehicle - if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(), &height)) - init.SetFall(); + // Creatures without inhabit type air should begin falling after exiting the vehicle + if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(), &height)) + init.SetFall(); - init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false); - init.SetFacing(pos.GetOrientation()); - init.SetTransportExit(); - GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_EXIT, MOTION_PRIORITY_HIGHEST); + init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false); + init.SetFacing(pos.GetOrientation()); + init.SetTransportExit(); + }; + GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_EXIT, MOTION_PRIORITY_HIGHEST); if (player) player->ResummonPetTemporaryUnSummonedIfAny(); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index cab96560c1d..a111a07ba71 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -884,12 +884,14 @@ bool VehicleJoinEvent::Execute(uint64, uint32) Passenger->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures) // also adds MOVEMENTFLAG_ROOT - Movement::MoveSplineInit init(Passenger); - init.DisableTransportPathTransformations(); - init.MoveTo(x, y, z, false, true); - init.SetFacing(o); - init.SetTransportEnter(); - Passenger->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST); + std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init) + { + init.DisableTransportPathTransformations(); + init.MoveTo(x, y, z, false, true); + init.SetFacing(o); + init.SetTransportEnter(); + }; + Passenger->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST); for (auto const& [guid, threatRef] : Passenger->GetThreatManager().GetThreatenedByMeList()) threatRef->GetOwner()->GetThreatManager().AddThreat(Target->GetBase(), threatRef->GetThreat(), nullptr, true, true); |
