summaryrefslogtreecommitdiff
path: root/src/newgrf_station.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-04-13 19:32:18 +0000
committerpeter1138 <peter1138@openttd.org>2007-04-13 19:32:18 +0000
commit59399480b3af919eea479b1dd3e2ee69dcd0bc5a (patch)
tree78427100f591828f22b4bf1543e50769733875e1 /src/newgrf_station.cpp
parent39735f7b549d256e32b64ab837d15aaba6a82885 (diff)
downloadopenttd-59399480b3af919eea479b1dd3e2ee69dcd0bc5a.tar.xz
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
Diffstat (limited to 'src/newgrf_station.cpp')
-rw-r--r--src/newgrf_station.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index a799e3c57..eb9757f16 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -409,12 +409,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0x49: return GetPlatformInfoHelper(tile, false, true, false);
/* Variables which use the parameter */
- case 0x60: return GB(st->goods[parameter].waiting_acceptance, 0, 12);
- case 0x61: return st->goods[parameter].days_since_pickup;
- case 0x62: return st->goods[parameter].rating;
- case 0x63: return st->goods[parameter].enroute_time;
- case 0x64: return st->goods[parameter].last_speed | (st->goods[parameter].last_age << 8);
- case 0x65: return GB(st->goods[parameter].waiting_acceptance, 12, 4);
+ /* Variables 0x60 to 0x65 are handled separately below */
/* General station properties */
case 0x82: return 50;
@@ -430,6 +425,23 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0xFA: return max(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
}
+ /* Handle cargo variables with parameter, 0x60 to 0x65 */
+ if (variable >= 0x60 && variable <= 0x65) {
+ CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
+
+ if (c == CT_INVALID) return 0;
+ const GoodsEntry *ge = &st->goods[c];
+
+ switch (variable) {
+ case 0x60: return GB(ge->waiting_acceptance, 0, 12);
+ case 0x61: return ge->days_since_pickup;
+ case 0x62: return ge->rating;
+ case 0x63: return ge->enroute_time;
+ case 0x64: return ge->last_speed | (ge->last_age << 8);
+ case 0x65: return GB(ge->waiting_acceptance, 12, 4);
+ }
+ }
+
/* Handle cargo variables (deprecated) */
if (variable >= 0x8C && variable <= 0xEC) {
const GoodsEntry *g = &st->goods[GB(variable - 0x8C, 3, 4)];