Fix multi-cargo ship capacity display in autoreplace and available ships windows

pull/661/head
Jonathan G Rennison 3 months ago
parent b13b2781bd
commit c5f026ba66

@ -523,8 +523,7 @@ public:
if (this->sel_engine[side] != INVALID_ENGINE) { if (this->sel_engine[side] != INVALID_ENGINE) {
/* Use default engine details without refitting */ /* Use default engine details without refitting */
const Engine *e = Engine::Get(this->sel_engine[side]); const Engine *e = Engine::Get(this->sel_engine[side]);
TestedEngineDetails ted; TestedEngineDetails ted{};
ted.cost = 0;
ted.FillDefaultCapacities(e); ted.FillDefaultCapacities(e);
const Rect r = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect() const Rect r = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect()

@ -1108,7 +1108,7 @@ static uint ShowAdditionalText(int left, int right, int y, EngineID engine)
void TestedEngineDetails::FillDefaultCapacities(const Engine *e) void TestedEngineDetails::FillDefaultCapacities(const Engine *e)
{ {
this->cargo = e->GetDefaultCargoType(); this->cargo = e->GetDefaultCargoType();
if (e->type == VEH_TRAIN || e->type == VEH_ROAD) { if (e->type == VEH_TRAIN || e->type == VEH_ROAD || e->type == VEH_SHIP) {
this->all_capacities = GetCapacityOfArticulatedParts(e->index); this->all_capacities = GetCapacityOfArticulatedParts(e->index);
this->capacity = this->all_capacities[this->cargo]; this->capacity = this->all_capacities[this->cargo];
this->mail_capacity = 0; this->mail_capacity = 0;
@ -1617,7 +1617,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
} }
/* Purchase test was not possible or failed, fill in the defaults instead. */ /* Purchase test was not possible or failed, fill in the defaults instead. */
this->te.cost = 0; this->te = {};
this->te.FillDefaultCapacities(e); this->te.FillDefaultCapacities(e);
} }
@ -2524,7 +2524,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
} }
/* Purchase test was not possible or failed, fill in the defaults instead. */ /* Purchase test was not possible or failed, fill in the defaults instead. */
state.te.cost = 0; state.te = {};
state.te.FillDefaultCapacities(e); state.te.FillDefaultCapacities(e);
} }

@ -40,10 +40,10 @@ enum VehicleInvalidateWindowData {
/** Extra information about refitted cargo and capacity */ /** Extra information about refitted cargo and capacity */
struct TestedEngineDetails { struct TestedEngineDetails {
Money cost; ///< Refit cost Money cost{}; ///< Refit cost
CargoID cargo; ///< Cargo type CargoID cargo{}; ///< Cargo type
uint capacity; ///< Cargo capacity uint capacity{}; ///< Cargo capacity
uint16_t mail_capacity; ///< Mail capacity if available uint16_t mail_capacity{}; ///< Mail capacity if available
CargoArray all_capacities{}; ///< Capacities for all cargoes CargoArray all_capacities{}; ///< Capacities for all cargoes
void FillDefaultCapacities(const Engine *e); void FillDefaultCapacities(const Engine *e);

Loading…
Cancel
Save