mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
This commit is contained in:
parent
2a96ca6983
commit
de357c74c1
@ -451,7 +451,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
RebuildVehicleLists();
|
RebuildVehicleLists();
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
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]++;
|
GetPlayer(_current_player)->num_engines[p1]++;
|
||||||
}
|
}
|
||||||
|
@ -38,17 +38,19 @@ void InitializeVehiclesGuiList()
|
|||||||
|
|
||||||
/** Rebuild the left autoreplace list if an engine is removed or added
|
/** Rebuild the left autoreplace list if an engine is removed or added
|
||||||
* @param e Engine to check if it 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
|
* 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 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 a vehicle is deleted and after it's substracted from num_engines
|
||||||
* - when not changing the count (used when changing replace orders)
|
* - 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);
|
Player *p = GetPlayer(_local_player);
|
||||||
byte type = GetEngine(e)->type;
|
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.
|
/* 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.
|
* 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 */
|
* In all cases, we need to update the left list */
|
||||||
|
@ -736,7 +736,7 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||||||
cost = RemoveEngineReplacementForPlayer(p, old_engine_type,id_g, flags);
|
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;
|
return cost;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
RebuildVehicleLists();
|
RebuildVehicleLists();
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
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]++;
|
GetPlayer(_current_player)->num_engines[p1]++;
|
||||||
}
|
}
|
||||||
|
@ -894,7 +894,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
RebuildVehicleLists();
|
RebuildVehicleLists();
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
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]++;
|
GetPlayer(_current_player)->num_engines[p1]++;
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla
|
|||||||
|
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
if (IsLocalPlayer()) {
|
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]++;
|
GetPlayer(_current_player)->num_engines[engine]++;
|
||||||
}
|
}
|
||||||
@ -771,7 +771,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
|
|||||||
RebuildVehicleLists();
|
RebuildVehicleLists();
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
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]++;
|
GetPlayer(_current_player)->num_engines[p1]++;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +677,7 @@ void DestroyVehicle(Vehicle *v)
|
|||||||
|
|
||||||
if (IsEngineCountable(v)) {
|
if (IsEngineCountable(v)) {
|
||||||
GetPlayer(v->owner)->num_engines[v->engine_type]--;
|
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 (IsValidGroupID(v->group_id)) GetGroup(v->group_id)->num_engines[v->engine_type]--;
|
||||||
if (v->IsPrimaryVehicle()) DecreaseGroupNumVehicle(v->group_id);
|
if (v->IsPrimaryVehicle()) DecreaseGroupNumVehicle(v->group_id);
|
||||||
|
@ -567,7 +567,7 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service,
|
|||||||
bool IsVehicleInDepot(const Vehicle *v);
|
bool IsVehicleInDepot(const Vehicle *v);
|
||||||
void VehicleEnterDepot(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);
|
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
|
||||||
bool CanBuildVehicleInfrastructure(VehicleType type);
|
bool CanBuildVehicleInfrastructure(VehicleType type);
|
||||||
|
Loading…
Reference in New Issue
Block a user