# HG changeset patch # User peter1138 # Date 1165160901 0 # Node ID 439d5ca713112757d146f6239fb53275e1ae1fc5 # Parent 521e6d945e5df45cab60e934875ddd5f3596790c (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() diff -r 521e6d945e5d -r 439d5ca71311 aircraft_cmd.c --- a/aircraft_cmd.c Sun Dec 03 13:40:16 2006 +0000 +++ b/aircraft_cmd.c Sun Dec 03 15:48:21 2006 +0000 @@ -207,7 +207,7 @@ 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 -r 521e6d945e5d -r 439d5ca71311 build_vehicle_gui.c --- a/build_vehicle_gui.c Sun Dec 03 13:40:16 2006 +0000 +++ b/build_vehicle_gui.c Sun Dec 03 15:48:21 2006 +0000 @@ -290,7 +290,7 @@ * 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 -r 521e6d945e5d -r 439d5ca71311 engine.c --- a/engine.c Sun Dec 03 13:40:16 2006 +0000 +++ b/engine.c Sun Dec 03 15:48:21 2006 +0000 @@ -401,12 +401,13 @@ /* * 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 @@ 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 -r 521e6d945e5d -r 439d5ca71311 engine.h --- a/engine.h Sun Dec 03 13:40:16 2006 +0000 +++ b/engine.h Sun Dec 03 15:48:21 2006 +0000 @@ -137,7 +137,7 @@ 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 -r 521e6d945e5d -r 439d5ca71311 roadveh_cmd.c --- a/roadveh_cmd.c Sun Dec 03 13:40:16 2006 +0000 +++ b/roadveh_cmd.c Sun Dec 03 15:48:21 2006 +0000 @@ -114,7 +114,7 @@ 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 -r 521e6d945e5d -r 439d5ca71311 ship_cmd.c --- a/ship_cmd.c Sun Dec 03 13:40:16 2006 +0000 +++ b/ship_cmd.c Sun Dec 03 15:48:21 2006 +0000 @@ -814,7 +814,7 @@ 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 -r 521e6d945e5d -r 439d5ca71311 train_cmd.c --- a/train_cmd.c Sun Dec 03 13:40:16 2006 +0000 +++ b/train_cmd.c Sun Dec 03 15:48:21 2006 +0000 @@ -743,7 +743,7 @@ 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 -r 521e6d945e5d -r 439d5ca71311 train_gui.c --- a/train_gui.c Sun Dec 03 13:40:16 2006 +0000 +++ b/train_gui.c Sun Dec 03 15:48:21 2006 +0000 @@ -393,7 +393,7 @@ 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) {