diff options
author | Shauren <shauren.trinity@gmail.com> | 2014-01-06 13:51:40 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2014-01-06 13:51:40 +0100 |
commit | 15cbe5858c52d69ab744b0abc1948202ba28b7d0 (patch) | |
tree | 423e913c36b9ca060aefca272d306eb8ab24d20f /src | |
parent | 95f14f921b0dd293e2b7a89718f7b181c5c61948 (diff) |
Core/Movement: Fixed vehicle passengers disappearing clientside
Closes #11411
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInit.cpp | 50 |
2 files changed, 39 insertions, 17 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index cb390cc4654..099adb0b659 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -405,7 +405,7 @@ void Unit::UpdateSplinePosition() m_movesplineTimer.Reset(positionUpdateDelay); Movement::Location loc = movespline->ComputePosition(); - if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT)) + if (movespline->onTransport) { Position& pos = m_movementInfo.transport.pos; pos.m_positionX = loc.x; @@ -15524,7 +15524,7 @@ void Unit::SetStunned(bool apply) // Creature specific if (GetTypeId() != TYPEID_PLAYER) - ToCreature()->StopMoving(); + StopMoving(); else SetStandState(UNIT_STAND_STATE_STAND); @@ -15582,7 +15582,7 @@ void Unit::SetRooted(bool apply) WorldPacket data(SMSG_SPLINE_MOVE_ROOT, 8); data.append(GetPackGUID()); SendMessageToSet(&data, true); - ToCreature()->StopMoving(); + StopMoving(); } } else diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index f6ef219522c..87d8e4a0c34 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -60,23 +60,27 @@ namespace Movement { MoveSpline& move_spline = *unit->movespline; - bool transport = false; - Location real_position(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZMinusOffset(), unit->GetOrientation()); - // Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes - if (unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID()) - { - transport = true; - real_position.x = unit->GetTransOffsetX(); - real_position.y = unit->GetTransOffsetY(); - real_position.z = unit->GetTransOffsetZ(); - real_position.orientation = unit->GetTransOffsetO(); - } - + // Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes (movementInfo.transport.guid is 0 in that case) + bool transport = unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID(); + Location real_position; // there is a big chance that current position is unknown if current state is not finalized, need compute it // this also allows CalculatePath spline position and update map position in much greater intervals // Don't compute for transport movement if the unit is in a motion between two transports if (!move_spline.Finalized() && move_spline.onTransport == transport) real_position = move_spline.ComputePosition(); + else + { + Position const* pos; + if (!transport) + pos = unit; + else + pos = &unit->m_movementInfo.transport.pos; + + real_position.x = pos->GetPositionX(); + real_position.y = pos->GetPositionY(); + real_position.z = pos->GetPositionZ(); + real_position.orientation = unit->GetOrientation(); + } // should i do the things that user should do? - no. if (args.path.empty()) @@ -135,14 +139,32 @@ namespace Movement if (move_spline.Finalized()) return; - Location loc = move_spline.ComputePosition(); + bool transport = unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID(); + Location loc; + if (move_spline.onTransport == transport) + loc = move_spline.ComputePosition(); + else + { + Position const* pos; + if (!transport) + pos = unit; + else + pos = &unit->m_movementInfo.transport.pos; + + loc.x = pos->GetPositionX(); + loc.y = pos->GetPositionY(); + loc.z = pos->GetPositionZ(); + loc.orientation = unit->GetOrientation(); + } + args.flags = MoveSplineFlag::Done; unit->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE_ENABLED); + move_spline.onTransport = transport; move_spline.Initialize(args); WorldPacket data(SMSG_MONSTER_MOVE, 64); data.append(unit->GetPackGUID()); - if (unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID()) + if (transport) { data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT); data.appendPackGUID(unit->GetTransGUID()); |