ai_road.hpp

Go to the documentation of this file.
00001 /* $Id: ai_road.hpp 18986 2010-02-02 21:25:01Z terkhen $ */
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 
00069   enum BuildType {
00070     BT_ROAD,       
00071     BT_DEPOT,      
00072     BT_BUS_STOP,   
00073     BT_TRUCK_STOP, 
00074   };
00075 
00082   static RoadVehicleType GetRoadVehicleTypeForCargo(CargoID cargo_type);
00083 
00092   static bool IsRoadTile(TileIndex tile);
00093 
00100   static bool IsRoadDepotTile(TileIndex tile);
00101 
00108   static bool IsRoadStationTile(TileIndex tile);
00109 
00117   static bool IsDriveThroughRoadStationTile(TileIndex tile);
00118 
00124   static bool IsRoadTypeAvailable(RoadType road_type);
00125 
00130   static RoadType GetCurrentRoadType();
00131 
00136   static void SetCurrentRoadType(RoadType road_type);
00137 
00146   static bool HasRoadType(TileIndex tile, RoadType road_type);
00147 
00160   static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
00161 
00191   static int32 CanBuildConnectedRoadParts(AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
00192 
00212   static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
00213 
00221   static int32 GetNeighbourRoadCount(TileIndex tile);
00222 
00229   static TileIndex GetRoadDepotFrontTile(TileIndex depot);
00230 
00237   static TileIndex GetRoadStationFrontTile(TileIndex station);
00238 
00247   static TileIndex GetDriveThroughBackTile(TileIndex station);
00248 
00269   static bool BuildRoad(TileIndex start, TileIndex end);
00270 
00296   static bool BuildOneWayRoad(TileIndex start, TileIndex end);
00297 
00319   static bool BuildRoadFull(TileIndex start, TileIndex end);
00320 
00347   static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
00348 
00361   static bool BuildRoadDepot(TileIndex tile, TileIndex front);
00362 
00385   static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00386 
00409   static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
00410 
00426   static bool RemoveRoad(TileIndex start, TileIndex end);
00427 
00444   static bool RemoveRoadFull(TileIndex start, TileIndex end);
00445 
00455   static bool RemoveRoadDepot(TileIndex tile);
00456 
00466   static bool RemoveRoadStation(TileIndex tile);
00467 
00475   static Money GetBuildCost(RoadType roadtype, BuildType build_type);
00476 
00477 private:
00478 
00482   static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
00483 
00487   static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
00488 };
00489 
00490 #endif /* AI_ROAD_HPP */

Generated on Thu Feb 4 17:20:22 2010 for OpenTTD by  doxygen 1.5.6