ai_road.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AI_ROAD_HPP
00013 #define AI_ROAD_HPP
00014
00015 #include "ai_object.hpp"
00016 #include "ai_error.hpp"
00017 #include "ai_tile.hpp"
00018
00022 class AIRoad : public AIObject {
00023 public:
00024 static const char *GetClassName() { return "AIRoad"; }
00025
00029 enum ErrorMessages {
00031 ERR_ROAD_BASE = AIError::ERR_CAT_ROAD << AIError::ERR_CAT_BIT_SIZE,
00032
00034 ERR_ROAD_WORKS_IN_PROGRESS,
00035
00037 ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION,
00038
00040 ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD,
00041
00042
00044 ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS,
00045 };
00046
00050 enum RoadType {
00051
00052 ROADTYPE_ROAD = 0,
00053 ROADTYPE_TRAM = 1,
00054
00055 ROADTYPE_INVALID = -1,
00056 };
00057
00061 enum RoadVehicleType {
00062 ROADVEHTYPE_BUS,
00063 ROADVEHTYPE_TRUCK,
00064 };
00065
00072 static RoadVehicleType GetRoadVehicleTypeForCargo(CargoID cargo_type);
00073
00082 static bool IsRoadTile(TileIndex tile);
00083
00090 static bool IsRoadDepotTile(TileIndex tile);
00091
00098 static bool IsRoadStationTile(TileIndex tile);
00099
00107 static bool IsDriveThroughRoadStationTile(TileIndex tile);
00108
00114 static bool IsRoadTypeAvailable(RoadType road_type);
00115
00120 static RoadType GetCurrentRoadType();
00121
00126 static void SetCurrentRoadType(RoadType road_type);
00127
00136 static bool HasRoadType(TileIndex tile, RoadType road_type);
00137
00150 static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
00151
00181 static int32 CanBuildConnectedRoadParts(AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
00182
00202 static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
00203
00211 static int32 GetNeighbourRoadCount(TileIndex tile);
00212
00219 static TileIndex GetRoadDepotFrontTile(TileIndex depot);
00220
00227 static TileIndex GetRoadStationFrontTile(TileIndex station);
00228
00237 static TileIndex GetDriveThroughBackTile(TileIndex station);
00238
00258 static bool BuildRoad(TileIndex start, TileIndex end);
00259
00284 static bool BuildOneWayRoad(TileIndex start, TileIndex end);
00285
00306 static bool BuildRoadFull(TileIndex start, TileIndex end);
00307
00333 static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
00334
00347 static bool BuildRoadDepot(TileIndex tile, TileIndex front);
00348
00371 static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00372
00395 static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00396
00412 static bool RemoveRoad(TileIndex start, TileIndex end);
00413
00430 static bool RemoveRoadFull(TileIndex start, TileIndex end);
00431
00441 static bool RemoveRoadDepot(TileIndex tile);
00442
00452 static bool RemoveRoadStation(TileIndex tile);
00453
00454 private:
00455
00459 static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
00460
00464 static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
00465 };
00466
00467 #endif