ai_vehicle.hpp

Go to the documentation of this file.
00001 /* $Id$ */
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_road.hpp"
00016 
00020 class AIVehicle : public AIObject {
00021 public:
00023   static const char *GetClassName() { return "AIVehicle"; }
00024 
00028   enum ErrorMessages {
00030     ERR_VEHICLE_BASE = AIError::ERR_CAT_VEHICLE << AIError::ERR_CAT_BIT_SIZE,
00031 
00033     ERR_VEHICLE_TOO_MANY,                   // [STR_ERROR_TOO_MANY_VEHICLES_IN_GAME]
00034 
00036     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]
00037 
00039     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]
00040 
00042     ERR_VEHICLE_WRONG_DEPOT,                // [STR_ERROR_DEPOT_WRONG_DEPOT_TYPE]
00043 
00045     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]
00046 
00048     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]
00049 
00051     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]
00052 
00054     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]
00055 
00057     ERR_VEHICLE_IS_DESTROYED,               // [STR_ERROR_VEHICLE_IS_DESTROYED]
00058 
00060     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]
00061 
00063     ERR_VEHICLE_IN_FLIGHT,                  // [STR_ERROR_AIRCRAFT_IS_IN_FLIGHT]
00064 
00066     ERR_VEHICLE_NO_POWER,                   // [STR_ERROR_TRAIN_START_NO_CATENARY]
00067 
00068   };
00069 
00074   enum VehicleType {
00075     /* Order IS important, as it now matches the internal state of the game for vehicle type */
00076     VT_RAIL,           
00077     VT_ROAD,           
00078     VT_WATER,          
00079     VT_AIR,            
00080     VT_INVALID = 0xFF, 
00081   };
00082 
00086   enum VehicleState {
00087     VS_RUNNING,        
00088     VS_STOPPED,        
00089     VS_IN_DEPOT,       
00090     VS_AT_STATION,     
00091     VS_BROKEN,         
00092     VS_CRASHED,        
00093 
00094     VS_INVALID = 0xFF, 
00095   };
00096 
00097   static const VehicleID VEHICLE_INVALID = 0xFFFFF; 
00098 
00104   static bool IsValidVehicle(VehicleID vehicle_id);
00105 
00112   static int32 GetNumWagons(VehicleID vehicle_id);
00113 
00124   static bool SetName(VehicleID vehicle_id, const char *name);
00125 
00132   static char *GetName(VehicleID vehicle_id);
00133 
00140   static TileIndex GetLocation(VehicleID vehicle_id);
00141 
00148   static EngineID GetEngineType(VehicleID vehicle_id);
00149 
00158   static EngineID GetWagonEngineType(VehicleID vehicle_id, int wagon);
00159 
00166   static int32 GetUnitNumber(VehicleID vehicle_id);
00167 
00175   static int32 GetAge(VehicleID vehicle_id);
00176 
00186   static int32 GetWagonAge(VehicleID vehicle_id, int wagon);
00187 
00195   static int32 GetMaxAge(VehicleID vehicle_id);
00196 
00204   static int32 GetAgeLeft(VehicleID vehicle_id);
00205 
00215   static int32 GetCurrentSpeed(VehicleID vehicle_id);
00216 
00223   static VehicleState GetState(VehicleID vehicle_id);
00224 
00234   static Money GetRunningCost(VehicleID vehicle_id);
00235 
00242   static Money GetProfitThisYear(VehicleID vehicle_id);
00243 
00250   static Money GetProfitLastYear(VehicleID vehicle_id);
00251 
00252 
00260   static Money GetCurrentValue(VehicleID vehicle_id);
00261 
00268   static AIVehicle::VehicleType GetVehicleType(VehicleID vehicle_id);
00269 
00277   static AIRoad::RoadType GetRoadType(VehicleID vehicle_id);
00278 
00285   static bool IsInDepot(VehicleID vehicle_id);
00286 
00293   static bool IsStoppedInDepot(VehicleID vehicle_id);
00294 
00312   static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id);
00313 
00328   static VehicleID CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders);
00329 
00343   static bool MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
00344 
00358   static bool MoveWagonChain(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
00359 
00370   static int GetRefitCapacity(VehicleID vehicle_id, CargoID cargo);
00371 
00385   static bool RefitVehicle(VehicleID vehicle_id, CargoID cargo);
00386 
00397   static bool SellVehicle(VehicleID vehicle_id);
00398 
00411   static bool SellWagon(VehicleID vehicle_id, int wagon);
00412 
00425   static bool SellWagonChain(VehicleID vehicle_id, int wagon);
00426 
00435   static bool SendVehicleToDepot(VehicleID vehicle_id);
00436 
00445   static bool SendVehicleToDepotForServicing(VehicleID vehicle_id);
00446 
00456   static bool StartStopVehicle(VehicleID vehicle_id);
00457 
00467   static bool ReverseVehicle(VehicleID vehicle_id);
00468 
00477   static int32 GetCapacity(VehicleID vehicle_id, CargoID cargo);
00478 
00486   static int GetLength(VehicleID vehicle_id);
00487 
00496   static int32 GetCargoLoad(VehicleID vehicle_id, CargoID cargo);
00497 
00503   static GroupID GetGroupID(VehicleID vehicle_id);
00504 
00512   static bool IsArticulated(VehicleID vehicle_id);
00513 
00520   static bool HasSharedOrders(VehicleID vehicle_id);
00521 
00528   static int GetReliability(VehicleID vehicle_id);
00529 
00530 private:
00534   static bool _SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons);
00535 
00539   static bool _MoveWagonInternal(VehicleID source_vehicle_id, int source_wagon, bool move_attached_wagons, int dest_vehicle_id, int dest_wagon);
00540 };
00541 
00542 #endif /* AI_VEHICLE_HPP */

Generated on Wed Apr 13 00:47:45 2011 for OpenTTD by  doxygen 1.6.1