diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index a9f783f6c6..3ab836aa68 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -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(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect() diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 898b160696..16e5d75ad3 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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); } diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 93611d2f0a..4d1cc2b4cd 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -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);