ai_road.hpp

Go to the documentation of this file.
00001 /* $Id: ai_road.hpp 17248 2009-08-21 20:21:05Z rubidium $ */
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_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,                   // [STR_ERROR_ROAD_WORKS_IN_PROGRESS]
00035 
00037     ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION,       // [STR_ERROR_DRIVE_THROUGH_DIRECTION]
00038 
00040     ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD,           // [STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD]
00041 
00042 
00044     ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, // [STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION]
00045   };
00046 
00050   enum RoadType {
00051     /* Values are important, as they represent the internal state of the game. */
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 /* AI_ROAD_HPP */

Generated on Wed Dec 23 23:27:48 2009 for OpenTTD by  doxygen 1.5.6