diff options
author | glx <glx@openttd.org> | 2019-03-08 19:52:22 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-24 15:28:48 +0000 |
commit | f8e6cd10ef8161fbaa95a847a794e475d6aeb60e (patch) | |
tree | 734b37097034e180161ec9a6b003c2c465d151f9 /src/script/api/script_vehicle.hpp | |
parent | d54b6ac09b6fe88c09f7886739fe9c05f16b8222 (diff) | |
download | openttd-f8e6cd10ef8161fbaa95a847a794e475d6aeb60e.tar.xz |
Add: script API functions for build with refit feature
Diffstat (limited to 'src/script/api/script_vehicle.hpp')
-rw-r--r-- | src/script/api/script_vehicle.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index f6b22c204..d027e1243 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -321,6 +321,41 @@ public: static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id); /** + * Builds a vehicle with the given engine at the given depot and refits it to the given cargo. + * @param depot The depot where the vehicle will be build. + * @param engine_id The engine to use for this vehicle. + * @param cargo The cargo to refit to. + * @pre The tile at depot has a depot that can build the engine and + * is owned by you. + * @pre ScriptEngine::IsBuildable(engine_id). + * @pre ScriptCargo::IsValidCargo(cargo). + * @game @pre Valid ScriptCompanyMode active in scope. + * @exception ScriptVehicle::ERR_VEHICLE_TOO_MANY + * @exception ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED + * @exception ScriptVehicle::ERR_VEHICLE_WRONG_DEPOT + * @return The VehicleID of the new vehicle, or an invalid VehicleID when + * it failed. Check the return value using IsValidVehicle. In test-mode + * 0 is returned if it was successful; any other value indicates failure. + * @note In Test Mode it means you can't assign orders yet to this vehicle, + * as the vehicle isn't really built yet. Build it for real first before + * assigning orders. + */ + static VehicleID BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo); + + /** + * Gets the capacity of a vehicle built at the given depot with the given engine and refitted to the given cargo. + * @param depot The depot where the vehicle will be build. + * @param engine_id The engine to use for this vehicle. + * @param cargo The cargo to refit to. + * @pre The tile at depot has a depot that can build the engine and + * is owned by you. + * @pre ScriptEngine::IsBuildable(engine_id). + * @pre ScriptCargo::IsValidCargo(cargo). + * @return The capacity the vehicle will have when refited. + */ + static int GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo); + + /** * Clones a vehicle at the given depot, copying or cloning its orders. * @param depot The depot where the vehicle will be build. * @param vehicle_id The vehicle to use as example for the new vehicle. @@ -564,6 +599,11 @@ public: private: /** + * Internal function used by BuildVehicle(WithRefit). + */ + static VehicleID _BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo); + + /** * Internal function used by SellWagon(Chain). */ static bool _SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons); |