summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-12-03 15:48:21 +0000
committerpeter1138 <peter1138@openttd.org>2006-12-03 15:48:21 +0000
commit00e9e3e9e6fa790ad8fe1c915f12d47e803ab89e (patch)
tree7fff8ddf2fb4e34463baa3c967c238f272fe2720
parent7cc06c10d97cf6ef08a673480a50b69b7d2dacdf (diff)
downloadopenttd-00e9e3e9e6fa790ad8fe1c915f12d47e803ab89e.tar.xz
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
player, resulting in an empty vehicle purchase list. Specify the player as an argument to IsEngineBuildable()
-rw-r--r--aircraft_cmd.c2
-rw-r--r--build_vehicle_gui.c2
-rw-r--r--engine.c7
-rw-r--r--engine.h2
-rw-r--r--roadveh_cmd.c2
-rw-r--r--ship_cmd.c2
-rw-r--r--train_cmd.c2
-rw-r--r--train_gui.c2
8 files changed, 11 insertions, 10 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 46e06f417..9f65f72e3 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -207,7 +207,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
const AirportFTAClass* ap;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_Aircraft)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_Aircraft, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
value = EstimateAircraftCost(p1);
diff --git a/build_vehicle_gui.c b/build_vehicle_gui.c
index 1f2639129..ce6ba8c0f 100644
--- a/build_vehicle_gui.c
+++ b/build_vehicle_gui.c
@@ -290,7 +290,7 @@ static void GenerateBuildAircraftList(Window *w)
* when planes become obsolete and are removed */
sel_id = INVALID_ENGINE;
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
- if (IsEngineBuildable(eid, VEH_Aircraft)) {
+ if (IsEngineBuildable(eid, VEH_Aircraft, _local_player)) {
const AircraftVehicleInfo *avi = AircraftVehInfo(eid);
switch (bv->filter.acc_planes) {
case HELICOPTERS_ONLY:
diff --git a/engine.c b/engine.c
index f2f903af3..d6acd5d05 100644
--- a/engine.c
+++ b/engine.c
@@ -401,12 +401,13 @@ int32 CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/*
* returns true if an engine is valid, of the specified type, and buildable by
- * the current player, false otherwise
+ * the given player, false otherwise
*
* engine = index of the engine to check
* type = the type the engine should be of (VEH_xxx)
+ * player = index of the player
*/
-bool IsEngineBuildable(uint engine, byte type)
+bool IsEngineBuildable(EngineID engine, byte type, PlayerID player)
{
const Engine *e;
@@ -419,7 +420,7 @@ bool IsEngineBuildable(uint engine, byte type)
if (e->type != type) return false;
// check if it's available
- if (!HASBIT(e->player_avail, _current_player)) return false;
+ if (!HASBIT(e->player_avail, player)) return false;
return true;
}
diff --git a/engine.h b/engine.h
index ddf0abc95..9675ca396 100644
--- a/engine.h
+++ b/engine.h
@@ -137,7 +137,7 @@ void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod);
void LoadCustomEngineNames(void);
void DeleteCustomEngineNames(void);
-bool IsEngineBuildable(uint engine, byte type);
+bool IsEngineBuildable(EngineID engine, byte type, PlayerID player);
enum {
NUM_NORMAL_RAIL_ENGINES = 54,
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 3a29ff3cd..d9e365508 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -114,7 +114,7 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
UnitID unit_num;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_Road)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_Road, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
diff --git a/ship_cmd.c b/ship_cmd.c
index e25ec5425..b81ee457f 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -814,7 +814,7 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
UnitID unit_num;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_Ship)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_Ship, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
diff --git a/train_cmd.c b/train_cmd.c
index 65154de6b..76ea710cd 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -743,7 +743,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
uint num_vehicles;
/* Check if the engine-type is valid (for the player) */
- if (!IsEngineBuildable(p1, VEH_Train)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_Train, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
/* Check if the train is actually being built in a depot belonging
* to the player. Doesn't matter if only the cost is queried */
diff --git a/train_gui.c b/train_gui.c
index 69f27665e..8acef3706 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -393,7 +393,7 @@ static void GenerateBuildList(Window *w)
const RailVehicleInfo *rvi = RailVehInfo(eid);
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(e->railtype, bv->filter.railtype)) continue;
- if (!IsEngineBuildable(eid, VEH_Train)) continue;
+ if (!IsEngineBuildable(eid, VEH_Train, _local_player)) continue;
EngList_Add(&bv->eng_list, eid);
if ((rvi->flags & RVI_WAGON) == 0) {