ai_road.hpp

Go to the documentation of this file.
00001 /* $Id: ai_road.hpp 17235 2009-08-20 12:22:31Z rubidium $ */
00002 
00005 #ifndef AI_ROAD_HPP
00006 #define AI_ROAD_HPP
00007 
00008 #include "ai_object.hpp"
00009 #include "ai_error.hpp"
00010 #include "ai_tile.hpp"
00011 
00015 class AIRoad : public AIObject {
00016 public:
00017   static const char *GetClassName() { return "AIRoad"; }
00018 
00022   enum ErrorMessages {
00024     ERR_ROAD_BASE = AIError::ERR_CAT_ROAD << AIError::ERR_CAT_BIT_SIZE,
00025 
00027     ERR_ROAD_WORKS_IN_PROGRESS,                   // [STR_ROAD_WORKS_IN_PROGRESS]
00028 
00030     ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION,       // [STR_DRIVE_THROUGH_ERROR_DIRECTION]
00031 
00033     ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD,           // [STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD]
00034 
00035 
00037     ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, // [STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION]
00038   };
00039 
00043   enum RoadType {
00044     /* Values are important, as they represent the internal state of the game. */
00045     ROADTYPE_ROAD = 0, 
00046     ROADTYPE_TRAM = 1, 
00047 
00048     ROADTYPE_INVALID = -1, 
00049   };
00050 
00054   enum RoadVehicleType {
00055     ROADVEHTYPE_BUS,   
00056     ROADVEHTYPE_TRUCK, 
00057   };
00058 
00065   static RoadVehicleType GetRoadVehicleTypeForCargo(CargoID cargo_type);
00066 
00075   static bool IsRoadTile(TileIndex tile);
00076 
00083   static bool IsRoadDepotTile(TileIndex tile);
00084 
00091   static bool IsRoadStationTile(TileIndex tile);
00092 
00100   static bool IsDriveThroughRoadStationTile(TileIndex tile);
00101 
00107   static bool IsRoadTypeAvailable(RoadType road_type);
00108 
00113   static RoadType GetCurrentRoadType();
00114 
00119   static void SetCurrentRoadType(RoadType road_type);
00120 
00129   static bool HasRoadType(TileIndex tile, RoadType road_type);
00130 
00143   static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
00144 
00174   static int32 CanBuildConnectedRoadParts(AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
00175 
00195   static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
00196 
00204   static int32 GetNeighbourRoadCount(TileIndex tile);
00205 
00212   static TileIndex GetRoadDepotFrontTile(TileIndex depot);
00213 
00220   static TileIndex GetRoadStationFrontTile(TileIndex station);
00221 
00230   static TileIndex GetDriveThroughBackTile(TileIndex station);
00231 
00251   static bool BuildRoad(TileIndex start, TileIndex end);
00252 
00277   static bool BuildOneWayRoad(TileIndex start, TileIndex end);
00278 
00299   static bool BuildRoadFull(TileIndex start, TileIndex end);
00300 
00326   static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
00327 
00340   static bool BuildRoadDepot(TileIndex tile, TileIndex front);
00341 
00364   static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00365 
00388   static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00389 
00405   static bool RemoveRoad(TileIndex start, TileIndex end);
00406 
00423   static bool RemoveRoadFull(TileIndex start, TileIndex end);
00424 
00434   static bool RemoveRoadDepot(TileIndex tile);
00435 
00445   static bool RemoveRoadStation(TileIndex tile);
00446 
00447 private:
00448 
00452   static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
00453 
00457   static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
00458 };
00459 
00460 #endif /* AI_ROAD_HPP */

Generated on Sun Sep 13 08:19:14 2009 for OpenTTD by  doxygen 1.5.6