From b749d6f1cb53911f09b69397c0f3553e0eb64d39 Mon Sep 17 00:00:00 2001 From: milek7 Date: Sun, 21 Feb 2021 22:53:35 +0100 Subject: [PATCH 1/3] Fix: Allow building with Allegro and without SDL on Linux --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24496f459c..ad78e441e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,8 +150,8 @@ check_ipo_supported(RESULT IPO_FOUND) show_options() if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED) - if(NOT SDL_FOUND AND NOT SDL2_FOUND) - message(FATAL_ERROR "SDL or SDL2 is required for this platform") + if(NOT SDL_FOUND AND NOT SDL2_FOUND AND NOT ALLEGRO_FOUND) + message(FATAL_ERROR "SDL, SDL2 or Allegro is required for this platform") endif() endif() if(APPLE) From 80fb1c74f04be7a571f6a721d2f6d82ed95de9b6 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sun, 21 Feb 2021 23:58:01 +0000 Subject: [PATCH 2/3] Change: Make pathfinder account for maximum order speed, if set --- src/pathfinder/yapf/yapf_costrail.hpp | 2 +- src/pathfinder/yapf/yapf_road.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index e6422dc240..2f4834633a 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -464,7 +464,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th { int min_speed = 0; int max_speed = tf->GetSpeedLimit(&min_speed); - int max_veh_speed = v->GetDisplayMaxSpeed(); + int max_veh_speed = std::min(v->GetDisplayMaxSpeed(), v->current_order.GetMaxSpeed()); if (max_speed < max_veh_speed) { extra_cost += YAPF_TILE_LENGTH * (max_veh_speed - max_speed) * (4 + tf->m_tiles_skipped) / max_veh_speed; } diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 98cd889c91..0122e1d88b 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -159,7 +159,7 @@ public: /* add min/max speed penalties */ int min_speed = 0; - int max_veh_speed = v->GetDisplayMaxSpeed(); + int max_veh_speed = std::min(v->GetDisplayMaxSpeed(), v->current_order.GetMaxSpeed() * 2); int max_speed = F.GetSpeedLimit(&min_speed); if (max_speed < max_veh_speed) segment_cost += YAPF_TILE_LENGTH * (max_veh_speed - max_speed) * (4 + F.m_tiles_skipped) / max_veh_speed; if (min_speed > max_veh_speed) segment_cost += YAPF_TILE_LENGTH * (min_speed - max_veh_speed); From 6af49b7885f618202995fd28fef8c30646a9f8de Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Mon, 22 Feb 2021 13:50:32 +0000 Subject: [PATCH 3/3] Fix #8724: Got wrong DepotID/StationID for airports, causing crash --- src/depot_gui.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 4bc6762683..8c018b73d8 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -294,7 +294,7 @@ struct DepotWindow : Window { ~DepotWindow() { DeleteWindowById(WC_BUILD_VEHICLE, this->window_number); - DeleteWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, GetDepotIndex(this->window_number)).Pack(), false); + DeleteWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDepotIndex()).Pack(), false); OrderBackup::Reset(this->window_number); } @@ -424,10 +424,8 @@ struct DepotWindow : Window { { if (widget != WID_D_CAPTION) return; - /* locate the depot struct */ - TileIndex tile = this->window_number; SetDParam(0, this->type); - SetDParam(1, (this->type == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile)); + SetDParam(1, this->GetDepotIndex()); } struct GetDepotVehiclePtData { @@ -810,11 +808,8 @@ struct DepotWindow : Window { case WID_D_SELL_ALL: /* Only open the confirmation window if there are anything to sell */ if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) { - TileIndex tile = this->window_number; - byte vehtype = this->type; - - SetDParam(0, vehtype); - SetDParam(1, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile)); + SetDParam(0, this->type); + SetDParam(1, this->GetDepotIndex()); ShowQuery( STR_DEPOT_CAPTION, STR_DEPOT_SELL_CONFIRMATION_TEXT, @@ -840,7 +835,7 @@ struct DepotWindow : Window { if (str == nullptr) return; /* Do depot renaming */ - DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), nullptr, str); + DoCommandP(0, this->GetDepotIndex(), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), nullptr, str); } bool OnRightClick(Point pt, int widget) override @@ -1077,6 +1072,16 @@ struct DepotWindow : Window { return ES_NOT_HANDLED; } + + /** + * Gets the DepotID of the current window. + * In the case of airports, this is the station ID. + * @return Depot or station ID of this window. + */ + inline uint16 GetDepotIndex() const + { + return (this->type == VEH_AIRCRAFT) ? ::GetStationIndex(this->window_number) : ::GetDepotIndex(this->window_number); + } }; static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)