(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
This commit is contained in:
bjarni
2005-10-24 19:40:48 +00:00
parent e0dd7efc82
commit bf467bd99c
9 changed files with 258 additions and 304 deletions

View File

@@ -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);
}
}
}