summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-06-07 07:20:28 +0000
committerpeter1138 <peter1138@openttd.org>2006-06-07 07:20:28 +0000
commitd286235a6ada2616c4e19fbfff565867e379bc21 (patch)
tree4539d4235dbbf4c3b1a8fdac043c17f06e9fe707 /vehicle.c
parent4a26eb083b7de1834257ceacb338e0a0c07dab00 (diff)
downloadopenttd-d286235a6ada2616c4e19fbfff565867e379bc21.tar.xz
(svn r5146) - NewGRF: Support selection of aircraft default cargo type by checking its refit mask. If aircraft can be refitted to passengers, no change happens, else the first refittable type is chosen. Also use refit capacity to determine the default capacity.
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/vehicle.c b/vehicle.c
index 9f9279cec..b7b521248 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -692,6 +692,25 @@ bool CanRefitTo(EngineID engine_type, CargoID cid_to)
return HASBIT(EngInfo(engine_type)->refit_mask, cid);
}
+/** Find the first cargo type that an engine can be refitted to.
+ * @param engine Which engine to find cargo for.
+ * @return A climate dependent cargo type. CT_INVALID is returned if not refittable.
+ */
+CargoID FindFirstRefittableCargo(EngineID engine_type)
+{
+ CargoID cid;
+ uint32 refit_mask = EngInfo(engine_type)->refit_mask;
+
+ if (refit_mask != 0) {
+ for (cid = CT_PASSENGERS; cid < NUM_CARGO; cid++) {
+ if (HASBIT(refit_mask, _global_cargo_id[_opt_ptr->landscape][cid])) return cid;
+ }
+ }
+
+ return CT_INVALID;
+}
+
+
static void DoDrawVehicle(const Vehicle *v)
{
uint32 image = v->cur_image;