diff options
author | peter1138 <peter1138@openttd.org> | 2007-06-27 20:40:20 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-06-27 20:40:20 +0000 |
commit | de357c74c1ac4df582f32849bfbc5681c3552171 (patch) | |
tree | 30e7a8bb576d442ce724911974f73d059b2ee6b3 /src/autoreplace_gui.cpp | |
parent | 2a96ca698380b003d1e68f82b1d3fdc4b4df0e44 (diff) | |
download | openttd-de357c74c1ac4df582f32849bfbc5681c3552171.tar.xz |
(svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
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 */ |