mirror of https://github.com/OpenTTD/OpenTTD.git
(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.
This commit is contained in:
parent
bde4b6020a
commit
b3f2f40db7
|
@ -33,6 +33,7 @@
|
|||
#include "order_func.h"
|
||||
#include "news_func.h"
|
||||
#include "aircraft.h"
|
||||
#include "vehicle_gui.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
|
@ -87,6 +88,11 @@ Station::~Station()
|
|||
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);
|
||||
|
|
|
@ -700,10 +700,10 @@ struct StationViewWindow : public Window {
|
|||
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()
|
||||
|
|
|
@ -1293,6 +1293,10 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
|||
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);
|
||||
}
|
||||
|
@ -1402,6 +1406,10 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
|
|||
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);
|
||||
|
|
|
@ -672,8 +672,10 @@ void Vehicle::PreDestructor()
|
|||
|
||||
if (this->IsPrimaryVehicle()) {
|
||||
DeleteWindowById(WC_VEHICLE_VIEW, this->index);
|
||||
DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
|
||||
DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
|
||||
DeleteWindowById(WC_VEHICLE_REFIT, this->index);
|
||||
DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
|
||||
DeleteWindowById(WC_VEHICLE_TIMETABLE, this->index);
|
||||
InvalidateWindow(WC_COMPANY, this->owner);
|
||||
}
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
|
||||
|
|
|
@ -1817,10 +1817,10 @@ struct VehicleViewWindow : Window {
|
|||
|
||||
~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()
|
||||
|
|
|
@ -492,10 +492,16 @@ Window *FindWindowById(WindowClass cls, WindowNumber number)
|
|||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_in
|
|||
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 */
|
||||
|
|
Loading…
Reference in New Issue