00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AI_RAIL_HPP
00013 #define AI_RAIL_HPP
00014
00015 #include "ai_tile.hpp"
00016
00020 class AIRail : public AIObject {
00021 public:
00023 static const char *GetClassName() { return "AIRail"; }
00024
00028 enum ErrorMessages {
00030 ERR_RAIL_BASE = AIError::ERR_CAT_RAIL << AIError::ERR_CAT_BIT_SIZE,
00031
00033 ERR_CROSSING_ON_ONEWAY_ROAD,
00034
00036 ERR_UNSUITABLE_TRACK,
00037
00039 ERR_NONUNIFORM_STATIONS_DISABLED,
00040
00042 ERR_RAILTYPE_DISALLOWS_CROSSING,
00043 };
00044
00048 enum RailType {
00049
00050 RAILTYPE_INVALID = 0xFF,
00051 };
00052
00056 enum RailTrack {
00057
00058 RAILTRACK_NE_SW = 1 << 0,
00059 RAILTRACK_NW_SE = 1 << 1,
00060 RAILTRACK_NW_NE = 1 << 2,
00061 RAILTRACK_SW_SE = 1 << 3,
00062 RAILTRACK_NW_SW = 1 << 4,
00063 RAILTRACK_NE_SE = 1 << 5,
00064 RAILTRACK_INVALID = 0xFF,
00065 };
00066
00070 enum SignalType {
00071
00072 SIGNALTYPE_NORMAL = 0,
00073 SIGNALTYPE_ENTRY = 1,
00074 SIGNALTYPE_EXIT = 2,
00075 SIGNALTYPE_COMBO = 3,
00076 SIGNALTYPE_PBS = 4,
00077 SIGNALTYPE_PBS_ONEWAY = 5,
00078 SIGNALTYPE_TWOWAY = 8,
00079 SIGNALTYPE_NORMAL_TWOWAY = SIGNALTYPE_NORMAL | SIGNALTYPE_TWOWAY,
00080 SIGNALTYPE_ENTRY_TWOWAY = SIGNALTYPE_ENTRY | SIGNALTYPE_TWOWAY,
00081 SIGNALTYPE_EXIT_TWOWAY = SIGNALTYPE_EXIT | SIGNALTYPE_TWOWAY,
00082 SIGNALTYPE_COMBO_TWOWAY = SIGNALTYPE_COMBO | SIGNALTYPE_TWOWAY,
00083 SIGNALTYPE_NONE = 0xFF,
00084 };
00085
00089 enum BuildType {
00090 BT_TRACK,
00091 BT_SIGNAL,
00092 BT_DEPOT,
00093 BT_STATION,
00094 BT_WAYPOINT,
00095 };
00096
00107 static char *GetName(RailType rail_type);
00108
00117 static bool IsRailTile(TileIndex tile);
00118
00124 static bool IsLevelCrossingTile(TileIndex tile);
00125
00132 static bool IsRailDepotTile(TileIndex tile);
00133
00140 static bool IsRailStationTile(TileIndex tile);
00141
00148 static bool IsRailWaypointTile(TileIndex tile);
00149
00155 static bool IsRailTypeAvailable(RailType rail_type);
00156
00161 static RailType GetCurrentRailType();
00162
00167 static void SetCurrentRailType(RailType rail_type);
00168
00179 static bool TrainCanRunOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
00180
00189 static bool TrainHasPowerOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
00190
00197 static RailType GetRailType(TileIndex tile);
00198
00210 static bool ConvertRailType(TileIndex start_tile, TileIndex end_tile, AIRail::RailType convert_to);
00211
00218 static TileIndex GetRailDepotFrontTile(TileIndex depot);
00219
00226 static RailTrack GetRailStationDirection(TileIndex tile);
00227
00240 static bool BuildRailDepot(TileIndex tile, TileIndex front);
00241
00263 static bool BuildRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id);
00264
00295 static bool BuildNewGRFRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, int distance, bool source_station);
00296
00307 static bool BuildRailWaypoint(TileIndex tile);
00308
00318 static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
00319
00329 static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
00330
00338 static uint GetRailTracks(TileIndex tile);
00339
00355 static bool BuildRailTrack(TileIndex tile, RailTrack rail_track);
00356
00367 static bool RemoveRailTrack(TileIndex tile, RailTrack rail_track);
00368
00379 static bool AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to);
00380
00402 static bool BuildRail(TileIndex from, TileIndex tile, TileIndex to);
00403
00418 static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to);
00419
00427 static SignalType GetSignalType(TileIndex tile, TileIndex front);
00428
00439 static bool BuildSignal(TileIndex tile, TileIndex front, SignalType signal);
00440
00449 static bool RemoveSignal(TileIndex tile, TileIndex front);
00450
00458 static Money GetBuildCost(RailType railtype, BuildType build_type);
00459
00470 static int32 GetMaxSpeed(RailType railtype);
00471 };
00472
00473 #endif