summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-22 08:59:57 +0000
committerrubidium <rubidium@openttd.org>2009-07-22 08:59:57 +0000
commit68ead6b84f56ad3c93d05ad3e09b7fbb8173cf26 (patch)
treeee33bd19b96a138530a84e86e7ffd60c0700f9d9 /src/ai
parent2646a99d29535a44c5998f080131cbca2e85bdcf (diff)
downloadopenttd-68ead6b84f56ad3c93d05ad3e09b7fbb8173cf26.tar.xz
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
-Change: make (rail) waypoints sub classes of 'base stations', make buoys waypoints and unify code between them where possible.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_buoylist.cpp8
-rw-r--r--src/ai/api/ai_order.cpp10
-rw-r--r--src/ai/api/ai_rail.cpp5
-rw-r--r--src/ai/api/ai_waypoint.cpp2
-rw-r--r--src/ai/api/ai_waypointlist.cpp2
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);
}
}