# ai_rail.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_rail.hpp 16324 2009-05-16 20:29:53Z rubidium $ */
    00002
    00005 #ifndef AI_RAIL_HPP
    00006 #define AI_RAIL_HPP
    00007
    00008 #include "ai_object.hpp"
    00009 #include "ai_error.hpp"
    00010 #include "ai_tile.hpp"
    00011
    00015 class AIRail : public AIObject {
    00016 public:
    00017   static const char *GetClassName() { return "AIRail"; }
    00018
    00022   enum ErrorMessages {
    00024     ERR_RAIL_BASE = AIError::ERR_CAT_RAIL << AIError::ERR_CAT_BIT_SIZE,
    00025
    00027     ERR_CROSSING_ON_ONEWAY_ROAD,       // [STR_ERR_CROSSING_ON_ONEWAY_ROAD]
    00028
    00030     ERR_UNSUITABLE_TRACK,              // [STR_1005_NO_SUITABLE_RAILROAD_TRACK]
    00031
    00033     ERR_NONUNIFORM_STATIONS_DISABLED,  // [STR_NONUNIFORM_STATIONS_DISALLOWED]
    00034   };
    00035
    00039   enum RailType {
    00040     /* Note: the values _are_ important as they represent an in-game value */
    00041     RAILTYPE_INVALID  = 0xFF,
    00042   };
    00043
    00047   enum RailTrack {
    00048     /* Note: the values _are_ important as they represent an in-game value */
    00049     RAILTRACK_NE_SW   = 1 << 0,
    00050     RAILTRACK_NW_SE   = 1 << 1,
    00051     RAILTRACK_NW_NE   = 1 << 2,
    00052     RAILTRACK_SW_SE   = 1 << 3,
    00053     RAILTRACK_NW_SW   = 1 << 4,
    00054     RAILTRACK_NE_SE   = 1 << 5,
    00055     RAILTRACK_INVALID = 0xFF,
    00056   };
    00057
    00061   enum SignalType {
    00062     /* Note: the values _are_ important as they represent an in-game value */
    00063     SIGNALTYPE_NORMAL        = 0,
    00064     SIGNALTYPE_ENTRY         = 1,
    00065     SIGNALTYPE_EXIT          = 2,
    00066     SIGNALTYPE_COMBO         = 3,
    00067     SIGNALTYPE_PBS           = 4,
    00068     SIGNALTYPE_PBS_ONEWAY    = 5,
    00069     SIGNALTYPE_TWOWAY        = 8,
    00070     SIGNALTYPE_NORMAL_TWOWAY = SIGNALTYPE_NORMAL | SIGNALTYPE_TWOWAY,
    00071     SIGNALTYPE_ENTRY_TWOWAY  = SIGNALTYPE_ENTRY | SIGNALTYPE_TWOWAY,
    00072     SIGNALTYPE_EXIT_TWOWAY   = SIGNALTYPE_EXIT | SIGNALTYPE_TWOWAY,
    00073     SIGNALTYPE_COMBO_TWOWAY  = SIGNALTYPE_COMBO | SIGNALTYPE_TWOWAY,
    00074     SIGNALTYPE_NONE          = 0xFF,
    00075   };
    00076
    00085   static bool IsRailTile(TileIndex tile);
    00086
    00092   static bool IsLevelCrossingTile(TileIndex tile);
    00093
    00100   static bool IsRailDepotTile(TileIndex tile);
    00101
    00108   static bool IsRailStationTile(TileIndex tile);
    00109
    00116   static bool IsRailWaypointTile(TileIndex tile);
    00117
    00123   static bool IsRailTypeAvailable(RailType rail_type);
    00124
    00129   static RailType GetCurrentRailType();
    00130
    00135   static void SetCurrentRailType(RailType rail_type);
    00136
    00147   static bool TrainCanRunOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
    00148
    00157   static bool TrainHasPowerOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
    00158
    00165   static RailType GetRailType(TileIndex tile);
    00166
    00178   static bool ConvertRailType(TileIndex start_tile, TileIndex end_tile, AIRail::RailType convert_to);
    00179
    00186   static TileIndex GetRailDepotFrontTile(TileIndex depot);
    00187
    00194   static RailTrack GetRailStationDirection(TileIndex tile);
    00195
    00208   static bool BuildRailDepot(TileIndex tile, TileIndex front);
    00209
    00231   static bool BuildRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id);
    00232
    00261   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);
    00262
    00273   static bool BuildRailWaypoint(TileIndex tile);
    00274
    00282   static bool RemoveRailWaypoint(TileIndex tile);
    00283
    00292   static bool RemoveRailStationTileRect(TileIndex tile, TileIndex tile2);
    00293
    00301   static uint GetRailTracks(TileIndex tile);
    00302
    00318   static bool BuildRailTrack(TileIndex tile, RailTrack rail_track);
    00319
    00330   static bool RemoveRailTrack(TileIndex tile, RailTrack rail_track);
    00331
    00342   static bool AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to);
    00343
    00364   static bool BuildRail(TileIndex from, TileIndex tile, TileIndex to);
    00365
    00380   static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to);
    00381
    00389   static SignalType GetSignalType(TileIndex tile, TileIndex front);
    00390
    00401   static bool BuildSignal(TileIndex tile, TileIndex front, SignalType signal);
    00402
    00411   static bool RemoveSignal(TileIndex tile, TileIndex front);
    00412 };
    00413
    00414 #endif /* AI_RAIL_HPP */