From 0f5c8787f8c0914f88dce4f1c106a82453c71165 Mon Sep 17 00:00:00 2001 From: bjarni Date: Mon, 24 Oct 2005 19:40:48 +0000 Subject: (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 --- vehicle_gui.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'vehicle_gui.c') 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); + } + } +} -- cgit v1.2.3-54-g00ecf