ai_rail.hpp

Go to the documentation of this file.
00001 /* $Id: ai_rail.hpp 21663 2010-12-29 23:20:12Z yexo $ */
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:
00025   static const char *GetClassName() { return "AIRail"; }
00026 
00030   enum ErrorMessages {
00032     ERR_RAIL_BASE = AIError::ERR_CAT_RAIL << AIError::ERR_CAT_BIT_SIZE,
00033 
00035     ERR_CROSSING_ON_ONEWAY_ROAD,       // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD]
00036 
00038     ERR_UNSUITABLE_TRACK,              // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK]
00039 
00041     ERR_NONUNIFORM_STATIONS_DISABLED,  // [STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED]
00042 
00044     ERR_RAILTYPE_DISALLOWS_CROSSING,   // [STR_ERROR_CROSSING_DISALLOWED]
00045   };
00046 
00050   enum RailType {
00051     /* Note: the values _are_ important as they represent an in-game value */
00052     RAILTYPE_INVALID  = 0xFF, 
00053   };
00054 
00058   enum RailTrack {
00059     /* Note: the values _are_ important as they represent an in-game value */
00060     RAILTRACK_NE_SW   = 1 << 0, 
00061     RAILTRACK_NW_SE   = 1 << 1, 
00062     RAILTRACK_NW_NE   = 1 << 2, 
00063     RAILTRACK_SW_SE   = 1 << 3, 
00064     RAILTRACK_NW_SW   = 1 << 4, 
00065     RAILTRACK_NE_SE   = 1 << 5, 
00066     RAILTRACK_INVALID = 0xFF,   
00067   };
00068 
00072   enum SignalType {
00073     /* Note: the values _are_ important as they represent an in-game value */
00074     SIGNALTYPE_NORMAL        = 0, 
00075     SIGNALTYPE_ENTRY         = 1, 
00076     SIGNALTYPE_EXIT          = 2, 
00077     SIGNALTYPE_COMBO         = 3, 
00078     SIGNALTYPE_PBS           = 4, 
00079     SIGNALTYPE_PBS_ONEWAY    = 5, 
00080     SIGNALTYPE_TWOWAY        = 8, 
00081     SIGNALTYPE_NORMAL_TWOWAY = SIGNALTYPE_NORMAL | SIGNALTYPE_TWOWAY, 
00082     SIGNALTYPE_ENTRY_TWOWAY  = SIGNALTYPE_ENTRY | SIGNALTYPE_TWOWAY,  
00083     SIGNALTYPE_EXIT_TWOWAY   = SIGNALTYPE_EXIT | SIGNALTYPE_TWOWAY,   
00084     SIGNALTYPE_COMBO_TWOWAY  = SIGNALTYPE_COMBO | SIGNALTYPE_TWOWAY,  
00085     SIGNALTYPE_NONE          = 0xFF, 
00086   };
00087 
00091   enum BuildType {
00092     BT_TRACK,    
00093     BT_SIGNAL,   
00094     BT_DEPOT,    
00095     BT_STATION,  
00096     BT_WAYPOINT, 
00097   };
00098 
00109   static char *GetName(RailType rail_type);
00110 
00119   static bool IsRailTile(TileIndex tile);
00120 
00126   static bool IsLevelCrossingTile(TileIndex tile);
00127 
00134   static bool IsRailDepotTile(TileIndex tile);
00135 
00142   static bool IsRailStationTile(TileIndex tile);
00143 
00150   static bool IsRailWaypointTile(TileIndex tile);
00151 
00157   static bool IsRailTypeAvailable(RailType rail_type);
00158 
00163   static RailType GetCurrentRailType();
00164 
00169   static void SetCurrentRailType(RailType rail_type);
00170 
00181   static bool TrainCanRunOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
00182 
00191   static bool TrainHasPowerOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type);
00192 
00199   static RailType GetRailType(TileIndex tile);
00200 
00212   static bool ConvertRailType(TileIndex start_tile, TileIndex end_tile, AIRail::RailType convert_to);
00213 
00220   static TileIndex GetRailDepotFrontTile(TileIndex depot);
00221 
00228   static RailTrack GetRailStationDirection(TileIndex tile);
00229 
00242   static bool BuildRailDepot(TileIndex tile, TileIndex front);
00243 
00265   static bool BuildRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id);
00266 
00297   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);
00298 
00309   static bool BuildRailWaypoint(TileIndex tile);
00310 
00320   static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
00321 
00331   static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
00332 
00340   static uint GetRailTracks(TileIndex tile);
00341 
00357   static bool BuildRailTrack(TileIndex tile, RailTrack rail_track);
00358 
00369   static bool RemoveRailTrack(TileIndex tile, RailTrack rail_track);
00370 
00381   static bool AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to);
00382 
00404   static bool BuildRail(TileIndex from, TileIndex tile, TileIndex to);
00405 
00420   static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to);
00421 
00429   static SignalType GetSignalType(TileIndex tile, TileIndex front);
00430 
00441   static bool BuildSignal(TileIndex tile, TileIndex front, SignalType signal);
00442 
00451   static bool RemoveSignal(TileIndex tile, TileIndex front);
00452 
00460   static Money GetBuildCost(RailType railtype, BuildType build_type);
00461 
00472   static int32 GetMaxSpeed(RailType railtype);
00473 };
00474 
00475 #endif /* AI_RAIL_HPP */

Generated on Thu Jan 20 22:57:31 2011 for OpenTTD by  doxygen 1.6.1