From 3b4c2c9daf93d8bcb271d11bd468a7dafd9229fa Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:41:57 +0000 Subject: [PATCH] Fix: [Script] Make ScriptOrder functions aware of road waypoints Updated GetOrderTypeByTile and GetOrderDestination to support road waypoints. --- src/script/api/script_order.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index 4f373bb26b..d90a72518d 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -34,7 +34,7 @@ static OrderType GetOrderTypeByTile(TileIndex t) switch (::GetTileType(t)) { default: break; case MP_STATION: - if (IsBuoy(t) || IsRailWaypoint(t)) return OT_GOTO_WAYPOINT; + if (IsBuoy(t) || IsRailWaypoint(t) || IsRoadWaypoint(t)) return OT_GOTO_WAYPOINT; if (IsHangar(t)) return OT_GOTO_DEPOT; return OT_GOTO_STATION; @@ -287,8 +287,12 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr for (TileIndex t : wp->train_station) { if (wp->TileBelongsToRailStation(t)) return t; } + } else if (wp->road_waypoint_area.tile != INVALID_TILE) { + for (TileIndex t : wp->road_waypoint_area) { + if (::IsRoadWaypointTile(t) && ::GetStationIndex(t) == wp->index) return t; + } } - /* If the waypoint has no rail waypoint tiles, it must have a buoy */ + /* If the waypoint has no rail or road waypoint tiles, it must have a buoy */ return wp->xy; } default: return INVALID_TILE;