summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 1866af6c4..f2a70be4d 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -707,8 +707,8 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
}
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 0x12: return Clamp(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 0xFFFF);
+ case 0x13: return GB(Clamp(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 0xFFFF), 8, 8);
case 0x14: return v->service_interval;
case 0x15: return GB(v->service_interval, 8, 8);
case 0x16: return v->last_station_visited;
@@ -736,10 +736,10 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x39: return v->cargo_type;
case 0x3A: return v->cargo_cap;
case 0x3B: return GB(v->cargo_cap, 8, 8);
- case 0x3C: return v->cargo.Count();
- case 0x3D: return GB(v->cargo.Count(), 8, 8);
+ case 0x3C: return ClampToU16(v->cargo.Count());
+ case 0x3D: return GB(ClampToU16(v->cargo.Count()), 8, 8);
case 0x3E: return v->cargo.Source();
- case 0x3F: return v->cargo.DaysInTransit();
+ case 0x3F: return ClampU(v->cargo.DaysInTransit(), 0, 0xFF);
case 0x40: return ClampToU16(v->age);
case 0x41: return GB(ClampToU16(v->age), 8, 8);
case 0x42: return ClampToU16(v->max_age);