diff options
author | bjarni <bjarni@openttd.org> | 2005-10-24 19:40:48 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2005-10-24 19:40:48 +0000 |
commit | 0f5c8787f8c0914f88dce4f1c106a82453c71165 (patch) | |
tree | cf9fee9ef1a7b1f4ef668ebcedec8d771cdfc860 /vehicle_gui.c | |
parent | 5536de23191ee3896783b45ea4b3f8531ca99d7c (diff) | |
download | openttd-0f5c8787f8c0914f88dce4f1c106a82453c71165.tar.xz |
(svn r3081) -Codechange: [autoreplace] complete rewrite of autoreplace
this is a complete rewrite, that makes use of existing commands like build and sell
this means that multiheaded train engines are replaced correctly
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r-- | vehicle_gui.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c index 81231658f..35aef4581 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -17,6 +17,7 @@ #include "gfx.h" #include "variables.h" #include "vehicle_gui.h" +#include "viewport.h" Sorting _sorting; @@ -1084,3 +1085,42 @@ void InitializeGUI(void) { memset(&_sorting, 0, sizeof(_sorting)); } + +/** Assigns an already open vehicle window to a new vehicle. +* Assigns an already open vehicle window to a new vehicle. If the vehicle got any sub window open (orders and so on) it will change owner too +* @param *from_v the current owner of the window +* @param *to_v the new owner of the window +*/ +void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v) +{ + Window *w; + + w = FindWindowById(WC_VEHICLE_VIEW, from_v->index); + + if (w != NULL) { + w->window_number = to_v->index; + WP(w, vp_d).follow_vehicle = (VehicleID)(w->window_number & 0xFFFF); + SetWindowDirty(w); + + w = FindWindowById(WC_VEHICLE_ORDERS, from_v->index); + + if (w != NULL) { + w->window_number = to_v->index; + SetWindowDirty(w); + } + + w = FindWindowById(WC_VEHICLE_REFIT, from_v->index); + + if (w != NULL) { + w->window_number = to_v->index; + SetWindowDirty(w); + } + + w = FindWindowById(WC_VEHICLE_DETAILS, from_v->index); + + if (w != NULL) { + w->window_number = to_v->index; + SetWindowDirty(w); + } + } +} |