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) {
/* Use default engine details without refitting */
const Engine *e = Engine::Get(this->sel_engine[side]);
TestedEngineDetails ted;
ted.cost = 0;
TestedEngineDetails ted{};
ted.FillDefaultCapacities(e);
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)
{
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->capacity = this->all_capacities[this->cargo];
this->mail_capacity = 0;
@ -1617,7 +1617,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
}
/* Purchase test was not possible or failed, fill in the defaults instead. */
this->te.cost = 0;
this->te = {};
this->te.FillDefaultCapacities(e);
}
@ -2524,7 +2524,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
}
/* Purchase test was not possible or failed, fill in the defaults instead. */
state.te.cost = 0;
state.te = {};
state.te.FillDefaultCapacities(e);
}

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

Loading…
Cancel
Save