summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-12 20:12:45 +0000
committerfrosch <frosch@openttd.org>2012-11-12 20:12:45 +0000
commit160aa435da76ef79686b3712d77e9f63c1d6d73e (patch)
tree83dc4640c602f87f4210685f5c26ce797c5e9f64
parente888f9da9f9aee16e379a8c1f3384eb1d88476bb (diff)
downloadopenttd-160aa435da76ef79686b3712d77e9f63c1d6d73e.tar.xz
(svn r24712) -Fix [FS#5303]: [NewGRF] Station variables 61 and 62 returned incorrect values, if no vehicle ever tried loading.
-rw-r--r--src/newgrf_station.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 5751ad31d..301ab493c 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -411,17 +411,28 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
CargoID c = GetCargoTranslation(parameter, object->grffile);
- if (c == CT_INVALID) return 0;
+ if (c == CT_INVALID) {
+ switch (variable) {
+ case 0x62: return 0xFFFFFFFF;
+ case 0x64: return 0xFF00;
+ default: return 0;
+ }
+ }
const GoodsEntry *ge = &this->goods[c];
switch (variable) {
case 0x60: return min(ge->cargo.Count(), 4095);
- case 0x61: return ge->days_since_pickup;
- case 0x62: return ge->rating;
+ case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->days_since_pickup : 0;
+ case 0x62: return HasBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP) ? ge->rating : 0xFFFFFFFF;
case 0x63: return ge->cargo.DaysInTransit();
- case 0x64: return ge->last_speed | (ge->last_age << 8);
+ case 0x64: return ge->HasVehicleEverTriedLoading() ? ge->last_speed | (ge->last_age << 8) : 0xFF00;
case 0x65: return GB(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1) << 3;
- case 0x69: return GB(ge->acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED, 4);
+ case 0x69: {
+ assert_compile((int)GoodsEntry::GES_EVER_ACCEPTED + 1 == (int)GoodsEntry::GES_LAST_MONTH);
+ assert_compile((int)GoodsEntry::GES_EVER_ACCEPTED + 2 == (int)GoodsEntry::GES_CURRENT_MONTH);
+ assert_compile((int)GoodsEntry::GES_EVER_ACCEPTED + 3 == (int)GoodsEntry::GES_ACCEPTED_BIGTICK);
+ return GB(ge->acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED, 4);
+ }
}
}