diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index e69ac66eb..b3563e7e8 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -19,6 +19,7 @@ #include "autoreplace_gui.h" #include "articulated_vehicles.h" #include "core/random_func.hpp" +#include "vehiclelist.h" #include "table/strings.h" @@ -779,6 +780,9 @@ CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, ui if (flags & DC_EXEC) { GroupStatistics::UpdateAutoreplace(_current_company); if (IsLocalCompany()) SetWindowDirty(WC_REPLACE_VEHICLE, Engine::Get(old_engine_type)->type); + + const VehicleType vt = Engine::Get(old_engine_type)->type; + SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).Pack()); } if ((flags & DC_EXEC) && IsLocalCompany()) InvalidateAutoreplaceWindow(old_engine_type, id_g); diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 12cce41f7..7ccdb4a1a 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -232,7 +232,7 @@ void GroupStatistics::Clear() stats.autoreplace_defined = true; stats.autoreplace_finished = true; } - if (stats.num_engines[erl->from] > 0) stats.autoreplace_finished = false; + if (GetGroupNumEngines(company, erl->group_id, erl->from) > 0) stats.autoreplace_finished = false; } } @@ -410,6 +410,8 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (flags & DC_EXEC) { g->parent = (pg == NULL) ? INVALID_GROUP : pg->index; } + + GroupStatistics::UpdateAutoreplace(g->owner); } if (flags & DC_EXEC) {