summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-28 18:19:34 +0000
committerrubidium <rubidium@openttd.org>2010-01-28 18:19:34 +0000
commitc1c401b51b5081c175b9b92b223e822096e3eed3 (patch)
tree1ad20208d6d52e199f7c3c70207692ed01423921 /src
parent27491c55866c3469851a509595ee17a503e20410 (diff)
downloadopenttd-c1c401b51b5081c175b9b92b223e822096e3eed3.tar.xz
(svn r18935) -Fix [FS#3551] (r18764): value of variables 90 and 91 weren't what NARS expects
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index b7650c95b..982fcf833 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -711,8 +711,20 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x0B: return v->current_order.GetDestination();
case 0x0C: return v->GetNumOrders();
case 0x0D: return v->cur_order_index;
- case 0x10: return v->load_unload_ticks;
- case 0x11: return GB(v->load_unload_ticks, 8, 8);
+ case 0x10:
+ case 0x11: {
+ uint ticks;
+ if (v->current_order.IsType(OT_LOADING)) {
+ ticks = v->load_unload_ticks;
+ } else {
+ switch (v->type) {
+ case VEH_TRAIN: ticks = Train::From(v)->wait_counter; break;
+ case VEH_AIRCRAFT: ticks = Aircraft::From(v)->turn_counter; break;
+ default: ticks = 0; break;
+ }
+ }
+ return (variable - 0x80) == 0x10 ? ticks : GB(ticks, 8, 8);
+ }
case 0x12: return max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
case 0x13: return GB(max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0), 8, 8);
case 0x14: return v->service_interval;