diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -4,7 +4,6 @@ #include "stdafx.h" #include "company_func.h" -#include "vehicle_gui.h" #include "train.h" #include "rail.h" #include "command_func.h" @@ -18,6 +17,10 @@ #include "table/strings.h" +extern void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index); +extern void ChangeVehicleNews(VehicleID from_index, VehicleID to_index); +extern void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index); + /** Figure out if two engines got at least one type of cargo in common (refitting if needed) * @param engine_a one of the EngineIDs * @param engine_b the other EngineID @@ -332,8 +335,10 @@ static CommandCost CopyHeadSpecificThing /* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */ new_head->CopyVehicleConfigAndStatistics(old_head); - /* Switch vehicle windows to the new vehicle, so they are not closed when the old vehicle is sold */ + /* Switch vehicle windows/news to the new vehicle, so they are not closed/deleted when the old vehicle is sold */ + ChangeVehicleViewports(old_head->index, new_head->index); ChangeVehicleViewWindow(old_head->index, new_head->index); + ChangeVehicleNews(old_head->index, new_head->index); } return cost;