ai_vehicle.hpp

Go to the documentation of this file.
00001 /* $Id: ai_vehicle.hpp 20574 2010-08-19 20:58:30Z 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_VEHICLE_HPP
00013 #define AI_VEHICLE_HPP
00014 
00015 #include "ai_object.hpp"
00016 #include "ai_error.hpp"
00017 #include "ai_road.hpp"
00018 #include "ai_order.hpp"
00019 
00023 class AIVehicle : public AIObject {
00024 public:
00026   static const char *GetClassName() { return "AIVehicle"; }
00027 
00031   enum ErrorMessages {
00033     ERR_VEHICLE_BASE = AIError::ERR_CAT_VEHICLE << AIError::ERR_CAT_BIT_SIZE,
00034 
00036     ERR_VEHICLE_TOO_MANY,                   // [STR_ERROR_TOO_MANY_VEHICLES_IN_GAME]
00037 
00039     ERR_VEHICLE_NOT_AVAILABLE,              // [STR_ERROR_AIRCRAFT_NOT_AVAILABLE, STR_ERROR_ROAD_VEHICLE_NOT_AVAILABLE, STR_ERROR_SHIP_NOT_AVAILABLE, STR_ERROR_RAIL_VEHICLE_NOT_AVAILABLE]
00040 
00042     ERR_VEHICLE_BUILD_DISABLED,             // [STR_ERROR_CAN_T_BUY_TRAIN, STR_ERROR_CAN_T_BUY_ROAD_VEHICLE, STR_ERROR_CAN_T_BUY_SHIP, STR_ERROR_CAN_T_BUY_AIRCRAFT]
00043 
00045     ERR_VEHICLE_WRONG_DEPOT,                // [STR_ERROR_DEPOT_WRONG_DEPOT_TYPE]
00046 
00048     ERR_VEHICLE_CANNOT_SEND_TO_DEPOT,       // [STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT, STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT, STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT, STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR]
00049 
00051     ERR_VEHICLE_CANNOT_START_STOP,          // [STR_ERROR_CAN_T_STOP_START_TRAIN, STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE, STR_ERROR_CAN_T_STOP_START_SHIP, STR_ERROR_CAN_T_STOP_START_AIRCRAFT]
00052 
00054     ERR_VEHICLE_CANNOT_TURN,                // [STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN, STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS]
00055 
00057     ERR_VEHICLE_CANNOT_REFIT,               // [STR_ERROR_CAN_T_REFIT_TRAIN, STR_ERROR_CAN_T_REFIT_ROAD_VEHICLE, STR_ERROR_CAN_T_REFIT_SHIP, STR_ERROR_CAN_T_REFIT_AIRCRAFT]
00058 
00060     ERR_VEHICLE_IS_DESTROYED,               // [STR_ERROR_VEHICLE_IS_DESTROYED]
00061 
00063     ERR_VEHICLE_NOT_IN_DEPOT,               // [STR_ERROR_AIRCRAFT_MUST_BE_STOPPED_INSIDE_HANGAR, STR_ERROR_ROAD_VEHICLE_MUST_BE_STOPPED_INSIDE_DEPOT, STR_ERROR_TRAIN_MUST_BE_STOPPED_INSIDE_DEPOT, STR_ERROR_SHIP_MUST_BE_STOPPED_INSIDE_DEPOT]
00064 
00066     ERR_VEHICLE_IN_FLIGHT,                  // [STR_ERROR_AIRCRAFT_IS_IN_FLIGHT]
00067 
00069     ERR_VEHICLE_NO_POWER,                   // [STR_ERROR_TRAIN_START_NO_CATENARY]
00070 
00071   };
00072 
00077   enum VehicleType {
00078     /* Order IS important, as it now matches the internal state of the game for vehicle type */
00079     VT_RAIL,           
00080     VT_ROAD,           
00081     VT_WATER,          
00082     VT_AIR,            
00083     VT_INVALID = 0xFF, 
00084   };
00085 
00089   enum VehicleState {
00090     VS_RUNNING,        
00091     VS_STOPPED,        
00092     VS_IN_DEPOT,       
00093     VS_AT_STATION,     
00094     VS_BROKEN,         
00095     VS_CRASHED,        
00096 
00097     VS_INVALID = 0xFF, 
00098   };
00099 
00100   static const VehicleID VEHICLE_INVALID = 0xFFFFF; 
00101 
00107   static bool IsValidVehicle(VehicleID vehicle_id);
00108 
00115   static int32 GetNumWagons(VehicleID vehicle_id);
00116 
00127   static bool SetName(VehicleID vehicle_id, const char *name);
00128 
00135   static char *GetName(VehicleID vehicle_id);
00136 
00143   static TileIndex GetLocation(VehicleID vehicle_id);
00144 
00151   static EngineID GetEngineType(VehicleID vehicle_id);
00152 
00161   static EngineID GetWagonEngineType(VehicleID vehicle_id, int wagon);
00162 
00169   static int32 GetUnitNumber(VehicleID vehicle_id);
00170 
00178   static int32 GetAge(VehicleID vehicle_id);
00179 
00189   static int32 GetWagonAge(VehicleID vehicle_id, int wagon);
00190 
00198   static int32 GetMaxAge(VehicleID vehicle_id);
00199 
00207   static int32 GetAgeLeft(VehicleID vehicle_id);
00208 
00218   static int32 GetCurrentSpeed(VehicleID vehicle_id);
00219 
00226   static VehicleState GetState(VehicleID vehicle_id);
00227 
00237   static Money GetRunningCost(VehicleID vehicle_id);
00238 
00245   static Money GetProfitThisYear(VehicleID vehicle_id);
00246 
00253   static Money GetProfitLastYear(VehicleID vehicle_id);
00254 
00255 
00263   static Money GetCurrentValue(VehicleID vehicle_id);
00264 
00271   static AIVehicle::VehicleType GetVehicleType(VehicleID vehicle_id);
00272 
00280   static AIRoad::RoadType GetRoadType(VehicleID vehicle_id);
00281 
00288   static bool IsInDepot(VehicleID vehicle_id);
00289 
00296   static bool IsStoppedInDepot(VehicleID vehicle_id);
00297 
00315   static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id);
00316 
00331   static VehicleID CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders);
00332 
00346   static bool MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
00347 
00361   static bool MoveWagonChain(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
00362 
00373   static int GetRefitCapacity(VehicleID vehicle_id, CargoID cargo);
00374 
00388   static bool RefitVehicle(VehicleID vehicle_id, CargoID cargo);
00389 
00400   static bool SellVehicle(VehicleID vehicle_id);
00401 
00414   static bool SellWagon(VehicleID vehicle_id, int wagon);
00415 
00428   static bool SellWagonChain(VehicleID vehicle_id, int wagon);
00429 
00438   static bool SendVehicleToDepot(VehicleID vehicle_id);
00439 
00448   static bool SendVehicleToDepotForServicing(VehicleID vehicle_id);
00449 
00459   static bool StartStopVehicle(VehicleID vehicle_id);
00460 
00470   static bool ReverseVehicle(VehicleID vehicle_id);
00471 
00480   static int32 GetCapacity(VehicleID vehicle_id, CargoID cargo);
00481 
00489   static int GetLength(VehicleID vehicle_id);
00490 
00499   static int32 GetCargoLoad(VehicleID vehicle_id, CargoID cargo);
00500 
00506   static GroupID GetGroupID(VehicleID vehicle_id);
00507 
00515   static bool IsArticulated(VehicleID vehicle_id);
00516 
00523   static bool HasSharedOrders(VehicleID vehicle_id);
00524 
00531   static int GetReliability(VehicleID vehicle_id);
00532 
00533 private:
00537   static bool _SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons);
00538 
00542   static bool _MoveWagonInternal(VehicleID source_vehicle_id, int source_wagon, bool move_attached_wagons, int dest_vehicle_id, int dest_wagon);
00543 };
00544 
00545 #endif /* AI_VEHICLE_HPP */

Generated on Thu Jan 20 22:57:31 2011 for OpenTTD by  doxygen 1.6.1