diff options
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/api/ai_buoylist.cpp | 8 | ||||
-rw-r--r-- | src/ai/api/ai_order.cpp | 10 | ||||
-rw-r--r-- | src/ai/api/ai_rail.cpp | 5 | ||||
-rw-r--r-- | src/ai/api/ai_waypoint.cpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_waypointlist.cpp | 2 |
5 files changed, 11 insertions, 16 deletions
diff --git a/src/ai/api/ai_buoylist.cpp b/src/ai/api/ai_buoylist.cpp index 0ba66fb39..1412c7860 100644 --- a/src/ai/api/ai_buoylist.cpp +++ b/src/ai/api/ai_buoylist.cpp @@ -3,12 +3,12 @@ /** @file ai_buoylist.cpp Implementation of AIBuoyList and friends. */ #include "ai_buoylist.hpp" -#include "../../station_base.h" +#include "../../waypoint.h" AIBuoyList::AIBuoyList() { - Station *st; - FOR_ALL_STATIONS(st) { - if (st->IsBuoy()) this->AddItem(st->xy); + Waypoint *wp; + FOR_ALL_WAYPOINTS(wp) { + if (wp->facilities & FACIL_DOCK) this->AddItem(wp->xy); } } diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp index 7cd791562..5069bcb5e 100644 --- a/src/ai/api/ai_order.cpp +++ b/src/ai/api/ai_order.cpp @@ -25,18 +25,14 @@ static OrderType GetOrderTypeByTile(TileIndex t) switch (::GetTileType(t)) { default: break; case MP_STATION: + if (IsBuoy(t) || IsRailWaypoint(t)) return OT_GOTO_WAYPOINT; if (IsHangar(t)) return OT_GOTO_DEPOT; - if (IsBuoy(t)) return OT_GOTO_WAYPOINT; return OT_GOTO_STATION; break; case MP_WATER: if (::IsShipDepot(t)) return OT_GOTO_DEPOT; break; case MP_ROAD: if (::GetRoadTileType(t) == ROAD_TILE_DEPOT) return OT_GOTO_DEPOT; break; case MP_RAILWAY: - switch (::GetRailTileType(t)) { - case RAIL_TILE_DEPOT: return OT_GOTO_DEPOT; - case RAIL_TILE_WAYPOINT: return OT_GOTO_WAYPOINT; - default: break; - } + if (IsRailDepot(t)) return OT_GOTO_DEPOT; break; } @@ -359,7 +355,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or break; case OT_GOTO_WAYPOINT: - order.MakeGoToWaypoint(::Vehicle::Get(vehicle_id)->type == VEH_TRAIN ? ::GetWaypointIndex(destination) : ::GetStationIndex(destination)); + order.MakeGoToWaypoint(::GetStationIndex(destination)); break; default: diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp index 5986ad82b..7e686aac9 100644 --- a/src/ai/api/ai_rail.cpp +++ b/src/ai/api/ai_rail.cpp @@ -45,7 +45,7 @@ { if (!::IsValidTile(tile)) return false; - return ::IsTileType(tile, MP_RAILWAY) && ::IsRailWaypointTile(tile); + return ::IsRailWaypointTile(tile); } /* static */ bool AIRail::IsRailTypeAvailable(RailType rail_type) @@ -200,8 +200,7 @@ { if (!IsRailTile(tile)) return RAILTRACK_INVALID; - if (IsRailWaypointTile(tile)) return ::GetRailWaypointBits(tile); - if (IsRailStationTile(tile)) return ::TrackToTrackBits(::GetRailStationTrack(tile)); + if (IsRailStationTile(tile) || IsRailWaypointTile(tile)) return ::TrackToTrackBits(::GetRailStationTrack(tile)); if (IsLevelCrossingTile(tile)) return ::GetCrossingRailBits(tile); if (IsRailDepotTile(tile)) return ::TRACK_BIT_NONE; return ::GetTrackBits(tile); diff --git a/src/ai/api/ai_waypoint.cpp b/src/ai/api/ai_waypoint.cpp index 21804dda7..d7d3b396a 100644 --- a/src/ai/api/ai_waypoint.cpp +++ b/src/ai/api/ai_waypoint.cpp @@ -22,7 +22,7 @@ { if (!AIRail::IsRailWaypointTile(tile)) return WAYPOINT_INVALID; - return ::GetWaypointIndex(tile); + return ::GetStationIndex(tile); } /* static */ char *AIWaypoint::GetName(WaypointID waypoint_id) diff --git a/src/ai/api/ai_waypointlist.cpp b/src/ai/api/ai_waypointlist.cpp index c2d87e6b7..20bc58544 100644 --- a/src/ai/api/ai_waypointlist.cpp +++ b/src/ai/api/ai_waypointlist.cpp @@ -13,7 +13,7 @@ AIWaypointList::AIWaypointList() { const Waypoint *wp; FOR_ALL_WAYPOINTS(wp) { - if (wp->owner == _current_company) this->AddItem(wp->index); + if (wp->facilities & FACIL_TRAIN && wp->owner == _current_company) this->AddItem(wp->index); } } |