summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-11-13 21:42:35 +0000
committerdarkvater <darkvater@openttd.org>2004-11-13 21:42:35 +0000
commit1f12dee3a052ceb8a6063a0f9a4d031d25dd4a04 (patch)
tree5c8bc36b17fba49c5d43c47be75f9733006d9368
parent0a2f28c2f2db13adf122828ff0be430433575d1a (diff)
downloadopenttd-1f12dee3a052ceb8a6063a0f9a4d031d25dd4a04.tar.xz
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
-rw-r--r--aircraft_gui.c42
-rw-r--r--train_gui.c42
2 files changed, 64 insertions, 20 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 0503a26e3..841f1e3d3 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -219,17 +219,39 @@ static void AircraftRefitWndProc(Window *w, WindowEvent *e)
x = 6;
y = 25;
sel = WP(w,refit_d).sel;
- b = _aircraft_refit_types[_opt.landscape];
- do {
- color = 16;
- if (sel == 0) {
- cargo = *b;
- color = 12;
+
+#define show_cargo(ctype) { \
+ color = 16; \
+ if (sel == 0) { \
+ cargo = ctype; \
+ color = 12; \
+ } \
+ sel--; \
+ DrawString(x, y, _cargoc.names_s[ctype], color); \
+ y += 10; \
+ }
+
+ if (_engine_refit_masks[v->engine_type]) {
+ uint32 mask = _engine_refit_masks[v->engine_type];
+ int cid = 0;
+
+ for (; mask; mask >>= 1, cid++) {
+ if (!(mask & 1)) // not this cid
+ continue;
+ if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape
+ continue;
+
+ show_cargo(_local_cargo_id_ctype[cid]);
}
- sel--;
- DrawString(x,y,_cargoc.names_s[*b], color);
- y += 10;
- } while (*++b != 0xFF);
+
+ } else { // generic refit list
+ b = _aircraft_refit_types[_opt.landscape];
+ do {
+ show_cargo(*b);
+ } while (*++b != 0xFF);
+ }
+
+#undef show_cargo
WP(w,refit_d).cargo = cargo;
diff --git a/train_gui.c b/train_gui.c
index 03b386a40..5dafcfbc0 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -623,17 +623,39 @@ static void RailVehicleRefitWndProc(Window *w, WindowEvent *e)
x = 6;
y = 25;
sel = WP(w,refit_d).sel;
- b = _rail_vehicle_refit_types[_opt.landscape];
- do {
- color = 16;
- if (sel == 0) {
- cargo = *b;
- color = 12;
+
+#define show_cargo(ctype) { \
+ color = 16; \
+ if (sel == 0) { \
+ cargo = ctype; \
+ color = 12; \
+ } \
+ sel--; \
+ DrawString(x, y, _cargoc.names_s[ctype], color); \
+ y += 10; \
+ }
+
+ if (_engine_refit_masks[v->engine_type]) {
+ uint32 mask = _engine_refit_masks[v->engine_type];
+ int cid = 0;
+
+ for (; mask; mask >>= 1, cid++) {
+ if (!(mask & 1)) // not this cid
+ continue;
+ if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape
+ continue;
+
+ show_cargo(_local_cargo_id_ctype[cid]);
}
- sel--;
- DrawString(x,y,_cargoc.names_s[*b], color);
- y += 10;
- } while (*++b != 255);
+
+ } else { // generic refit list
+ b = _rail_vehicle_refit_types[_opt.landscape];
+ do {
+ show_cargo(*b);
+ } while (*++b != 255);
+ }
+
+#undef show_cargo
WP(w,refit_d).cargo = cargo;