summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-07-10 08:54:57 +0000
committerfrosch <frosch@openttd.org>2010-07-10 08:54:57 +0000
commit1055c2b0fd8feb8a4a3eb039c3170d7ee8160b46 (patch)
treed18c332b9157243bb55d427b56c4f15b2a80569e
parentd4da257ff9b11abcbaaea85743665d4188562856 (diff)
downloadopenttd-1055c2b0fd8feb8a4a3eb039c3170d7ee8160b46.tar.xz
(svn r20106) -Fix (r5999): Engine and vehicle age were clamped at 0xFFFF, though there are 32bit available.
-rw-r--r--src/engine.cpp2
-rw-r--r--src/newgrf_engine.cpp4
-rw-r--r--src/vehicle.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 0d9371f28..e2faf7a42 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -734,7 +734,7 @@ void EnginesMonthlyLoop()
Engine *e;
FOR_ALL_ENGINES(e) {
/* Age the vehicle */
- if ((e->flags & ENGINE_AVAILABLE) && e->age != 0xFFFF) {
+ if ((e->flags & ENGINE_AVAILABLE) && e->age != MAX_DAY) {
e->age++;
CalcEngineReliability(e);
}
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index e2ce07dea..9b63ff6d9 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -732,8 +732,8 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x3D: return GB(v->cargo.Count(), 8, 8);
case 0x3E: return v->cargo.Source();
case 0x3F: return v->cargo.DaysInTransit();
- case 0x40: return v->age;
- case 0x41: return GB(v->age, 8, 8);
+ case 0x40: return ClampToU16(v->age);
+ case 0x41: return GB(ClampToU16(v->age), 8, 8);
case 0x42: return v->max_age;
case 0x43: return GB(v->max_age, 8, 8);
case 0x44: return Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 0a88f3c53..178596a4f 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -971,7 +971,7 @@ void CheckVehicleBreakdown(Vehicle *v)
void AgeVehicle(Vehicle *v)
{
- if (v->age < 65535) v->age++;
+ if (v->age < MAX_DAY) v->age++;
int age = v->age - v->max_age;
if (age == DAYS_IN_LEAP_YEAR * 0 || age == DAYS_IN_LEAP_YEAR * 1 ||