summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2005-11-29 22:29:59 +0000
committerpeter1138 <peter1138@openttd.org>2005-11-29 22:29:59 +0000
commit0b48a69e0237dfa1fd0f65ebc48674089f9972aa (patch)
tree0f74bc18a32d47dcd8443ec9fb7a992a9e350615
parent627dd10451c904e32d873b50eebe9f8ca935c7a5 (diff)
downloadopenttd-0b48a69e0237dfa1fd0f65ebc48674089f9972aa.tar.xz
(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.
-rw-r--r--aircraft_cmd.c2
-rw-r--r--ship_cmd.c2
-rw-r--r--train_cmd.c2
-rw-r--r--vehicle.c8
-rw-r--r--vehicle.h2
5 files changed, 8 insertions, 8 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index eaeeb0c84..06aef2916 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -496,7 +496,7 @@ int32 CmdRefitAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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);
diff --git a/ship_cmd.c b/ship_cmd.c
index c029a04b6..be6b2aee8 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -1056,7 +1056,7 @@ int32 CmdRefitShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* 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);
diff --git a/train_cmd.c b/train_cmd.c
index 71672ca44..2689da67f 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1717,7 +1717,7 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* 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);
diff --git a/vehicle.c b/vehicle.c
index 3c7f3156d..dbf65f494 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -680,15 +680,15 @@ bool CanFillVehicle(Vehicle *v)
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)
diff --git a/vehicle.h b/vehicle.h
index 59955de41..d8b2b8e36 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -273,7 +273,7 @@ Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
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);