diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index cb9addd95d..35557d753c 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -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 log); CheckCaches(true, nullptr); break; diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 6765f4f928..c3f10f9e09 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -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(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; } }; diff --git a/src/economy.cpp b/src/economy.cpp index fe4f31d643..2b8fb59f7b 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -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; diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 2233d794e2..cd1e065f78 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -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); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 52aecf3fc4..1d4d1282cf 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -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' */ diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 9ac88579ce..a1b15f2c54 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -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); } } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 7260feab26..878a29bea7 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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