ai_road.hpp

Go to the documentation of this file.
00001 /* $Id: ai_road.hpp 15494 2009-02-14 22:06:11Z yexo $ */
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 
00067   static bool IsRoadTile(TileIndex tile);
00068 
00075   static bool IsRoadDepotTile(TileIndex tile);
00076 
00083   static bool IsRoadStationTile(TileIndex tile);
00084 
00092   static bool IsDriveThroughRoadStationTile(TileIndex tile);
00093 
00099   static bool IsRoadTypeAvailable(RoadType road_type);
00100 
00105   static RoadType GetCurrentRoadType();
00106 
00111   static void SetCurrentRoadType(RoadType road_type);
00112 
00121   static bool HasRoadType(TileIndex tile, RoadType road_type);
00122 
00134   static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
00135 
00165   static int32 CanBuildConnectedRoadParts(AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
00166 
00186   static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
00187 
00194   static int32 GetNeighbourRoadCount(TileIndex tile);
00195 
00202   static TileIndex GetRoadDepotFrontTile(TileIndex depot);
00203 
00210   static TileIndex GetRoadStationFrontTile(TileIndex station);
00211 
00220   static TileIndex GetDriveThroughBackTile(TileIndex station);
00221 
00240   static bool BuildRoad(TileIndex start, TileIndex end);
00241 
00266   static bool BuildOneWayRoad(TileIndex start, TileIndex end);
00267 
00287   static bool BuildRoadFull(TileIndex start, TileIndex end);
00288 
00314   static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
00315 
00327   static bool BuildRoadDepot(TileIndex tile, TileIndex front);
00328 
00350   static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00351 
00373   static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00374 
00389   static bool RemoveRoad(TileIndex start, TileIndex end);
00390 
00406   static bool RemoveRoadFull(TileIndex start, TileIndex end);
00407 
00417   static bool RemoveRoadDepot(TileIndex tile);
00418 
00428   static bool RemoveRoadStation(TileIndex tile);
00429 
00430 private:
00431 
00435   static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
00436 
00440   static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
00441 };
00442 
00443 #endif /* AI_ROAD_HPP */

Generated on Mon Feb 16 23:12:05 2009 for openttd by  doxygen 1.5.6