summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-07-07 20:17:01 +0000
committerpeter1138 <peter1138@openttd.org>2007-07-07 20:17:01 +0000
commit855e9d075101344079a8c7c66cbb25dc63eea7e1 (patch)
tree6a6e903e7044643c68d59d065766aa6e9fe1fe3f /src
parentf60d055d8dc637075e26b0b021ba6e99e4dd4f33 (diff)
downloadopenttd-855e9d075101344079a8c7c66cbb25dc63eea7e1.tar.xz
(svn r10470) -Fix: clamp station build date to 16 bit value for newgrf, preventing overflow and incorrect graphics shown past a certain date.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_station.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 95b9c574a..bd7783019 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -378,7 +378,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
case 0x43: return _current_player; // Station owner
case 0x44: return 2; // PBS status
- case 0xFA: return max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); // Build date
+ case 0xFA: return clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value
}
*available = false;
@@ -420,7 +420,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0xF3: return st->bus_stops->status;
case 0xF6: return st->airport_flags;
case 0xF7: return GB(st->airport_flags, 8, 8);
- case 0xFA: return max(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
+ case 0xFA: return clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
}
/* Handle cargo variables with parameter, 0x60 to 0x65 */