Core/Transports: Fixed crash added in b88cecb656

This commit is contained in:
Shauren
2016-10-30 14:00:23 +01:00
parent e1552d56b5
commit d68d99d182

View File

@@ -203,14 +203,16 @@ void Transport::Update(uint32 diff)
if (_positionChangeTimer.Passed())
{
_positionChangeTimer.Reset(positionUpdateDelay);
if (IsMoving() || justStopped)
if (IsMoving())
{
float t = CalculateSegmentPos(float(timer) * 0.001f);
float t = !justStopped ? CalculateSegmentPos(float(timer) * 0.001f) : 1.0f;
G3D::Vector3 pos, dir;
_currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
UpdatePosition(pos.x, pos.y, pos.z, std::atan2(dir.y, dir.x) + float(M_PI));
}
else if (justStopped)
UpdatePosition(_currentFrame->Node->LocX, _currentFrame->Node->LocY, _currentFrame->Node->LocZ, _currentFrame->InitialOrientation);
else
{
/* There are four possible scenarios that trigger loading/unloading passengers: