src/ai/api/ai_order.hpp
author rubidium
Tue, 15 Apr 2008 15:32:47 +0000
branchnoai
changeset 10189 b18d1d5b047d
parent 10181 54df587fef5d
child 10844 affb2821fb9f
permissions -rw-r--r--
(svn r12720) [NoAI] -Add: functions to get the capacity/current load of a vehicle given a cargo type.
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
9829
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9737
diff changeset
     3
/** @file ai_order.hpp Everything to query and build orders. */
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
#ifndef AI_ORDER_HPP
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     6
#define AI_ORDER_HPP
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     7
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
     8
#include "ai_object.hpp"
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
     9
#include "ai_error.hpp"
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    10
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    11
/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    12
 * Class that handles all order related functions.
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    13
 */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    14
class AIOrder : public AIObject {
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    15
public:
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    16
	static const char *GetClassName() { return "AIOrder"; }
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    17
10096
780921b39016 (svn r12627) [NoAI] -Fix: last few commits missed some comments around enums
truebrain
parents: 10093
diff changeset
    18
	/**
780921b39016 (svn r12627) [NoAI] -Fix: last few commits missed some comments around enums
truebrain
parents: 10093
diff changeset
    19
	 * All order related error messages.
780921b39016 (svn r12627) [NoAI] -Fix: last few commits missed some comments around enums
truebrain
parents: 10093
diff changeset
    20
	 */
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    21
	enum ErrorMessages {
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    22
		/** Base for all order related errors */
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    23
		ERR_ORDER_BASE = AIError::ERR_CAT_ORDER << AIError::ERR_CAT_BIT_SIZE,
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    24
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    25
		/** No more space for orders */
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    26
		ERR_ORDER_TOO_MANY,                                  // [STR_8831_NO_MORE_SPACE_FOR_ORDERS]
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    27
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    28
		/** Destination of new order is to far away from the previous order */
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    29
		ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION,    // [STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO]
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    30
	};
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
    31
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    32
	/**
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    33
	 * Flags that can be used to modify the behaviour of orders.
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    34
	 */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    35
	enum AIOrderFlags {
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    36
		/** Just go to the station/depot, stop unload if possible and load if needed. */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    37
		AIOF_NONE              = 0,
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    38
10181
54df587fef5d (svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents: 10149
diff changeset
    39
		/** Do not stop at the stations that are passed when going to the destination. Only for trains and road vehicles. */
10149
a273c164cfab (svn r12680) [NoAI] -Fix [API CHANGE]: don't use very very long AIOF_NON_STOP flags, but AIOF_NON_STOP_INTERMEDIATE / AIOF_NON_STOP_DESTINATION instead
truebrain
parents: 10146
diff changeset
    40
		AIOF_NON_STOP_INTERMEDIATE = 1 << 0,
10181
54df587fef5d (svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents: 10149
diff changeset
    41
		/** Do not stop at the destionation station. Only for trains and road vehicles. */
10149
a273c164cfab (svn r12680) [NoAI] -Fix [API CHANGE]: don't use very very long AIOF_NON_STOP flags, but AIOF_NON_STOP_INTERMEDIATE / AIOF_NON_STOP_DESTINATION instead
truebrain
parents: 10146
diff changeset
    42
		AIOF_NON_STOP_DESTINATION  = 1 << 1,
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: 10096
diff changeset
    43
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: 10096
diff changeset
    44
		/** Always unload the vehicle; only for stations. Cannot be set when AIOF_TRANSFER or AIOF_NO_UNLOAD is set. */
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: 10096
diff changeset
    45
		AIOF_UNLOAD            = 1 << 2,
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: 10096
diff changeset
    46
		/** Transfer instead of deliver the goods; only for stations. Cannot be set when AIOF_UNLOAD or AIOF_NO_UNLOAD is set. */
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: 10096
diff changeset
    47
		AIOF_TRANSFER          = 1 << 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: 10096
diff changeset
    48
		/** Never unload the vehicle; only for stations. Cannot be set when AIOF_UNLOAD, AIOF_TRANSFER or AIOF_NO_LOAD is set. */
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: 10096
diff changeset
    49
		AIOF_NO_UNLOAD         = 1 << 4,
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: 10096
diff changeset
    50
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: 10096
diff changeset
    51
		/** Wait till the vehicle is fully loaded; only for stations. Cannot be set when AIOF_NO_LOAD is set. */
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: 10096
diff changeset
    52
		AIOF_FULL_LOAD         = 2 << 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: 10096
diff changeset
    53
		/** Wait till at least one cargo of the vehicle is fully loaded; only for stations. Cannot be set when AIOF_NO_LOAD is set. */
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: 10096
diff changeset
    54
		AIOF_FULL_LOAD_ANY     = 3 << 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: 10096
diff changeset
    55
		/** Do not load any cargo; only for stations. Cannot be set when AIOF_NO_UNLOAD, AIOF_FULL_LOAD or AIOF_FULL_LOAD_ANY is set. */
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: 10096
diff changeset
    56
		AIOF_NO_LOAD           = 1 << 7,
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    57
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    58
		/** Service the vehicle when needed, otherwise skip this order; only for depots. */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    59
		AIOF_SERVICE_IF_NEEDED = 1 << 2,
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    60
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: 10096
diff changeset
    61
		/** All flags related to non-stop settings. */
10149
a273c164cfab (svn r12680) [NoAI] -Fix [API CHANGE]: don't use very very long AIOF_NON_STOP flags, but AIOF_NON_STOP_INTERMEDIATE / AIOF_NON_STOP_DESTINATION instead
truebrain
parents: 10146
diff changeset
    62
		AIOF_NON_STOP_FLAGS    = AIOF_NON_STOP_INTERMEDIATE | AIOF_NON_STOP_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: 10096
diff changeset
    63
		/** All flags related to unloading. */
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: 10096
diff changeset
    64
		AIOF_UNLOAD_FLAGS      = AIOF_TRANSFER | AIOF_UNLOAD | AIOF_NO_UNLOAD,
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: 10096
diff changeset
    65
		/** All flags related to loading. */
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: 10096
diff changeset
    66
		AIOF_LOAD_FLAGS        = AIOF_FULL_LOAD | AIOF_FULL_LOAD_ANY | AIOF_NO_LOAD,
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    67
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    68
		/** For marking invalid order flags */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    69
		AIOF_INVALID           = 0xFFFF,
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    70
	};
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
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    73
	 * Checks whether the given order id is valid for the given vehicle.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    74
	 * @param vehicle_id The vehicle to check the order index for.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    75
	 * @param order_id The order index to check.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    76
	 * @pre AIVehicle::IsValidVehicle(vehicle_id).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    77
	 * @return True if and only if the order_id is valid for the given vehicle.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    78
	 */
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    79
	static bool IsValidVehicleOrder(VehicleID vehicle_id, uint32 order_id);
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    80
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    81
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    82
	 * Checks whether the given order flags are valid for the given destination.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    83
	 * @param destination The destination of the order.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    84
	 * @param order_flags The flags given to the order.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    85
	 * @return True if and only if the order_flags are valid for the given location.
9500
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
	static bool AreOrderFlagsValid(TileIndex destination, AIOrderFlags order_flags);
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    88
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    89
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    90
	 * Returns the number of orders for the given vehicle.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    91
	 * @param vehicle_id The vehicle to get the order count of.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    92
	 * @pre AIVehicle::IsValidVehicle(vehicle_id).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    93
	 * @return The number of orders for the given vehicle or a negative
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    94
	 *   value when the vehicle does not exist.
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    95
	 */
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: 9707
diff changeset
    96
	static int32 GetNumberOfOrders(VehicleID vehicle_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    97
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    98
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
    99
	 * Gets the destination of the given order for the given vehicle.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   100
	 * @param vehicle_id The vehicle to get the destination for.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   101
	 * @param order_id The order to get the destination for.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   102
	 * @pre IsValidVehicleOrder(vehicle_id, order_id).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   103
	 * @return The destination tile of the order.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   104
	 */
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: 9707
diff changeset
   105
	static TileIndex GetOrderDestination(VehicleID vehicle_id, uint32 order_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   106
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   107
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   108
	 * Gets the AIOrderFlags of the given order for the given vehicle.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   109
	 * @param vehicle_id The vehicle to get the destination for.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   110
	 * @param order_id The order to get the destination for.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   111
	 * @pre IsValidVehicleOrder(vehicle_id, order_id).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   112
	 * @return The AIOrderFlags of the order.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   113
	 */
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: 9707
diff changeset
   114
	static AIOrderFlags GetOrderFlags(VehicleID vehicle_id, uint32 order_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   115
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   116
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   117
	 * Appends an order to the end of the vehicle's order list.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   118
	 * @param vehicle_id The vehicle to append the order to.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   119
	 * @param destination The destination of the order.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   120
	 * @param order_flags The flags given to the order.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   121
	 * @pre AIVehicle::IsValidVehicle(vehicle_id).
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   122
	 * @pre AreOrderFlagsValid(destination, order_flags).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   123
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   124
	 * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   125
	 * @exception AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   126
	 * @return True if and only if the order was appended.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   127
	 */
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: 9707
diff changeset
   128
	static bool AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   129
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   130
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   131
	 * Inserts an order before the given order_id into the vehicle's order list.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   132
	 * @param vehicle_id The vehicle to add the order to.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   133
	 * @param order_id The order to place the new order before.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   134
	 * @param destination The destination of the order.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   135
	 * @param order_flags The flags given to the order.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   136
	 * @pre IsValidVehicleOrder(vehicle_id, order_id).
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   137
	 * @pre AreOrderFlagsValid(destination, order_flags).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   138
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   139
	 * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   140
	 * @exception AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   141
	 * @return True if and only if the order was inserted.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   142
	 */
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: 9707
diff changeset
   143
	static bool InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrderFlags order_flags);
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
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   146
	 * Removes an order from the vehicle's order list.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   147
	 * @param vehicle_id The vehicle to remove the order from.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   148
	 * @param order_id The order to remove from the order list.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   149
	 * @pre AIVehicle::IsValidVehicleOrder(vehicle_id, order_id).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   150
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   151
	 * @return True if and only if the order was removed.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   152
	 */
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: 9707
diff changeset
   153
	static bool RemoveOrder(VehicleID vehicle_id, uint32 order_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   154
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   155
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   156
	 * Changes the order flags of the given order.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   157
	 * @param vehicle_id The vehicle to change the order of.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   158
	 * @param order_id The order to change.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   159
	 * @param order_flags The new flags given to the order.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   160
	 * @pre IsValidVehicleOrder(vehicle_id, order_id).
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   161
	 * @pre AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   162
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   163
	 * @return True if and only if the order was changed.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   164
	 */
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: 9707
diff changeset
   165
	static bool ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrderFlags order_flags);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   166
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   167
	/**
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   168
	 * Move an order inside the orderlist
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   169
	 * @param vehicle_id The vehicle to move the orders.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   170
	 * @param order_id_move The order to move.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   171
	 * @param order_id_target The target order
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   172
	 * @pre IsValidVehicleOrder(vehicle_id, order_id_move).
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   173
	 * @pre IsValidVehicleOrder(vehicle_id, order_id_target).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   174
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   175
	 * @return True if and only if the order was moved.
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   176
	 * @note If the order is moved to a lower place (e.g. from 7 to 2)
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   177
	 *  the target order is moved upwards (e.g. 3). If the order is moved
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   178
	 *  to a higher place (e.g. from 7 to 9) the target will be moved
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   179
	 *  downwards (e.g. 8).
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   180
	 */
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: 9707
diff changeset
   181
	static bool MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target);
9707
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   182
a5f233287295 (svn r11273) [NoAI] -Add: added AIOrder::MoveOrder (dynaxo)
truelight
parents: 9596
diff changeset
   183
	/**
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   184
	 * Copies the orders from another vehicle. The orders of the main vehicle
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   185
	 *  are going to be the orders of the changed vehicle.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   186
	 * @param vehicle_id The vehicle to copy the orders to.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   187
	 * @param main_vehicle_id The vehicle to copy the orders from.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   188
	 * @pre AIVehicle::IsValidVehicle(vehicle_id).
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   189
	 * @pre AIVehicle::IsValidVehicle(main_vehicle_id).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   190
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   191
	 * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   192
	 * @return True if and only if the copying succeeded.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   193
	 */
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: 9707
diff changeset
   194
	static bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   195
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   196
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   197
	 * Shares the orders between two vehicles. The orders of the main
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   198
	 * vehicle are going to be the orders of the changed vehicle.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   199
	 * @param vehicle_id The vehicle to add to the shared order list.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   200
	 * @param main_vehicle_id The vehicle to share the orders with.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   201
	 * @pre AIVehicle::IsValidVehicle(vehicle_id).
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   202
	 * @pre AIVehicle::IsValidVehicle(main_vehicle_id).
10093
b3849a19d137 (svn r12623) [NoAI] -Add: support for GetLastError in AIOrder.
rubidium
parents: 9838
diff changeset
   203
	 * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   204
	 * @return True if and only if the sharing succeeded.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   205
	 */
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: 9707
diff changeset
   206
	static bool ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   207
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   208
	/**
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   209
	 * Removes the given vehicle from a shared orders list.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   210
	 * @param vehicle_id The vehicle to remove from the shared order list.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   211
	 * @pre AIVehicle::IsValidVehicle(vehicle_id).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
   212
	 * @return True if and only if the unsharing succeeded.
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   213
	 */
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: 9707
diff changeset
   214
	static bool UnshareOrders(VehicleID vehicle_id);
9500
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   215
};
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   216
DECLARE_ENUM_AS_BIT_SET(AIOrder::AIOrderFlags);
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   217
d67653613da4 (svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff changeset
   218
#endif /* AI_ORDER_HPP */