summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_vehicle.hpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-02-14 21:22:42 +0000
committeryexo <yexo@openttd.org>2009-02-14 21:22:42 +0000
commit2b221f5afc28c025fa0eee7148d72460827c63fb (patch)
tree08ba8ca2df5f787b42750a85edccda553459c95f /src/ai/api/ai_vehicle.hpp
parent336abd66a2ba618df9388f3c5a06fdfd272a770e (diff)
downloadopenttd-2b221f5afc28c025fa0eee7148d72460827c63fb.tar.xz
(svn r15492) -Change [API CHANGE]: Split AIVehicle::MoveWagon in MoveWagon and MoveWagonChain (frosch).
Diffstat (limited to 'src/ai/api/ai_vehicle.hpp')
-rw-r--r--src/ai/api/ai_vehicle.hpp50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp
index 5b9a276c6..5c363e4f4 100644
--- a/src/ai/api/ai_vehicle.hpp
+++ b/src/ai/api/ai_vehicle.hpp
@@ -328,7 +328,6 @@ public:
* Move a wagon after another wagon.
* @param source_vehicle_id The vehicle to move a wagon away from.
* @param source_wagon The wagon in source_vehicle to move.
- * @param move_attached_wagons Also move all wagons attached to the wagon to move.
* @param dest_vehicle_id The vehicle to move the wagon to, or -1 to create a new vehicle.
* @param dest_wagon The wagon in dest_vehicle to place source_wagon after.
* @pre IsValidVehicle(source_vehicle_id).
@@ -336,9 +335,24 @@ public:
* @pre dest_vehicle_id == -1 || (IsValidVehicle(dest_vehicle_id) && dest_wagon < GetNumWagons(dest_vehicle_id)).
* @pre GetVehicleType(source_vehicle_id) == VEHICLE_RAIL.
* @pre dest_vehicle_id == -1 || GetVehicleType(dest_vehicle_id) == VEHICLE_RAIL.
- * @return Whether or not moving the wagon(s) succeeded.
+ * @return Whether or not moving the wagon succeeded.
*/
- static bool MoveWagon(VehicleID source_vehicle_id, int source_wagon, bool move_attached_wagons, int dest_vehicle_id, int dest_wagon);
+ static bool MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
+
+ /**
+ * Move a chain of wagons after another wagon.
+ * @param source_vehicle_id The vehicle to move a wagon away from.
+ * @param source_wagon The first wagon in source_vehicle to move.
+ * @param dest_vehicle_id The vehicle to move the wagons to, or -1 to create a new vehicle.
+ * @param dest_wagon The wagon in dest_vehicle to place source_wagon and following wagons after.
+ * @pre IsValidVehicle(source_vehicle_id).
+ * @pre source_wagon < GetNumWagons(source_vehicle_id).
+ * @pre dest_vehicle_id == -1 || (IsValidVehicle(dest_vehicle_id) && dest_wagon < GetNumWagons(dest_vehicle_id)).
+ * @pre GetVehicleType(source_vehicle_id) == VEHICLE_RAIL.
+ * @pre dest_vehicle_id == -1 || GetVehicleType(dest_vehicle_id) == VEHICLE_RAIL.
+ * @return Whether or not moving the wagons succeeded.
+ */
+ static bool MoveWagonChain(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
/**
* Gets the capacity of the given vehicle when refited to the given cargo type.
@@ -383,16 +397,29 @@ public:
* Sells the given wagon from the vehicle.
* @param vehicle_id The vehicle to sell a wagon from.
* @param wagon The wagon to sell.
- * @param sell_attached_wagons Sell all wagons attached to the one we want to sell.
* @pre IsValidVehicle(vehicle_id).
* @pre wagon < GetNumWagons(vehicle_id).
* @pre You must own the vehicle.
* @pre The vehicle must be stopped in the depot.
* @exception AIVehicle::ERR_VEHICLE_IS_DESTROYED
* @exception AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT
- * @return True if and only if the wagon(s) has been sold.
+ * @return True if and only if the wagon has been sold.
+ */
+ static bool SellWagon(VehicleID vehicle_id, int wagon);
+
+ /**
+ * Sells all wagons from the vehicle starting from a given position.
+ * @param vehicle_id The vehicle to sell a wagon from.
+ * @param wagon The wagon to sell.
+ * @pre IsValidVehicle(vehicle_id).
+ * @pre wagon < GetNumWagons(vehicle_id).
+ * @pre You must own the vehicle.
+ * @pre The vehicle must be stopped in the depot.
+ * @exception AIVehicle::ERR_VEHICLE_IS_DESTROYED
+ * @exception AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT
+ * @return True if and only if the wagons have been sold.
*/
- static bool SellWagon(VehicleID vehicle_id, int wagon, bool sell_attached_wagons);
+ static bool SellWagonChain(VehicleID vehicle_id, int wagon);
/**
* Sends the given vehicle to a depot.
@@ -486,6 +513,17 @@ public:
* @return True if the vehicle has shared orders.
*/
static bool HasSharedOrders(VehicleID vehicle_id);
+
+private:
+ /**
+ * Internal function used by SellWagon(Chain).
+ */
+ static bool _SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons);
+
+ /**
+ * Internal function used by MoveWagon(Chain).
+ */
+ static bool _MoveWagonInternal(VehicleID source_vehicle_id, int source_wagon, bool move_attached_wagons, int dest_vehicle_id, int dest_wagon);
};
#endif /* AI_VEHICLE_HPP */