Mercurial > hg > openttd
changeset 19111:b7dfb9e0b855 draft
(svn r23965) -Fix [FS#5070]: Refittability should never depend on the current capacity of a vehicle.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 19 Feb 2012 18:34:24 +0000 |
parents | 02aeef95e966 |
children | 0cd97a844141 |
files | src/articulated_vehicles.cpp src/autoreplace_cmd.cpp src/newgrf_engine.cpp |
diffstat | 3 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -109,13 +109,13 @@ */ static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, bool include_initial_cargo_type) { - uint32 cargoes = 0; - CargoID initial_cargo_type; + const Engine *e = Engine::Get(engine); + if (!e->CanCarryCargo()) return 0; - if (GetVehicleDefaultCapacity(engine, &initial_cargo_type) > 0) { - const EngineInfo *ei = EngInfo(engine); - cargoes = ei->refit_mask; - if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargoes, initial_cargo_type); + uint32 cargoes = e->info.refit_mask; + + if (include_initial_cargo_type) { + SetBit(cargoes, e->GetDefaultCargoType()); } return cargoes; @@ -240,7 +240,7 @@ CargoID first_cargo = CT_INVALID; 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 != v->cargo_type) { if (cargo_type != NULL) *cargo_type = CT_INVALID;
--- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -206,7 +206,7 @@ * 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()) { - 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 */ if (HasBit(available_cargo_types, v->cargo_type)) return v->cargo_type; }
--- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -498,7 +498,7 @@ if (v->type == VEH_TRAIN) user_def_data |= Train::From(u)->tcache.user_def_data; /* Skip empty engines */ - if (u->cargo_cap == 0) continue; + if (!u->GetEngine()->CanCarryCargo()) continue; cargo_classes |= CargoSpec::Get(u->cargo_type)->classes; common_cargoes[u->cargo_type]++; @@ -516,7 +516,7 @@ /* Count subcargo types of common_cargo_type */ for (u = v; u != NULL; u = u->Next()) { /* 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]++; }