summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-02-19 18:34:24 +0000
committerfrosch <frosch@openttd.org>2012-02-19 18:34:24 +0000
commit5167f2be29957bd96d06b0103f448b25a20691be (patch)
tree166a589e6c9b679be253b9703735cf536df1ae67 /src
parent3d6f8cd7d4ee6268c497e0f8217dce5e62e12177 (diff)
downloadopenttd-5167f2be29957bd96d06b0103f448b25a20691be.tar.xz
(svn r23965) -Fix [FS#5070]: Refittability should never depend on the current capacity of a vehicle.
Diffstat (limited to 'src')
-rw-r--r--src/articulated_vehicles.cpp14
-rw-r--r--src/autoreplace_cmd.cpp2
-rw-r--r--src/newgrf_engine.cpp4
3 files changed, 10 insertions, 10 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 7a7d05a94..d153a169f 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -109,13 +109,13 @@ static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_t
*/
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;
+
+ uint32 cargoes = e->info.refit_mask;
- 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);
+ if (include_initial_cargo_type) {
+ SetBit(cargoes, e->GetDefaultCargoType());
}
return cargoes;
@@ -240,7 +240,7 @@ bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *car
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;
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 87ff69449..31bf75dee 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -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 */
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;
}
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 980ee33f2..3c1a93ac0 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -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;
/* 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 @@ static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte
/* 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]++;
}