Fix artic engines with no capacity on leading part in build window
Engines were being shown as not having any capacity overall
This commit is contained in:
@@ -1085,6 +1085,7 @@ void TestedEngineDetails::FillDefaultCapacities(const Engine *e)
|
||||
this->all_capacities[this->cargo] = this->capacity;
|
||||
this->all_capacities[CT_MAIL] = this->mail_capacity;
|
||||
}
|
||||
if (this->all_capacities.GetCount() == 0) this->cargo = CT_INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1521,7 +1522,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
|
||||
if (this->sel_engine == INVALID_ENGINE) return;
|
||||
|
||||
const Engine *e = Engine::Get(this->sel_engine);
|
||||
if (!e->CanCarryCargo()) {
|
||||
if (!e->CanPossiblyCarryCargo()) {
|
||||
this->te.cost = 0;
|
||||
this->te.cargo = CT_INVALID;
|
||||
this->te.all_capacities.Clear();
|
||||
@@ -2377,7 +2378,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
if (state.sel_engine == INVALID_ENGINE) return;
|
||||
|
||||
const Engine *e = Engine::Get(state.sel_engine);
|
||||
if (!e->CanCarryCargo()) {
|
||||
if (!e->CanPossiblyCarryCargo()) {
|
||||
state.te.cost = 0;
|
||||
state.te.cargo = CT_INVALID;
|
||||
state.te.all_capacities.Clear();
|
||||
|
@@ -186,6 +186,35 @@ bool Engine::CanCarryCargo() const
|
||||
return this->GetDefaultCargoType() != CT_INVALID;
|
||||
}
|
||||
|
||||
bool Engine::CanPossiblyCarryCargo() const
|
||||
{
|
||||
if (this->IsGroundVehicle() && HasBit(this->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return true;
|
||||
|
||||
switch (this->type) {
|
||||
case VEH_TRAIN:
|
||||
if (HasBit(this->cb36_properties_used, PROP_TRAIN_CARGO_CAPACITY)) return true;
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
if (HasBit(this->cb36_properties_used, PROP_ROADVEH_CARGO_CAPACITY)) return true;
|
||||
break;
|
||||
|
||||
case VEH_SHIP:
|
||||
if (HasBit(this->cb36_properties_used, PROP_SHIP_CARGO_CAPACITY)) return true;
|
||||
break;
|
||||
|
||||
case VEH_AIRCRAFT:
|
||||
if (HasBit(this->cb36_properties_used, PROP_AIRCRAFT_PASSENGER_CAPACITY)) return true;
|
||||
if (HasBit(this->cb36_properties_used, PROP_AIRCRAFT_MAIL_CAPACITY)) return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
||||
return this->CanCarryCargo();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines capacity of a given vehicle from scratch.
|
||||
|
@@ -114,6 +114,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
|
||||
uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity = nullptr) const;
|
||||
|
||||
bool CanCarryCargo() const;
|
||||
bool CanPossiblyCarryCargo() const;
|
||||
|
||||
/**
|
||||
* Determines the default cargo capacity of an engine for display purposes.
|
||||
|
Reference in New Issue
Block a user