diff options
Diffstat (limited to 'src/autoreplace_gui.cpp')
-rw-r--r-- | src/autoreplace_gui.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index f77428dda..159c21824 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -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 */ |