(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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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:
|
||||
|
@@ -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);
|
||||
|
@@ -22,7 +22,7 @@
|
||||
{
|
||||
if (!AIRail::IsRailWaypointTile(tile)) return WAYPOINT_INVALID;
|
||||
|
||||
return ::GetWaypointIndex(tile);
|
||||
return ::GetStationIndex(tile);
|
||||
}
|
||||
|
||||
/* static */ char *AIWaypoint::GetName(WaypointID waypoint_id)
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user