summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_order.cpp16
-rw-r--r--src/ai/api/ai_order.hpp4
-rw-r--r--src/ai/api/ai_order.hpp.sq2
3 files changed, 18 insertions, 4 deletions
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index 9278b9f82..6e5bd28cd 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -74,7 +74,10 @@ static OrderType GetOrderTypeByTile(TileIndex t)
(((order_flags & AIOF_NO_UNLOAD) == 0) || ((order_flags & AIOF_NO_LOAD) == 0)) &&
(((order_flags & AIOF_FULL_LOAD_ANY) == 0) || ((order_flags & AIOF_NO_LOAD) == 0));
- case OT_GOTO_DEPOT: return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_SERVICE_IF_NEEDED)) == 0;
+ case OT_GOTO_DEPOT:
+ return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_DEPOT_FLAGS)) == 0) &&
+ (((order_flags & AIOF_SERVICE_IF_NEEDED) == 0) || ((order_flags & AIOF_STOP_IN_DEPOT) == 0));
+
case OT_GOTO_WAYPOINT: return (order_flags & ~(AIOF_NON_STOP_FLAGS)) == 0;
default: return false;
}
@@ -145,6 +148,7 @@ static OrderType GetOrderTypeByTile(TileIndex t)
switch (order->GetType()) {
case OT_GOTO_DEPOT:
if (order->GetDepotOrderType() & ODTFB_SERVICE) order_flags |= AIOF_SERVICE_IF_NEEDED;
+ if (order->GetDepotActionType() & ODATFB_HALT) order_flags |= AIOF_STOP_IN_DEPOT;
break;
case OT_GOTO_STATION:
@@ -260,9 +264,12 @@ static OrderType GetOrderTypeByTile(TileIndex t)
Order order;
switch (::GetOrderTypeByTile(destination)) {
- case OT_GOTO_DEPOT:
- order.MakeGoToDepot(::GetDepotByTile(destination)->index, (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & AIOF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0)));
+ case OT_GOTO_DEPOT: {
+ OrderDepotTypeFlags odtf = (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & AIOF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0));
+ OrderDepotActionFlags odaf = (OrderDepotActionFlags)(ODATF_SERVICE_ONLY | ((order_flags & AIOF_STOP_IN_DEPOT) ? ODATFB_HALT : 0));
+ order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, odaf);
break;
+ }
case OT_GOTO_STATION:
order.MakeGoToStation(::GetStationIndex(destination));
@@ -357,9 +364,10 @@ static void _DoCommandReturnSetOrderFlags(class AIInstance *instance)
switch (order->GetType()) {
case OT_GOTO_DEPOT:
- if ((current & AIOF_SERVICE_IF_NEEDED) != (order_flags & AIOF_SERVICE_IF_NEEDED)) {
+ if ((current & AIOF_DEPOT_FLAGS) != (order_flags & AIOF_DEPOT_FLAGS)) {
uint data = DA_ALWAYS_GO;
if (order_flags & AIOF_SERVICE_IF_NEEDED) data = DA_SERVICE;
+ if (order_flags & AIOF_STOP_IN_DEPOT) data = DA_STOP;
return AIObject::DoCommand(0, vehicle_id | (order_position << 16), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, NULL, &_DoCommandReturnSetOrderFlags);
}
break;
diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp
index dd26c819c..8a08b505a 100644
--- a/src/ai/api/ai_order.hpp
+++ b/src/ai/api/ai_order.hpp
@@ -57,6 +57,8 @@ public:
/** Service the vehicle when needed, otherwise skip this order; only for depots. */
AIOF_SERVICE_IF_NEEDED = 1 << 2,
+ /** Stop in the depot instead of only go there for servicing; only for depots. */
+ AIOF_STOP_IN_DEPOT = 1 << 3,
/** All flags related to non-stop settings. */
AIOF_NON_STOP_FLAGS = AIOF_NON_STOP_INTERMEDIATE | AIOF_NON_STOP_DESTINATION,
@@ -64,6 +66,8 @@ public:
AIOF_UNLOAD_FLAGS = AIOF_TRANSFER | AIOF_UNLOAD | AIOF_NO_UNLOAD,
/** All flags related to loading. */
AIOF_LOAD_FLAGS = AIOF_FULL_LOAD | AIOF_FULL_LOAD_ANY | AIOF_NO_LOAD,
+ /** All flags related to depots. */
+ AIOF_DEPOT_FLAGS = AIOF_SERVICE_IF_NEEDED | AIOF_STOP_IN_DEPOT,
/** For marking invalid order flags */
AIOF_INVALID = 0xFFFF,
diff --git a/src/ai/api/ai_order.hpp.sq b/src/ai/api/ai_order.hpp.sq
index 3164c1098..d2ac2ae8a 100644
--- a/src/ai/api/ai_order.hpp.sq
+++ b/src/ai/api/ai_order.hpp.sq
@@ -42,9 +42,11 @@ void SQAIOrder_Register(Squirrel *engine) {
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_FULL_LOAD_ANY, "AIOF_FULL_LOAD_ANY");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_NO_LOAD, "AIOF_NO_LOAD");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_SERVICE_IF_NEEDED, "AIOF_SERVICE_IF_NEEDED");
+ SQAIOrder.DefSQConst(engine, AIOrder::AIOF_STOP_IN_DEPOT, "AIOF_STOP_IN_DEPOT");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_NON_STOP_FLAGS, "AIOF_NON_STOP_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_UNLOAD_FLAGS, "AIOF_UNLOAD_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_LOAD_FLAGS, "AIOF_LOAD_FLAGS");
+ SQAIOrder.DefSQConst(engine, AIOrder::AIOF_DEPOT_FLAGS, "AIOF_DEPOT_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_INVALID, "AIOF_INVALID");
SQAIOrder.DefSQConst(engine, AIOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE");
SQAIOrder.DefSQConst(engine, AIOrder::OC_RELIABILITY, "OC_RELIABILITY");