Changeset - r7096:4ffe6f8fa4da
[Not reviewed]
master
0 8 0
peter1138 - 17 years ago 2007-06-27 20:40:20
peter1138@openttd.org
(svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
8 files changed with 12 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -451,7 +451,7 @@ CommandCost CmdBuildAircraft(TileIndex t
 
		RebuildVehicleLists();
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		if (IsLocalPlayer())
 
			InvalidateAutoreplaceWindow(VEH_AIRCRAFT); //updates the replace Aircraft window
 
			InvalidateAutoreplaceWindow(VEH_AIRCRAFT, v->group_id); //updates the replace Aircraft window
 

	
 
		GetPlayer(_current_player)->num_engines[p1]++;
 
	}
src/autoreplace_gui.cpp
Show inline comments
 
@@ -38,17 +38,19 @@ void InitializeVehiclesGuiList()
 

	
 
/** Rebuild the left autoreplace list if an engine is removed or added
 
 * @param e Engine to check if it is removed or added
 
 * @param id_g The group the engine belongs to
 
 *  Note: this function only works if it is called either
 
 *   - when a new vehicle is build, but before it's counted in num_engines
 
 *   - when a vehicle is deleted and after it's substracted from num_engines
 
 *   - when not changing the count (used when changing replace orders)
 
 */
 
void InvalidateAutoreplaceWindow(EngineID e)
 
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
 
{
 
	Player *p = GetPlayer(_local_player);
 
	byte type = GetEngine(e)->type;
 
	uint num_engines = IsDefaultGroupID(id_g) ? p->num_engines[e] : GetGroup(id_g)->num_engines[e];
 

	
 
	if (p->num_engines[e] == 0) {
 
	if (num_engines == 0 || p->num_engines[e] == 0) {
 
		/* We don't have any of this engine type.
 
		 * Either we just sold the last one, we build a new one or we stopped replacing it.
 
		 * In all cases, we need to update the left list */
src/players.cpp
Show inline comments
 
@@ -736,7 +736,7 @@ CommandCost CmdSetAutoReplace(TileIndex 
 
				cost = RemoveEngineReplacementForPlayer(p, old_engine_type,id_g, flags);
 
			}
 

	
 
			if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type);
 
			if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type, id_g);
 

	
 
			return cost;
 
		}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -269,7 +269,7 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
		RebuildVehicleLists();
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		if (IsLocalPlayer())
 
			InvalidateAutoreplaceWindow(VEH_ROAD); // updates the replace Road window
 
			InvalidateAutoreplaceWindow(VEH_ROAD, v->group_id); // updates the replace Road window
 

	
 
		GetPlayer(_current_player)->num_engines[p1]++;
 
	}
src/ship_cmd.cpp
Show inline comments
 
@@ -894,7 +894,7 @@ CommandCost CmdBuildShip(TileIndex tile,
 
		RebuildVehicleLists();
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		if (IsLocalPlayer())
 
			InvalidateAutoreplaceWindow(VEH_SHIP); // updates the replace Ship window
 
			InvalidateAutoreplaceWindow(VEH_SHIP, v->group_id); // updates the replace Ship window
 

	
 
		GetPlayer(_current_player)->num_engines[p1]++;
 
	}
src/train_cmd.cpp
Show inline comments
 
@@ -587,7 +587,7 @@ static CommandCost CmdBuildRailWagon(Eng
 

	
 
			InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
			if (IsLocalPlayer()) {
 
				InvalidateAutoreplaceWindow(VEH_TRAIN); // updates the replace Train window
 
				InvalidateAutoreplaceWindow(VEH_TRAIN, v->group_id); // updates the replace Train window
 
			}
 
			GetPlayer(_current_player)->num_engines[engine]++;
 
		}
 
@@ -771,7 +771,7 @@ CommandCost CmdBuildRailVehicle(TileInde
 
			RebuildVehicleLists();
 
			InvalidateWindow(WC_COMPANY, v->owner);
 
			if (IsLocalPlayer())
 
				InvalidateAutoreplaceWindow(VEH_TRAIN); // updates the replace Train window
 
				InvalidateAutoreplaceWindow(VEH_TRAIN, v->group_id); // updates the replace Train window
 

	
 
			GetPlayer(_current_player)->num_engines[p1]++;
 
		}
src/vehicle.cpp
Show inline comments
 
@@ -677,7 +677,7 @@ void DestroyVehicle(Vehicle *v)
 

	
 
	if (IsEngineCountable(v)) {
 
		GetPlayer(v->owner)->num_engines[v->engine_type]--;
 
		if (v->owner == _local_player) InvalidateAutoreplaceWindow(v->engine_type);
 
		if (v->owner == _local_player) InvalidateAutoreplaceWindow(v->engine_type, v->group_id);
 

	
 
		if (IsValidGroupID(v->group_id)) GetGroup(v->group_id)->num_engines[v->engine_type]--;
 
		if (v->IsPrimaryVehicle()) DecreaseGroupNumVehicle(v->group_id);
src/vehicle.h
Show inline comments
 
@@ -567,7 +567,7 @@ CommandCost SendAllVehiclesToDepot(Vehic
 
bool IsVehicleInDepot(const Vehicle *v);
 
void VehicleEnterDepot(Vehicle *v);
 

	
 
void InvalidateAutoreplaceWindow(EngineID e);
 
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
 

	
 
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
 
bool CanBuildVehicleInfrastructure(VehicleType type);
0 comments (0 inline, 0 general)