summaryrefslogtreecommitdiff
path: root/src/articulated_vehicles.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-02-27 20:40:39 +0000
committerfrosch <frosch@openttd.org>2009-02-27 20:40:39 +0000
commite01106f66b8b003ebc847470d1291af8ef640c96 (patch)
tree7419f11ae37834876be39c85f17576ba1dd82c3e /src/articulated_vehicles.cpp
parent729972847269e3661e2647f18061f1a02d010d0c (diff)
downloadopenttd-e01106f66b8b003ebc847470d1291af8ef640c96.tar.xz
(svn r15592) -Fix: Refit-info in purchase list did only check the first articulated part.
Diffstat (limited to 'src/articulated_vehicles.cpp')
-rw-r--r--src/articulated_vehicles.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index ac894f362..a53facf80 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -118,8 +118,32 @@ uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
}
/**
+ * Checks whether any of the articulated parts is refittable
+ * @param engine the first part
+ * @return true if refittable
+ */
+bool IsArticulatedVehicleRefittable(EngineID engine)
+{
+ if (IsEngineRefittable(engine)) return true;
+
+ const Engine *e = GetEngine(engine);
+ if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return false;
+
+ if (!HasBit(e->info.callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return false;
+
+ for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
+ uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
+ if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
+
+ EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
+ if (IsEngineRefittable(artic_engine)) return true;
+ }
+
+ return false;
+}
+
+/**
* Ors the refit_masks of all articulated parts.
- * Note: Vehicles with a default capacity of zero are ignored.
* @param engine the first part
* @param type the vehicle type
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
@@ -146,7 +170,6 @@ uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool i
/**
* Ands the refit_masks of all articulated parts.
- * Note: Vehicles with a default capacity of zero are ignored.
* @param engine the first part
* @param type the vehicle type
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask