Skip to content

Commit 460ad51

Browse files
authored
Fix getTrainSpeed returning 0 for negative speeds (#2732) (#4415)
Refactor train speed handling to use GetTrainSpeed and SetTrainSpeed methods
1 parent e490616 commit 460ad51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5442,8 +5442,7 @@ bool CStaticFunctionDefinitions::GetTrainSpeed(CVehicle* pVehicle, float& fSpeed
54425442
if (pVehicle->GetVehicleType() != VEHICLE_TRAIN)
54435443
return false;
54445444

5445-
const CVector& vecVelocity = pVehicle->GetVelocity();
5446-
fSpeed = vecVelocity.Length();
5445+
fSpeed = pVehicle->GetTrainSpeed();
54475446
return true;
54485447
}
54495448

@@ -7330,6 +7329,7 @@ bool CStaticFunctionDefinitions::SetTrainSpeed(CVehicle* pVehicle, float fSpeed)
73307329
vecVelocity.Normalize();
73317330
vecVelocity *= fSpeed;
73327331
pVehicle->SetVelocity(vecVelocity);
7332+
pVehicle->SetTrainSpeed(fSpeed);
73337333

73347334
CBitStream BitStream;
73357335
BitStream.pBitStream->Write(fSpeed);

0 commit comments

Comments
 (0)