summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
authorhackykid <hackykid@openttd.org>2005-05-26 16:31:32 +0000
committerhackykid <hackykid@openttd.org>2005-05-26 16:31:32 +0000
commite383ee6bbaec4eebc29bd1388bf816d290e98565 (patch)
tree291eececf8a6992ef616cae9e0ace038fa17e21e /vehicle_gui.c
parent73ba260e75adf435697493772239e7434919d6fd (diff)
downloadopenttd-e383ee6bbaec4eebc29bd1388bf816d290e98565.tar.xz
(svn r2365) - Change: [refitting] Make refitting capacities for trains newgrf compatible. Train vehicles can now carry twice as much mail/goods as other cargo, and four times as much passengers.
- Fix: [refitting] The refit window now shows the correct refit options for the entire consist. Only if at least one of the vehicles in the train can be refitted to a certain cargo, it is shown in the list. - Fix: [refitting] When refitting to a cargo which is already carried by some vehicles in the consist, the capacities of those vehicles are taken into account when calculating the new capacity of the train in the refit window.
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 */