# ai_road.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_road.hpp 15904 2009-03-30 23:22:13Z 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
    00142   static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
    00143
    00173   static int32 CanBuildConnectedRoadParts(AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
    00174
    00194   static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
    00195
    00202   static int32 GetNeighbourRoadCount(TileIndex tile);
    00203
    00210   static TileIndex GetRoadDepotFrontTile(TileIndex depot);
    00211
    00218   static TileIndex GetRoadStationFrontTile(TileIndex station);
    00219
    00228   static TileIndex GetDriveThroughBackTile(TileIndex station);
    00229
    00248   static bool BuildRoad(TileIndex start, TileIndex end);
    00249
    00274   static bool BuildOneWayRoad(TileIndex start, TileIndex end);
    00275
    00295   static bool BuildRoadFull(TileIndex start, TileIndex end);
    00296
    00322   static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
    00323
    00335   static bool BuildRoadDepot(TileIndex tile, TileIndex front);
    00336
    00358   static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
    00359
    00381   static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
    00382
    00397   static bool RemoveRoad(TileIndex start, TileIndex end);
    00398
    00414   static bool RemoveRoadFull(TileIndex start, TileIndex end);
    00415
    00425   static bool RemoveRoadDepot(TileIndex tile);
    00426
    00436   static bool RemoveRoadStation(TileIndex tile);
    00437
    00438 private:
    00439
    00443   static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
    00444
    00448   static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
    00449 };
    00450
    00451 #endif /* AI_ROAD_HPP */