From 8d5685679111ee465c6fcafa94322ead7ccd11e2 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 18 Apr 2012 19:21:54 +0000 Subject: (svn r24152) -Fix [FS#5157]: [NoAI] Do not return the last 'cached' speed of vehicles when they are stopped/crashed --- src/script/api/script_vehicle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/script') diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index b6a28af4f..c4c6ca590 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -311,7 +311,8 @@ { if (!IsValidVehicle(vehicle_id)) return -1; - return ::Vehicle::Get(vehicle_id)->GetDisplaySpeed(); // km-ish/h + const ::Vehicle *v = ::Vehicle::Get(vehicle_id); + return (v->vehstatus & (::VS_STOPPED | ::VS_CRASHED)) == 0 ? v->GetDisplaySpeed() : 0; // km-ish/h } /* static */ ScriptVehicle::VehicleState ScriptVehicle::GetState(VehicleID vehicle_id) -- cgit v1.2.3-70-g09d2