src/ai/api/ai_bridge.hpp
branchnoai
changeset 9867 b7d9ffe24f81
parent 9838 0839682a601b
child 9870 875cae2f4696
equal deleted inserted replaced
9866:efc38e1f559a 9867:b7d9ffe24f81
     5 #ifndef AI_BRIDGE_HPP
     5 #ifndef AI_BRIDGE_HPP
     6 #define AI_BRIDGE_HPP
     6 #define AI_BRIDGE_HPP
     7 
     7 
     8 #include "ai_object.hpp"
     8 #include "ai_object.hpp"
     9 #include "ai_vehicle.hpp"
     9 #include "ai_vehicle.hpp"
       
    10 #include "ai_error.hpp"
    10 #include "../../bridge.h"
    11 #include "../../bridge.h"
    11 
    12 
    12 /** In OpenTTD Core 'BridgeID' is called 'BridgeType', so map it to make this API more logic. */
    13 /** In OpenTTD Core 'BridgeID' is called 'BridgeType', so map it to make this API more logic. */
    13 typedef BridgeType BridgeID;
    14 typedef BridgeType BridgeID;
    14 
    15 
    15 /**
    16 /**
    16  * Class that handles all bridge related functions.
    17  * Class that handles all bridge related functions.
    17  */
    18  */
    18 class AIBridge : public AIObject {
    19 class AIBridge : public AIObject {
    19 public:
    20 public:
       
    21 	enum ErrorMessages {
       
    22 		/** Base for bridge related errors */
       
    23 		ERR_BRIDGE_BASE = AIError::ERR_CAT_BRIDGE << AIError::ERR_CAT_BIT_SIZE,
       
    24 
       
    25 		/**
       
    26 		 * The bridge you want to build is not available yet,
       
    27 		 * or it is not available for the requested length.
       
    28 		 */
       
    29 		ERR_BRIDGE_TYPE_UNAVAILABLE,         // [STR_5015_CAN_T_BUILD_BRIDGE_HERE]
       
    30 
       
    31 		/** One (or more) of the bridge head(s) ends in water. */
       
    32 		ERR_BRIDGE_CANNOT_END_IN_WATER,      // [STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH]
       
    33 
       
    34 		/** Slope of the land does not allow the required bridge head. */
       
    35 		ERR_BRIDGE_SLOPE_WRONG,              // [STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION]
       
    36 
       
    37 		/** The bride heads need to be on the same height */
       
    38 		ERR_BRIDGE_HEADS_NOT_ON_SAME_HEIGHT, // [STR_BRIDGEHEADS_NOT_SAME_HEIGHT]
       
    39 	};
       
    40 
    20 	static const char *GetClassName() { return "AIBridge"; }
    41 	static const char *GetClassName() { return "AIBridge"; }
    21 
    42 
    22 	/**
    43 	/**
    23 	 * Checks whether the given bridge type is valid.
    44 	 * Checks whether the given bridge type is valid.
    24 	 * @param bridge_id The bridge to check.
    45 	 * @param bridge_id The bridge to check.
    94 	 * @pre AIMap::IsValidTile(end).
   115 	 * @pre AIMap::IsValidTile(end).
    95 	 * @pre 'start' and 'end' are in a straight line, i.e.
   116 	 * @pre 'start' and 'end' are in a straight line, i.e.
    96 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   117 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
    97 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   118 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
    98 	 * @pre 'vehicle_type' is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD.
   119 	 * @pre 'vehicle_type' is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD.
       
   120 	 * @exception AIError::ERR_ALREADY_BUILT
       
   121 	 * @exception AIError::ERR_AREA_NOT_CLEAR
       
   122 	 * @exception AIBridge::ERR_BRIDGE_TYPE_UNAVAILABLE
       
   123 	 * @exception AIBridge::ERR_BRIDGE_CANNOT_END_IN_WATER
       
   124 	 * @exception AIBridge::ERR_BRIDGE_SLOPE_WRONG
       
   125 	 * @exception AIBridge::ERR_BRIDGE_HEADS_NOT_ON_SAME_HEIGHT
    99 	 * @return Whether the bridge has been/can be build or not.
   126 	 * @return Whether the bridge has been/can be build or not.
   100 	 */
   127 	 */
   101 	static bool BuildBridge(AIVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end);
   128 	static bool BuildBridge(AIVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end);
   102 
   129 
   103 	/**
   130 	/**