ai_rail.hpp

Go to the documentation of this file.
00001 /* $Id: ai_rail.hpp 17471 2009-09-08 10:12:13Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef AI_RAIL_HPP
00013 #define AI_RAIL_HPP
00014 
00015 #include "ai_object.hpp"
00016 #include "ai_error.hpp"
00017 #include "ai_tile.hpp"
00018 
00022 class AIRail : public AIObject {
00023 public:
00024   static const char *GetClassName() { return "AIRail"; }
00025 
00029   enum ErrorMessages {
00031     ERR_RAIL_BASE = AIError::ERR_CAT_RAIL << AIError::ERR_CAT_BIT_SIZE,
00032 
00034     ERR_CROSSING_ON_ONEWAY_ROAD,       // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD]
00035 
00037     ERR_UNSUITABLE_TRACK,              // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK]
00038 
00040     ERR_NONUNIFORM_STATIONS_DISABLED,  // [STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED]
00041   };
00042 
00046   enum RailType {
00047     /* Note: the values _are_ important as they represent an in-game value */
00048     RAILTYPE_INVALID  = 0xFF, 
00049   };
00050 
00054   enum RailTrack {
00055     /* Note: the values _are_ important as they represent an in-game value */
00056     RAILTRACK_NE_SW   = 1 << 0, 
00057     RAILTRACK_NW_SE   = 1 << 1, 
00058     RAILTRACK_NW_NE   = 1 << 2, 
00059     RAILTRACK_SW_SE   = 1 << 3, 
00060     RAILTRACK_NW_SW   = 1 << 4, 
00061     RAILTRACK_NE_SE   = 1 << 5, 
00062     RAILTRACK_INVALID = 0xFF,   
00063   };
00064 
00068   enum SignalType {
00069     /* Note: the values _are_ important as they represent an in-game value */
00070     SIGNALTYPE_NORMAL        = 0, 
00071     SIGNALTYPE_ENTRY         = 1, 
00072     SIGNALTYPE_EXIT          = 2, 
00073     SIGNALTYPE_COMBO         = 3, 
00074     SIGNALTYPE_PBS           = 4, 
00075     SIGNALTYPE_PBS_ONEWAY    = 5, 
00076     SIGNALTYPE_TWOWAY        = 8, 
00077     SIGNALTYPE_NORMAL_TWOWAY = SIGNALTYPE_NORMAL | SIGNALTYPE_TWOWAY, 
00078     SIGNALTYPE_ENTRY_TWOWAY  = SIGNALTYPE_ENTRY | SIGNALTYPE_TWOWAY,  
00079     SIGNALTYPE_EXIT_TWOWAY   = SIGNALTYPE_EXIT | SIGNALTYPE_TWOWAY,   
00080     SIGNALTYPE_COMBO_TWOWAY  = SIGNALTYPE_COMBO | SIGNALTYPE_TWOWAY,  
00081     SIGNALTYPE_NONE          = 0xFF, 
00082   };
00083 
00092   static bool IsRailTile(TileIndex tile);
00093 
00099   static bool IsLevelCrossingTile(TileIndex tile);
00100 
00107   static bool IsRailDepotTile(TileIndex tile);
00108 
00115   static bool IsRailStationTile(TileIndex tile);
00116 
00123   static bool IsRailWaypointTile(TileIndex tile);
00124 
00130   static bool IsRailTypeAvailable(RailType rail_type);
00131 
00136   static RailType GetCurrentRailType();
00137 
00142   static void SetCurrentRailType(RailType rail_type);
00143 
00154   static bool TrainCanRunOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
00155 
00164   static bool TrainHasPowerOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
00165 
00172   static RailType GetRailType(TileIndex tile);
00173 
00185   static bool ConvertRailType(TileIndex start_tile, TileIndex end_tile, AIRail::RailType convert_to);
00186 
00193   static TileIndex GetRailDepotFrontTile(TileIndex depot);
00194 
00201   static RailTrack GetRailStationDirection(TileIndex tile);
00202 
00215   static bool BuildRailDepot(TileIndex tile, TileIndex front);
00216 
00238   static bool BuildRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id);
00239 
00268   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);
00269 
00280   static bool BuildRailWaypoint(TileIndex tile);
00281 
00291   static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
00292 
00302   static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
00303 
00311   static uint GetRailTracks(TileIndex tile);
00312 
00328   static bool BuildRailTrack(TileIndex tile, RailTrack rail_track);
00329 
00340   static bool RemoveRailTrack(TileIndex tile, RailTrack rail_track);
00341 
00352   static bool AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to);
00353 
00374   static bool BuildRail(TileIndex from, TileIndex tile, TileIndex to);
00375 
00390   static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to);
00391 
00399   static SignalType GetSignalType(TileIndex tile, TileIndex front);
00400 
00411   static bool BuildSignal(TileIndex tile, TileIndex front, SignalType signal);
00412 
00421   static bool RemoveSignal(TileIndex tile, TileIndex front);
00422 };
00423 
00424 #endif /* AI_RAIL_HPP */

Generated on Wed Dec 23 23:27:48 2009 for OpenTTD by  doxygen 1.5.6