(svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved.
authorpeter1138
Tue, 29 Nov 2005 22:29:59 +0000
changeset 2704 bdf6ae0cb27c
parent 2703 a969970a5245
child 2705 494b6b5e7a08
(svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved.
aircraft_cmd.c
ship_cmd.c
train_cmd.c
vehicle.c
vehicle.h
--- a/aircraft_cmd.c	Tue Nov 29 22:04:02 2005 +0000
+++ b/aircraft_cmd.c	Tue Nov 29 22:29:59 2005 +0000
@@ -496,7 +496,7 @@
 	avi = AircraftVehInfo(v->engine_type);
 
 	/* Check cargo */
-	if (new_cid > NUM_CARGO || !CanRefitTo(v, new_cid)) return CMD_ERROR;
+	if (new_cid > NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
 
 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 
--- a/ship_cmd.c	Tue Nov 29 22:04:02 2005 +0000
+++ b/ship_cmd.c	Tue Nov 29 22:29:59 2005 +0000
@@ -1056,7 +1056,7 @@
 
 	/* Check cargo */
 	if (!ShipVehInfo(v->engine_type)->refittable) return CMD_ERROR;
-	if (new_cid > NUM_CARGO || !CanRefitTo(v, new_cid)) return CMD_ERROR;
+	if (new_cid > NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
 
 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
 
--- a/train_cmd.c	Tue Nov 29 22:04:02 2005 +0000
+++ b/train_cmd.c	Tue Nov 29 22:29:59 2005 +0000
@@ -1717,7 +1717,7 @@
 		/* XXX: We also refit all the attached wagons en-masse if they
 		 * can be refitted. This is how TTDPatch does it.  TODO: Have
 		 * some nice [Refit] button near each wagon. --pasky */
-		if (!CanRefitTo(v, new_cid)) continue;
+		if (!CanRefitTo(v->engine_type, new_cid)) continue;
 
 		if (v->cargo_cap != 0) {
 			const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
--- a/vehicle.c	Tue Nov 29 22:04:02 2005 +0000
+++ b/vehicle.c	Tue Nov 29 22:29:59 2005 +0000
@@ -680,15 +680,15 @@
 	return false;
 }
 
-/** Check if a given vehicle (type) can be refitted to a given cargo
- * @param *v vehicle to check
+/** Check if a given engine type can be refitted to a given cargo
+ * @param engine_type Engine type to check
  * @param cid_to check refit to this cargo-type
  * @return true if it is possible, false otherwise
  */
-bool CanRefitTo(const Vehicle *v, CargoID cid_to)
+bool CanRefitTo(EngineID engine_type, CargoID cid_to)
 {
 	CargoID cid = _global_cargo_id[_opt_ptr->landscape][cid_to];
-	return HASBIT(_engine_info[v->engine_type].refit_mask, cid) != 0;
+	return HASBIT(_engine_info[engine_type].refit_mask, cid) != 0;
 }
 
 static void DoDrawVehicle(const Vehicle *v)
--- a/vehicle.h	Tue Nov 29 22:04:02 2005 +0000
+++ b/vehicle.h	Tue Nov 29 22:29:59 2005 +0000
@@ -273,7 +273,7 @@
 void InitializeTrains(void);
 
 bool CanFillVehicle(Vehicle *v);
-bool CanRefitTo(const Vehicle *v, CargoID cid_to);
+bool CanRefitTo(EngineID engine_type, CargoID cid_to);
 
 void ViewportAddVehicles(DrawPixelInfo *dpi);