src/ai/api/ai_order.cpp
author truebrain
Sat, 07 Jun 2008 23:05:36 +0000
branchnoai
changeset 10853 87f2238f47d4
parent 10844 affb2821fb9f
child 11029 776c7cc8bda5
permissions -rw-r--r--
(svn r13404) [NoAI] -Change [API CHANGE]: AITile::IsBuildable no longer returns 'true' on road, but only on a halve piece of road (as that is auto-removed). This should make this function return less 'true', and more sane results :)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     1
/* $Id$ */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     2
9833
89a64246458f (svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents: 9737
diff changeset
     3
/** @file ai_order.cpp Implementation of AIOrder. */
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     4
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     5
#include "ai_order.hpp"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     6
#include "ai_map.hpp"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     7
#include "ai_vehicle.hpp"
10339
ce6cd68d9eb8 (svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents: 10249
diff changeset
     8
#include "../../openttd.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9707
diff changeset
     9
#include "../../vehicle_base.h"
10249
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 10146
diff changeset
    10
#include "../../depot_base.h"
9599
949374e83b78 (svn r9632) [NoAI] -Sync with trunk r9574:9631.
rubidium
parents: 9548
diff changeset
    11
#include "../../landscape.h"
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    12
#include "../../rail_map.h"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    13
#include "../../road_map.h"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    14
#include "../../station_map.h"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    15
#include "../../water_map.h"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    16
#include "../../waypoint.h"
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    17
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    18
/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    19
 * Gets the order type given a tile
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    20
 * @param t the tile to get the order from
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    21
 * @return the order type, or OT_END when there is no order
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    22
 */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    23
static OrderType GetOrderTypeByTile(TileIndex t)
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    24
{
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    25
	if (!::IsValidTile(t)) return OT_END;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    26
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    27
	switch (::GetTileType(t)) {
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    28
		default: break;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    29
		case MP_STATION: return OT_GOTO_STATION; break;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    30
		case MP_WATER:   if (::IsShipDepot(t)) return OT_GOTO_DEPOT; break;
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9624
diff changeset
    31
		case MP_ROAD:    if (::GetRoadTileType(t) == ROAD_TILE_DEPOT) return OT_GOTO_DEPOT; break;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    32
		case MP_RAILWAY:
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    33
			switch (::GetRailTileType(t)) {
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    34
				case RAIL_TILE_DEPOT:    return OT_GOTO_DEPOT;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    35
				case RAIL_TILE_WAYPOINT: return OT_GOTO_WAYPOINT;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    36
				default: break;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    37
			}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    38
			break;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    39
	}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    40
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    41
	return OT_END;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    42
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    43
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    44
/* static */ bool AIOrder::IsValidVehicleOrder(VehicleID vehicle_id, uint32 order_id)
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    45
{
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    46
	return AIVehicle::IsValidVehicle(vehicle_id) && order_id < ::GetVehicle(vehicle_id)->num_orders;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    47
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    48
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    49
/* static */ bool AIOrder::AreOrderFlagsValid(TileIndex destination, AIOrderFlags order_flags)
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    50
{
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    51
	switch (::GetOrderTypeByTile(destination)) {
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    52
		case OT_GOTO_STATION:
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    53
			return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_UNLOAD_FLAGS | AIOF_LOAD_FLAGS)) == 0) &&
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    54
					/* Test the different mutual exclusive flags. */
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    55
					(((order_flags & AIOF_TRANSFER)      == 0) || ((order_flags & AIOF_UNLOAD)    == 0)) &&
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    56
					(((order_flags & AIOF_TRANSFER)      == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    57
					(((order_flags & AIOF_UNLOAD)        == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    58
					(((order_flags & AIOF_UNLOAD)        == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    59
					(((order_flags & AIOF_NO_UNLOAD)     == 0) || ((order_flags & AIOF_NO_LOAD)   == 0)) &&
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    60
					(((order_flags & AIOF_FULL_LOAD_ANY) == 0) || ((order_flags & AIOF_NO_LOAD)   == 0));
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    61
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    62
		case OT_GOTO_DEPOT:    return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_SERVICE_IF_NEEDED)) == 0;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    63
		case OT_GOTO_WAYPOINT: return (order_flags & ~(AIOF_NON_STOP_FLAGS)) == 0;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    64
		default:               return false;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    65
	}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    66
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    67
10844
affb2821fb9f (svn r13395) [NoAI] -Fix [API CHANGE]: Rename AIOrder::GetNumberOfORders to AIOrder::GetOrderCount
truebrain
parents: 10339
diff changeset
    68
/* static */ int32 AIOrder::GetOrderCount(VehicleID vehicle_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    69
{
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    70
	return AIVehicle::IsValidVehicle(vehicle_id) ? ::GetVehicle(vehicle_id)->num_orders : -1;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    71
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    72
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
    73
/* static */ TileIndex AIOrder::GetOrderDestination(VehicleID vehicle_id, uint32 order_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    74
{
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9723
diff changeset
    75
	if (!IsValidVehicleOrder(vehicle_id, order_id)) return INVALID_TILE;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    76
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    77
	Order *order = ::GetVehicle(vehicle_id)->orders;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    78
	for (uint i = 0; i < order_id; i++) order = order->next;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    79
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    80
	switch (order->GetType()) {
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    81
		case OT_GOTO_DEPOT:    return ::GetDepot(order->GetDestination())->xy;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    82
		case OT_GOTO_STATION:  return ::GetStation(order->GetDestination())->xy;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    83
		case OT_GOTO_WAYPOINT: return ::GetWaypoint(order->GetDestination())->xy;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    84
		default:               return INVALID_TILE;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    85
	}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    86
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    87
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
    88
/* static */ AIOrder::AIOrderFlags AIOrder::GetOrderFlags(VehicleID vehicle_id, uint32 order_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    89
{
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9723
diff changeset
    90
	if (!IsValidVehicleOrder(vehicle_id, order_id)) return AIOF_INVALID;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    91
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    92
	Order *order = ::GetVehicle(vehicle_id)->orders;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    93
	for (uint i = 0; i < order_id; i++) order = order->next;
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    94
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    95
	AIOrderFlags order_flags = AIOF_NONE;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
    96
	order_flags |= (AIOrderFlags)order->GetNonStopType();
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    97
	switch (order->GetType()) {
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    98
		case OT_GOTO_DEPOT:
10142
56ee7da4ad56 (svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents: 10095
diff changeset
    99
			if (order->GetDepotOrderType() & ODTFB_SERVICE) order_flags |= AIOF_SERVICE_IF_NEEDED;
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   100
			break;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   101
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   102
		case OT_GOTO_STATION:
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   103
			order_flags |= (AIOrderFlags)(order->GetLoadType()   << 5);
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   104
			order_flags |= (AIOrderFlags)(order->GetUnloadType() << 2);
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   105
			break;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   106
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   107
		default: break;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   108
	}
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   109
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   110
	return order_flags;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   111
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   112
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   113
/* static */ bool AIOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   114
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   115
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   116
	return InsertOrder(vehicle_id, ::GetVehicle(vehicle_id)->num_orders, destination, order_flags);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   117
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   118
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   119
/* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrder::AIOrderFlags order_flags)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   120
{
9534
72cd7f3a32d9 (svn r9456) [NoAI] -Fix: creation of new orders failed.
rubidium
parents: 9500
diff changeset
   121
	/* IsValidVehicleOrder is not good enough because it does not allow appending. */
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   122
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
10095
7483ad241067 (svn r12626) [NoAI] -Fix r12623: use tabs in front of lines, not spaces
truebrain
parents: 10093
diff changeset
   123
	EnforcePrecondition(false, order_id <= ::GetVehicle(vehicle_id)->num_orders);
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   124
	EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   125
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   126
	Order order;
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   127
	switch (::GetOrderTypeByTile(destination)) {
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   128
		case OT_GOTO_DEPOT:
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   129
			order.MakeGoToDepot(::GetDepotByTile(destination)->index, (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & AIOF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0)));
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   130
			break;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   131
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   132
		case OT_GOTO_STATION:
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   133
			order.MakeGoToStation(::GetStationIndex(destination));
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   134
			order.SetLoadType((OrderLoadFlags)GB(order_flags, 5, 3));
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   135
			order.SetUnloadType((OrderUnloadFlags)GB(order_flags, 2, 3));
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   136
			break;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   137
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   138
		case OT_GOTO_WAYPOINT:
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   139
			order.MakeGoToWaypoint(::GetWaypointIndex(destination));
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   140
			break;
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   141
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   142
		default:
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   143
			return false;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   144
	}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   145
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   146
	order.SetNonStopType((OrderNonStopFlags)GB(order_flags, 0, 2));
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   147
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
   148
	return AIObject::DoCommand(0, vehicle_id | (order_id << 16), order.Pack(), CMD_INSERT_ORDER);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   149
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   150
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   151
/* static */ bool AIOrder::RemoveOrder(VehicleID vehicle_id, uint32 order_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   152
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   153
	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id));
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   154
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   155
	return AIObject::DoCommand(0, vehicle_id, order_id, CMD_DELETE_ORDER);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   156
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   157
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   158
/* static */ bool AIOrder::ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrder::AIOrderFlags order_flags)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   159
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   160
	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id));
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   161
	EnforcePrecondition(false, AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags));
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   162
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   163
	Order *order = ::GetVehicle(vehicle_id)->orders;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   164
	for (uint i = 0; i < order_id; i++) order = order->next;
9548
9f9f003dd9b5 (svn r9479) [NoAI] -Fix: AIOrder::ChangeOrder didn't work as expected, or rather CMD_MODIFY_ORDER didn't.
rubidium
parents: 9534
diff changeset
   165
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   166
	AIOrderFlags current = GetOrderFlags(vehicle_id, order_id);
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   167
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   168
	if ((current & AIOF_NON_STOP_FLAGS) != (order_flags & AIOF_NON_STOP_FLAGS)) {
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   169
		bool res = AIObject::DoCommand(0, vehicle_id | (order_id << 16), (order_flags & AIOF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER);
9548
9f9f003dd9b5 (svn r9479) [NoAI] -Fix: AIOrder::ChangeOrder didn't work as expected, or rather CMD_MODIFY_ORDER didn't.
rubidium
parents: 9534
diff changeset
   170
		if (!res) return false;
9f9f003dd9b5 (svn r9479) [NoAI] -Fix: AIOrder::ChangeOrder didn't work as expected, or rather CMD_MODIFY_ORDER didn't.
rubidium
parents: 9534
diff changeset
   171
	}
10146
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   172
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   173
	switch (order->GetType()) {
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   174
		case OT_GOTO_DEPOT:
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   175
			if ((current & AIOF_SERVICE_IF_NEEDED) != (order_flags & AIOF_SERVICE_IF_NEEDED)) {
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   176
				bool res = AIObject::DoCommand(0, vehicle_id | (order_id << 16), MOF_DEPOT_ACTION, CMD_MODIFY_ORDER);
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   177
				if (!res) return false;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   178
			}
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   179
			break;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   180
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   181
		case OT_GOTO_STATION:
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   182
			if ((current & AIOF_UNLOAD_FLAGS) != (order_flags & AIOF_UNLOAD_FLAGS)) {
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   183
				bool res = AIObject::DoCommand(0, vehicle_id | (order_id << 16), (order_flags & AIOF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, CMD_MODIFY_ORDER);
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   184
				if (!res) return false;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   185
			}
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   186
			if ((current & AIOF_LOAD_FLAGS) != (order_flags & AIOF_LOAD_FLAGS)) {
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   187
				bool res = AIObject::DoCommand(0, vehicle_id | (order_id << 16), (order_flags & AIOF_LOAD_FLAGS) >> 1 | MOF_LOAD, CMD_MODIFY_ORDER);
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   188
				if (!res) return false;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   189
			}
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   190
			break;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   191
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   192
		default: break;
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   193
	}
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   194
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   195
	assert(GetOrderFlags(vehicle_id, order_id) == order_flags);
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   196
ddbb8d2ae3ea (svn r12677) [NoAI] -Change [API CHANGE]: rework of the OrderFlags to support the new order possibilities in OpenTTD. As a result of this the following has changed:
rubidium
parents: 10142
diff changeset
   197
	return true;
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   198
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   199
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   200
/* static */ bool AIOrder::MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target)
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9694
diff changeset
   201
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   202
	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id_move));
10095
7483ad241067 (svn r12626) [NoAI] -Fix r12623: use tabs in front of lines, not spaces
truebrain
parents: 10093
diff changeset
   203
	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id_target));
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9694
diff changeset
   204
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   205
	return AIObject::DoCommand(0, vehicle_id, order_id_move | (order_id_target << 16), CMD_MOVE_ORDER);
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9694
diff changeset
   206
}
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9694
diff changeset
   207
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   208
/* static */ bool AIOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   209
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   210
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
10095
7483ad241067 (svn r12626) [NoAI] -Fix r12623: use tabs in front of lines, not spaces
truebrain
parents: 10093
diff changeset
   211
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(main_vehicle_id));
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   212
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   213
	return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_COPY, CMD_CLONE_ORDER);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   214
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   215
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   216
/* static */ bool AIOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   217
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   218
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
10095
7483ad241067 (svn r12626) [NoAI] -Fix r12623: use tabs in front of lines, not spaces
truebrain
parents: 10093
diff changeset
   219
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(main_vehicle_id));
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   220
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   221
	return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_SHARE, CMD_CLONE_ORDER);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   222
}
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   223
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   224
/* static */ bool AIOrder::UnshareOrders(VehicleID vehicle_id)
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   225
{
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9869
diff changeset
   226
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   227
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9736
diff changeset
   228
	return AIObject::DoCommand(0, vehicle_id, CO_UNSHARE, CMD_CLONE_ORDER);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   229
}