mirror of https://github.com/OpenTTD/OpenTTD
(svn r23965) -Fix [FS#5070]: Refittability should never depend on the current capacity of a vehicle.
parent
3d6f8cd7d4
commit
5167f2be29
|
@ -109,13 +109,13 @@ static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_t
|
||||||
*/
|
*/
|
||||||
static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, bool include_initial_cargo_type)
|
static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, bool include_initial_cargo_type)
|
||||||
{
|
{
|
||||||
uint32 cargoes = 0;
|
const Engine *e = Engine::Get(engine);
|
||||||
CargoID initial_cargo_type;
|
if (!e->CanCarryCargo()) return 0;
|
||||||
|
|
||||||
if (GetVehicleDefaultCapacity(engine, &initial_cargo_type) > 0) {
|
uint32 cargoes = e->info.refit_mask;
|
||||||
const EngineInfo *ei = EngInfo(engine);
|
|
||||||
cargoes = ei->refit_mask;
|
if (include_initial_cargo_type) {
|
||||||
if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargoes, initial_cargo_type);
|
SetBit(cargoes, e->GetDefaultCargoType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return cargoes;
|
return cargoes;
|
||||||
|
@ -240,7 +240,7 @@ bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *car
|
||||||
CargoID first_cargo = CT_INVALID;
|
CargoID first_cargo = CT_INVALID;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (v->cargo_cap > 0 && v->cargo_type != CT_INVALID) {
|
if (v->cargo_type != CT_INVALID && v->GetEngine()->CanCarryCargo()) {
|
||||||
if (first_cargo == CT_INVALID) first_cargo = v->cargo_type;
|
if (first_cargo == CT_INVALID) first_cargo = v->cargo_type;
|
||||||
if (first_cargo != v->cargo_type) {
|
if (first_cargo != v->cargo_type) {
|
||||||
if (cargo_type != NULL) *cargo_type = CT_INVALID;
|
if (cargo_type != NULL) *cargo_type = CT_INVALID;
|
||||||
|
|
|
@ -206,7 +206,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
|
||||||
* now we will figure out what cargo the train is carrying and refit to fit this */
|
* now we will figure out what cargo the train is carrying and refit to fit this */
|
||||||
|
|
||||||
for (v = v->First(); v != NULL; v = v->Next()) {
|
for (v = v->First(); v != NULL; v = v->Next()) {
|
||||||
if (v->cargo_cap == 0) continue;
|
if (!v->GetEngine()->CanCarryCargo()) continue;
|
||||||
/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
|
/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
|
||||||
if (HasBit(available_cargo_types, v->cargo_type)) return v->cargo_type;
|
if (HasBit(available_cargo_types, v->cargo_type)) return v->cargo_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,7 +498,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte
|
||||||
if (v->type == VEH_TRAIN) user_def_data |= Train::From(u)->tcache.user_def_data;
|
if (v->type == VEH_TRAIN) user_def_data |= Train::From(u)->tcache.user_def_data;
|
||||||
|
|
||||||
/* Skip empty engines */
|
/* Skip empty engines */
|
||||||
if (u->cargo_cap == 0) continue;
|
if (!u->GetEngine()->CanCarryCargo()) continue;
|
||||||
|
|
||||||
cargo_classes |= CargoSpec::Get(u->cargo_type)->classes;
|
cargo_classes |= CargoSpec::Get(u->cargo_type)->classes;
|
||||||
common_cargoes[u->cargo_type]++;
|
common_cargoes[u->cargo_type]++;
|
||||||
|
@ -516,7 +516,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte
|
||||||
/* Count subcargo types of common_cargo_type */
|
/* Count subcargo types of common_cargo_type */
|
||||||
for (u = v; u != NULL; u = u->Next()) {
|
for (u = v; u != NULL; u = u->Next()) {
|
||||||
/* Skip empty engines and engines not carrying common_cargo_type */
|
/* Skip empty engines and engines not carrying common_cargo_type */
|
||||||
if (u->cargo_cap == 0 || u->cargo_type != common_cargo_type) continue;
|
if (u->cargo_type != common_cargo_type || !u->GetEngine()->CanCarryCargo()) continue;
|
||||||
|
|
||||||
common_subtypes[u->cargo_subtype]++;
|
common_subtypes[u->cargo_subtype]++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue