ai_road.hpp

Go to the documentation of this file.
00001 /* $Id: ai_road.hpp 20288 2010-08-01 20:41:46Z yexo $ */
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:
00025   static const char *GetClassName() { return "AIRoad"; }
00026 
00030   enum ErrorMessages {
00032     ERR_ROAD_BASE = AIError::ERR_CAT_ROAD << AIError::ERR_CAT_BIT_SIZE,
00033 
00035     ERR_ROAD_WORKS_IN_PROGRESS,                   // [STR_ERROR_ROAD_WORKS_IN_PROGRESS]
00036 
00038     ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION,       // [STR_ERROR_DRIVE_THROUGH_DIRECTION]
00039 
00041     ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD,           // [STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD]
00042 
00043 
00045     ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, // [STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION]
00046   };
00047 
00051   enum RoadType {
00052     /* Values are important, as they represent the internal state of the game. */
00053     ROADTYPE_ROAD = 0, 
00054     ROADTYPE_TRAM = 1, 
00055 
00056     ROADTYPE_INVALID = -1, 
00057   };
00058 
00062   enum RoadVehicleType {
00063     ROADVEHTYPE_BUS,   
00064     ROADVEHTYPE_TRUCK, 
00065   };
00066 
00070   enum BuildType {
00071     BT_ROAD,       
00072     BT_DEPOT,      
00073     BT_BUS_STOP,   
00074     BT_TRUCK_STOP, 
00075   };
00076 
00083   static RoadVehicleType GetRoadVehicleTypeForCargo(CargoID cargo_type);
00084 
00093   static bool IsRoadTile(TileIndex tile);
00094 
00101   static bool IsRoadDepotTile(TileIndex tile);
00102 
00109   static bool IsRoadStationTile(TileIndex tile);
00110 
00118   static bool IsDriveThroughRoadStationTile(TileIndex tile);
00119 
00125   static bool IsRoadTypeAvailable(RoadType road_type);
00126 
00131   static RoadType GetCurrentRoadType();
00132 
00137   static void SetCurrentRoadType(RoadType road_type);
00138 
00147   static bool HasRoadType(TileIndex tile, RoadType road_type);
00148 
00161   static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
00162 
00192   static int32 CanBuildConnectedRoadParts(AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
00193 
00213   static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
00214 
00222   static int32 GetNeighbourRoadCount(TileIndex tile);
00223 
00230   static TileIndex GetRoadDepotFrontTile(TileIndex depot);
00231 
00238   static TileIndex GetRoadStationFrontTile(TileIndex station);
00239 
00248   static TileIndex GetDriveThroughBackTile(TileIndex station);
00249 
00270   static bool BuildRoad(TileIndex start, TileIndex end);
00271 
00297   static bool BuildOneWayRoad(TileIndex start, TileIndex end);
00298 
00320   static bool BuildRoadFull(TileIndex start, TileIndex end);
00321 
00348   static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
00349 
00362   static bool BuildRoadDepot(TileIndex tile, TileIndex front);
00363 
00386   static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00387 
00410   static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00411 
00427   static bool RemoveRoad(TileIndex start, TileIndex end);
00428 
00445   static bool RemoveRoadFull(TileIndex start, TileIndex end);
00446 
00456   static bool RemoveRoadDepot(TileIndex tile);
00457 
00467   static bool RemoveRoadStation(TileIndex tile);
00468 
00476   static Money GetBuildCost(RoadType roadtype, BuildType build_type);
00477 
00478 private:
00479 
00483   static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
00484 
00488   static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
00489 };
00490 
00491 #endif /* AI_ROAD_HPP */

Generated on Sun Jan 9 16:01:51 2011 for OpenTTD by  doxygen 1.6.1