summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-04-18 19:21:54 +0000
committerrubidium <rubidium@openttd.org>2012-04-18 19:21:54 +0000
commit8d5685679111ee465c6fcafa94322ead7ccd11e2 (patch)
tree64f1fc8eece69ad39a8d6589677ecdd2da2ab8ee
parenteeb781b42916120510658dbfdba39b20839b5306 (diff)
downloadopenttd-8d5685679111ee465c6fcafa94322ead7ccd11e2.tar.xz
(svn r24152) -Fix [FS#5157]: [NoAI] Do not return the last 'cached' speed of vehicles when they are stopped/crashed
-rw-r--r--src/script/api/script_vehicle.cpp3
1 files changed, 2 insertions, 1 deletions
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)