Changeset - r10528:99ad5205b347
[Not reviewed]
master
0 7 0
rubidium - 15 years ago 2009-01-02 20:59:04
rubidium@openttd.org
(svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
7 files changed with 34 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/station.cpp
Show inline comments
 
@@ -30,12 +30,13 @@
 
#include "variables.h"
 
#include "settings_type.h"
 
#include "command_func.h"
 
#include "order_func.h"
 
#include "news_func.h"
 
#include "aircraft.h"
 
#include "vehicle_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
Station::Station(TileIndex tile)
 
{
 
@@ -84,12 +85,17 @@ Station::~Station()
 
	}
 

	
 
	MarkDirty();
 
	InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
 

	
 
	DeleteWindowById(WC_STATION_VIEW, index);
 
	WindowNumber wno = (index << 16) | VLW_STATION_LIST | this->owner;
 
	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 

	
 
	/* Now delete all orders that go to the station */
 
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
 

	
 
	/* Subsidies need removal as well */
 
	DeleteSubsidyWithStation(index);
src/station_gui.cpp
Show inline comments
 
@@ -697,16 +697,16 @@ struct StationViewWindow : public Window
 

	
 
	~StationViewWindow()
 
	{
 
		WindowNumber wno =
 
			(this->window_number << 16) | VLW_STATION_LIST | GetStation(this->window_number)->owner;
 

	
 
		DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
		DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
		DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
		DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 
		DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11), false);
 
		DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
 
		DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11), false);
 
		DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11), false);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		StationID station_id = this->window_number;
 
		const Station *st = GetStation(station_id);
src/train_cmd.cpp
Show inline comments
 
@@ -1290,12 +1290,16 @@ CommandCost CmdMoveRailVehicle(TileIndex
 
			}
 
			dst_head = src;
 
		} else {
 
			if (IsFrontEngine(src)) {
 
				/* the vehicle was previously a loco. need to free the order list and delete vehicle windows etc. */
 
				DeleteWindowById(WC_VEHICLE_VIEW, src->index);
 
				DeleteWindowById(WC_VEHICLE_ORDERS, src->index);
 
				DeleteWindowById(WC_VEHICLE_REFIT, src->index);
 
				DeleteWindowById(WC_VEHICLE_DETAILS, src->index);
 
				DeleteWindowById(WC_VEHICLE_TIMETABLE, src->index);
 
				DeleteVehicleOrders(src);
 
				RemoveVehicleFromGroup(src);
 
			}
 

	
 
			if (IsFrontEngine(src) || IsFreeWagon(src)) {
 
				InvalidateWindowData(WC_VEHICLE_DEPOT, src->tile);
 
@@ -1399,12 +1403,16 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
	if (IsRearDualheaded(v)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
 

	
 
	if (flags & DC_EXEC) {
 
		if (v == first && IsFrontEngine(first)) {
 
			DeleteWindowById(WC_VEHICLE_VIEW, first->index);
 
			DeleteWindowById(WC_VEHICLE_ORDERS, first->index);
 
			DeleteWindowById(WC_VEHICLE_REFIT, first->index);
 
			DeleteWindowById(WC_VEHICLE_DETAILS, first->index);
 
			DeleteWindowById(WC_VEHICLE_TIMETABLE, first->index);
 
		}
 
		InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
 
		InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 
	}
 

	
 
	CommandCost cost(EXPENSES_NEW_VEHICLES);
src/vehicle.cpp
Show inline comments
 
@@ -669,14 +669,16 @@ void Vehicle::PreDestructor()
 
	if (this->type != VEH_TRAIN || (this->type == VEH_TRAIN && (IsFrontEngine(this) || IsFreeWagon(this)))) {
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, this->tile);
 
	}
 

	
 
	if (this->IsPrimaryVehicle()) {
 
		DeleteWindowById(WC_VEHICLE_VIEW, this->index);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->index);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->index);
 
		InvalidateWindow(WC_COMPANY, this->owner);
 
	}
 
	InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
 

	
 
	this->cargo.Truncate(0);
 
	DeleteVehicleOrders(this);
src/vehicle_gui.cpp
Show inline comments
 
@@ -1814,16 +1814,16 @@ struct VehicleViewWindow : Window {
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~VehicleViewWindow()
 
	{
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number, false);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->window_number, false);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number, false);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number, false);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/** Message strings for heading to depot indexed by vehicle type. */
 
		static const StringID _heading_for_depot_strings[] = {
src/window.cpp
Show inline comments
 
@@ -489,16 +489,22 @@ Window *FindWindowById(WindowClass cls, 
 
}
 

	
 
/**
 
 * Delete a window by its class and window number (if it is open).
 
 * @param cls Window class
 
 * @param number Number of the window within the window class
 
 * @param force force deletion; if false don't delete when stickied
 
 */
 
void DeleteWindowById(WindowClass cls, WindowNumber number)
 
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
 
{
 
	delete FindWindowById(cls, number);
 
	Window *w = FindWindowById(cls, number);
 
	if (force || w == NULL ||
 
			(w->desc_flags & WDF_STICKY_BUTTON) == 0 ||
 
			(w->flags4 & WF_STICKY) == 0) {
 
		delete w;
 
	}
 
}
 

	
 
/**
 
 * Delete all windows of a given class
 
 * @param cls Window class of windows to delete
 
 */
src/window_func.h
Show inline comments
 
@@ -32,10 +32,10 @@ void HideVitalWindows();
 
void ShowVitalWindows();
 

	
 
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
 
void InvalidateWindow(WindowClass cls, WindowNumber number);
 
void InvalidateWindowClasses(WindowClass cls);
 

	
 
void DeleteWindowById(WindowClass cls, WindowNumber number);
 
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true);
 
void DeleteWindowByClass(WindowClass cls);
 

	
 
#endif /* WINDOW_FUNC_H */
0 comments (0 inline, 0 general)