summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-03-12 11:43:40 +0000
committeryexo <yexo@openttd.org>2009-03-12 11:43:40 +0000
commit21daa3fbc9775dc0b45db006c7adf39bdfd8254c (patch)
tree036f263970898122c11bfe14edff539e64fb1b9e
parent111e2691b045c77b1a0afeaee52177158620336f (diff)
downloadopenttd-21daa3fbc9775dc0b45db006c7adf39bdfd8254c.tar.xz
(svn r15684) -Add [NoAI]: AIOrder::SkipToOrder().
-rw-r--r--src/ai/api/ai_event.hpp1
-rw-r--r--src/ai/api/ai_order.cpp7
-rw-r--r--src/ai/api/ai_order.hpp12
-rw-r--r--src/ai/api/ai_order.hpp.sq1
4 files changed, 20 insertions, 1 deletions
diff --git a/src/ai/api/ai_event.hpp b/src/ai/api/ai_event.hpp
index 077e2a2e6..109b0b68f 100644
--- a/src/ai/api/ai_event.hpp
+++ b/src/ai/api/ai_event.hpp
@@ -91,6 +91,7 @@ public:
/**
* Insert an event to the queue for the company.
* @param event The event to insert.
+ * @note DO NOT CALL YOURSELF; leave it to the internal AI programming.
*/
static void InsertEvent(AIEvent *event);
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index e22c08ea1..2e901ea0a 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -306,6 +306,13 @@ static OrderType GetOrderTypeByTile(TileIndex t)
return AIObject::DoCommand(0, vehicle_id, order_position, CMD_DELETE_ORDER);
}
+/* static */ bool AIOrder::SkipToOrder(VehicleID vehicle_id, OrderPosition next_order)
+{
+ EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, next_order));
+
+ return AIObject::DoCommand(0, vehicle_id, next_order, CMD_SKIP_TO_ORDER);
+}
+
/**
* Callback handler as SetOrderFlags possibly needs multiple DoCommand calls
* to be able to set all order flags correctly. As we need to wait till the
diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp
index c39513f19..dd26c819c 100644
--- a/src/ai/api/ai_order.hpp
+++ b/src/ai/api/ai_order.hpp
@@ -331,7 +331,7 @@ public:
* Removes an order from the vehicle's order list.
* @param vehicle_id The vehicle to remove the order from.
* @param order_position The order to remove from the order list.
- * @pre AIVehicle::IsValidVehicleOrder(vehicle_id, order_position).
+ * @pre IsValidVehicleOrder(vehicle_id, order_position).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
* @return True if and only if the order was removed.
*/
@@ -378,6 +378,16 @@ public:
static bool MoveOrder(VehicleID vehicle_id, OrderPosition order_position_move, OrderPosition order_position_target);
/**
+ * Make a vehicle execute next_order instead of its current order.
+ * @param vehicle_id The vehicle that should skip some orders.
+ * @param next_order The order the vehicle should skip to.
+ * @pre IsValidVehicleOrder(vehicle_id, next_order).
+ * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
+ * @return True if and only the current order was changed.
+ */
+ static bool SkipToOrder(VehicleID vehicle_id, OrderPosition next_order);
+
+ /**
* Copies the orders from another vehicle. The orders of the main vehicle
* are going to be the orders of the changed vehicle.
* @param vehicle_id The vehicle to copy the orders to.
diff --git a/src/ai/api/ai_order.hpp.sq b/src/ai/api/ai_order.hpp.sq
index 388fec391..3164c1098 100644
--- a/src/ai/api/ai_order.hpp.sq
+++ b/src/ai/api/ai_order.hpp.sq
@@ -95,6 +95,7 @@ void SQAIOrder_Register(Squirrel *engine) {
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderFlags, "SetOrderFlags", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, ".iii");
+ SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SkipToOrder, "SkipToOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, ".i");