summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index c83f287ec..ce67dc171 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -165,9 +165,9 @@ void DrawVehicleProfitButton(Vehicle *v, int x, int y)
DrawSprite(SPR_BLOT | ormod, x, y);
}
-/** Draw the list of available refit options.
+/** Draw the list of available refit options for a consist.
* Draw the list and highlight the selected refit option (if any)
- * @param *v vehicle(type) to get the refit-options of
+ * @param *v first vehicle in consist to get the refit-options of
* @param sel selected refit cargo-type in the window
* @return the cargo type that is hightlighted, CT_INVALID if none
*/
@@ -176,6 +176,7 @@ CargoID DrawVehicleRefitWindow(const Vehicle *v, int sel)
uint32 cmask;
CargoID cid, cargo = CT_INVALID;
int y = 25;
+ const Vehicle* u;
#define show_cargo(ctype) { \
byte colour = 16; \
if (sel == 0) { \
@@ -187,10 +188,23 @@ CargoID DrawVehicleRefitWindow(const Vehicle *v, int sel)
y += 10; \
}
- /* Check if engine has custom refit or normal ones, and get its bitmasked value.
- * Now just and it with the bitmasked available cargo on the current landscape, and
- * where the bits are set: those are available */
- cmask = (_engine_refit_masks[v->engine_type] != 0) ? _engine_refit_masks[v->engine_type] : _default_refitmasks[v->type - VEH_Train];
+ /* Check if vehicle has custom refit or normal ones, and get its bitmasked value.
+ * If its a train, 'or' this with the refit masks of the wagons. Now just 'and'
+ * it with the bitmask of available cargo on the current landscape, and
+ * where the bits are set: those are available */
+ cmask = 0;
+ u = v;
+ do {
+ if (_engine_refit_masks[u->engine_type] != 0) { // newgrf custom refit mask
+ cmask |= _engine_refit_masks[u->engine_type];
+ } else if (u->cargo_cap != 0) {
+ // rail wagons cant be refitted by default
+ if (v->type != VEH_Train || !(RailVehInfo(u->engine_type)->flags & RVI_WAGON))
+ cmask |= _default_refitmasks[v->type - VEH_Train];
+ }
+ u = u->next;
+ } while (v->type == VEH_Train && u != NULL);
+
cmask &= _landscape_global_cargo_mask[_opt_ptr->landscape];
/* Check which cargo has been selected from the refit window and draw list */