Fix cases where departures board data was not invalidated

pull/135/head
Jonathan G Rennison 4 years ago
parent 749b9da602
commit cb6a01cab3

@ -916,6 +916,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (StoryPage::GetNumItems() == 0 || Goal::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
extern void CheckCaches(bool force_check, std::function<void(const char *)> log);
CheckCaches(true, nullptr);
break;

@ -90,6 +90,7 @@ protected:
StationID station; ///< The station whose departures we're showing.
DepartureList *departures; ///< The current list of departures from this station.
DepartureList *arrivals; ///< The current list of arrivals from this station.
bool departures_invalid; ///< The departures and arrivals list are currently invalid.
uint entry_height; ///< The height of an entry in the departures list.
uint tick_count; ///< The number of ticks that have elapsed since the window was created. Used for scrolling text.
int calc_tick_countdown; ///< The number of ticks to wait until recomputing the departure list. Signed in case it goes below zero.
@ -213,6 +214,7 @@ public:
station(window_number),
departures(new DepartureList()),
arrivals(new DepartureList()),
departures_invalid(true),
entry_height(1 + FONT_HEIGHT_NORMAL + 1 + (_settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL) + 1 + 1),
tick_count(0),
calc_tick_countdown(0),
@ -356,6 +358,8 @@ public:
break;
case WID_DB_LIST: { // Matrix to show departures
if (this->departures_invalid) return;
/* We need to find the departure corresponding to where the user clicked. */
uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(WID_DB_LIST)->pos_y) / this->entry_height;
@ -442,6 +446,7 @@ public:
bool show_freight = _settings_client.gui.departure_only_passengers ? false : this->show_freight;
this->departures = (this->departure_types[0] ? MakeDepartureList(this->station, this->vehicles, D_DEPARTURE, Twaypoint || this->departure_types[2], show_pax, show_freight) : new DepartureList());
this->arrivals = (this->departure_types[1] && !_settings_client.gui.departure_show_both ? MakeDepartureList(this->station, this->vehicles, D_ARRIVAL, false, show_pax, show_freight) : new DepartureList());
this->departures_invalid = false;
this->SetWidgetDirty(WID_DB_LIST);
}
@ -463,6 +468,13 @@ public:
}
}
virtual void OnRealtimeTick(uint delta_ms) override
{
if (_pause_mode != PM_UNPAUSED && this->calc_tick_countdown <= 0) {
this->OnGameTick();
}
}
virtual void OnPaint() override
{
if (Twaypoint || _settings_client.gui.departure_show_both) {
@ -500,6 +512,7 @@ public:
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
this->RefreshVehicleList();
this->departures_invalid = true;
}
};

@ -2225,6 +2225,7 @@ static void DoAcquireCompany(Company *c)
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
delete c;

@ -2441,6 +2441,7 @@ void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist, bool reset_order_indic
v->orders.list = nullptr;
} else {
DeleteWindowById(GetWindowClassForVehicleType(v->type), VehicleListIdentifier(VL_SHARED_ORDERS, v->type, v->owner, v->index).Pack());
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
if (v->orders.list != nullptr) {
/* Remove the orders */
v->orders.list->FreeChain(keep_orderlist);

@ -1593,6 +1593,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
InvalidateWindowData(WC_VEHICLE_DEPOT, src->tile);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS, 0);
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
}
} else {
/* We don't want to execute what we're just tried. */
@ -1684,6 +1685,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS, 0);
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
}
/* Actually delete the sold 'goods' */

@ -49,6 +49,7 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
DoCommandP(0, _new_vehicle_id, found->index, CMD_MOVE_RAIL_VEHICLE);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS, 0);
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
}
}

@ -350,6 +350,7 @@ uint Vehicle::Crash(bool flooded)
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
SetWindowDirty(WC_VEHICLE_DEPOT, this->tile);
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
delete this->cargo_payment;
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment

Loading…
Cancel
Save