summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-08-10 20:06:39 +0000
committerfrosch <frosch@openttd.org>2009-08-10 20:06:39 +0000
commit52f9b8ffbd5fe9222da34e968d69876982b9a810 (patch)
treeac1f89eacfa91e22cdd80d1c7d39ba898bd0944f /src/window.cpp
parent238b0e43bbaa997acb7e53f1de118a963bb330fa (diff)
downloadopenttd-52f9b8ffbd5fe9222da34e968d69876982b9a810.tar.xz
(svn r17147) -Fix [FS#3048]: Keep vehicle news and viewports following vehicles, when autoreplacing/renewing them.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 6c202f489..0d46ff644 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2663,6 +2663,24 @@ void SetHScrollCount(Window *w, int num)
if (num < w->hscroll.pos) w->hscroll.pos = num;
}
+
+/**
+ * Switches viewports following vehicles, which get autoreplaced
+ * @param from_index the old vehicle ID
+ * @param to_index the new vehicle ID
+ */
+void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index)
+{
+ Window *w;
+ FOR_ALL_WINDOWS_FROM_BACK(w) {
+ if (w->viewport != NULL && w->viewport->follow_vehicle == from_index) {
+ w->viewport->follow_vehicle = to_index;
+ w->SetDirty();
+ }
+ }
+}
+
+
/**
* Relocate all windows to fit the new size of the game application screen
* @param neww New width of the game application screen