author | rubidium |
Mon, 26 Mar 2007 12:58:47 +0000 | |
branch | noai |
changeset 9548 | 9f9f003dd9b5 |
parent 9547 | baf86d35646a |
child 9594 | 5009a30f320a |
permissions | -rw-r--r-- |
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 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
3 |
/** @file ai_order.hpp Everything to query and build Orders */ |
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" |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
9 |
|
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 |
* Class that handles all order related functions. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
12 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
13 |
class AIOrder : public AIObject { |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
14 |
public: |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
15 |
/** |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
16 |
* The name of the class, needed by several sub-processes. |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
17 |
*/ |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
18 |
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
|
19 |
|
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
20 |
/** |
9500
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
21 |
* Flags that can be used to modify the behaviour of orders. |
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 |
enum AIOrderFlags { |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
24 |
/** 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
|
25 |
AIOF_NONE = 0, |
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 |
/** Transfer instead of deliver the goods; only for stations. */ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
28 |
AIOF_TRANSFER = 1 << 0, |
9548
9f9f003dd9b5
(svn r9479) [NoAI] -Fix: AIOrder::ChangeOrder didn't work as expected, or rather CMD_MODIFY_ORDER didn't.
rubidium
parents:
9547
diff
changeset
|
29 |
/** Always unload the vehicle; only for stations. Cannot be set when AIOF_FULL_LOAD is set. */ |
9500
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
30 |
AIOF_UNLOAD = 1 << 1, |
9548
9f9f003dd9b5
(svn r9479) [NoAI] -Fix: AIOrder::ChangeOrder didn't work as expected, or rather CMD_MODIFY_ORDER didn't.
rubidium
parents:
9547
diff
changeset
|
31 |
/** Wait till the the vehicle is fully loaded; only for stations. Cannot be set when AIOF_UNLOAD is set. */ |
9500
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
32 |
AIOF_FULL_LOAD = 1 << 2, |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
33 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
34 |
/** 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
|
35 |
AIOF_SERVICE_IF_NEEDED = 1 << 2, |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
36 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
37 |
/** Do not stop at the stations that are passed when going to the destination. */ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
38 |
AIOF_NON_STOP = 1 << 3, |
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 |
/** For marking invalid order flags */ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
41 |
AIOF_INVALID = 0xFFFF, |
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 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
45 |
* Checks whether the given order id is valid for the given vehicle. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
46 |
* @param vehicle_id the vehicle to check the order index for. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
47 |
* @param order_id the order index to check. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
48 |
* @pre AIVehicle::IsValidVehicle(vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
49 |
* @return true if and only if the order_id is valid for the given vehicle. |
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 |
static bool IsValidVehicleOrder(VehicleID vehicle_id, uint32 order_id); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
52 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
53 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
54 |
* Checks whether the given order flags are valid for the given destination. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
55 |
* @param destination the destination of the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
56 |
* @param order_flags the flags given to the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
57 |
* @return true if and only if the order_flags are valid for the given location. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
58 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
59 |
static bool AreOrderFlagsValid(TileIndex destination, AIOrderFlags order_flags); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
60 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
61 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
62 |
* Returns the number of orders for the given vehicle. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
63 |
* @param vehicle_id the vehicle to get the order count of. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
64 |
* @pre AIVehicle::IsValidVehicle(vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
65 |
* @return the number of orders for the given vehicle or a negative |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
66 |
* value when the vehicle does not exist. |
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 |
int32 GetNumberOfOrders(VehicleID vehicle_id); |
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 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
71 |
* Gets the destination of the given order for the given vehicle. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
72 |
* @param vehicle_id the vehicle to get the destination for. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
73 |
* @param order_id the order to get the destination for. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
74 |
* @pre IsValidVehicleOrder(vehicle_id, order_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
75 |
* @return the destination tile of the order. |
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 |
TileIndex GetOrderDestination(VehicleID vehicle_id, uint32 order_id); |
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 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
80 |
* Gets the AIOrderFlags of the given order for the given vehicle. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
81 |
* @param vehicle_id the vehicle to get the destination for. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
82 |
* @param order_id the order to get the destination for. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
83 |
* @pre IsValidVehicleOrder(vehicle_id, order_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
84 |
* @return the AIOrderFlags of the order. |
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 |
AIOrderFlags GetOrderFlags(VehicleID vehicle_id, uint32 order_id); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
87 |
|
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 |
* Appends an order to the end of the vehicle's order list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
90 |
* @param vehicle_id the vehicle to append the order to. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
91 |
* @param destination the destination of the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
92 |
* @param order_flags the flags given to the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
93 |
* @pre AIVehicle::IsValidVehicle(vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
94 |
* @pre AreOrderFlagsValid(destination, order_flags). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
95 |
* @return true if and only if the order was appended. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
96 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
97 |
bool AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags); |
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 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
100 |
* Inserts an order before the given order_id into the vehicle's order list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
101 |
* @param vehicle_id the vehicle to add the order to. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
102 |
* @param order_id the order to place the new order before. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
103 |
* @param destination the destination of the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
104 |
* @param order_flags the flags given to the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
105 |
* @pre IsValidVehicleOrder(vehicle_id, order_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
106 |
* @pre AreOrderFlagsValid(destination, order_flags). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
107 |
* @return true if and only if the order was inserted. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
108 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
109 |
bool InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrderFlags order_flags); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
110 |
|
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 |
* Removes an order from the vehicle's order list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
113 |
* @param vehicle_id the vehicle to remove the order from. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
114 |
* @param order_id the order to remove from the order list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
115 |
* @pre AIVehicle::IsValidVehicleOrder(vehicle_id, order_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
116 |
* @return true if and only if the order was removed. |
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 |
bool RemoveOrder(VehicleID vehicle_id, uint32 order_id); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
119 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
120 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
121 |
* Changes the order flags of the given order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
122 |
* @param vehicle_id the vehicle to change the order of. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
123 |
* @param order_id the order to change. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
124 |
* @param order_flags the new flags given to the order. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
125 |
* @pre IsValidVehicleOrder(vehicle_id, order_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
126 |
* @pre AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
127 |
* @return true if and only if the order was changed. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
128 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
129 |
bool ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrderFlags order_flags); |
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 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
132 |
* Copies the orders from another vehicle. The orders of the main |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
133 |
* vehicle are going to be the orders of the changed vehicle. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
134 |
* @param vehicle_id the vehicle to copy the orders to. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
135 |
* @param main_vehicle_id the vehicle to copy the orders from. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
136 |
* @pre AIVehicle::IsValidVehicle(vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
137 |
* @pre AIVehicle::IsValidVehicle(main_vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
138 |
* @return true if and only if the copying succeeded. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
139 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
140 |
bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
141 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
142 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
143 |
* Shares the orders between two vehicles. The orders of the main |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
144 |
* vehicle are going to be the orders of the changed vehicle. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
145 |
* @param vehicle_id the vehicle to add to the shared order list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
146 |
* @param main_vehicle_id the vehicle to share the orders with. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
147 |
* @pre AIVehicle::IsValidVehicle(vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
148 |
* @pre AIVehicle::IsValidVehicle(main_vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
149 |
* @return true if and only if the sharing succeeded. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
150 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
151 |
bool ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
152 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
153 |
/** |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
154 |
* Removes the given vehicle from a shared orders list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
155 |
* @param vehicle_id the vehicle to remove from the shared order list. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
156 |
* @pre AIVehicle::IsValidVehicle(vehicle_id). |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
157 |
* @return true if and only if the unsharing succeeded. |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
158 |
*/ |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
159 |
bool UnshareOrders(VehicleID vehicle_id); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
160 |
}; |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
161 |
DECLARE_ENUM_AS_BIT_SET(AIOrder::AIOrderFlags); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
162 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
163 |
#ifdef DEFINE_SQUIRREL_CLASS |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9501
diff
changeset
|
164 |
namespace SQConvert { |
9524
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9521
diff
changeset
|
165 |
/* Allow enums to be used as Squirrel parameters */ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9501
diff
changeset
|
166 |
template <> AIOrder::AIOrderFlags GetParam(ForceType<AIOrder::AIOrderFlags>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIOrder::AIOrderFlags)tmp; } |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9501
diff
changeset
|
167 |
template <> int Return<AIOrder::AIOrderFlags>(HSQUIRRELVM vm, AIOrder::AIOrderFlags res) { sq_pushinteger(vm, (int32)res); return 1; } |
9524
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9521
diff
changeset
|
168 |
|
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9521
diff
changeset
|
169 |
/* Allow AIOrder to be used as Squirrel parameter */ |
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9521
diff
changeset
|
170 |
template <> AIOrder *GetParam(ForceType<AIOrder *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIOrder *)instance; } |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9501
diff
changeset
|
171 |
}; // namespace SQConvert |
9501
15689f09d1f5
(svn r9375) [NoAI] -Fix r9374: make AIOrder() work for SQ (enums not yet)
truelight
parents:
9500
diff
changeset
|
172 |
|
9500
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
173 |
void SQAIOrderRegister(Squirrel *engine) { |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
174 |
DefSQClass <AIOrder> SQAIOrder("AIOrder"); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
175 |
SQAIOrder.PreRegister(engine); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
176 |
SQAIOrder.AddConstructor(engine); |
9525
1d6c509b56ee
(svn r9445) [NoAI] -Change: changed from sq_createslot to sq_newslot (first is deprecated)
truelight
parents:
9524
diff
changeset
|
177 |
|
9547
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
178 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_NONE, "AIOF_NONE"); |
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
179 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_TRANSFER, "AIOF_TRANSFER"); |
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
180 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_UNLOAD, "AIOF_UNLOAD"); |
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
181 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_FULL_LOAD, "AIOF_FULL_LOAD"); |
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
182 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_SERVICE_IF_NEEDED, "AIOF_SERVICE_IF_NEEDED"); |
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
183 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_NON_STOP, "AIOF_NON_STOP"); |
baf86d35646a
(svn r9478) [NoAI] -Codechange: back in the days that DefSQMethod was called DefSQFunction, DefSQConst has a few spaces to align everything... aligning them now means adding way too much spaces, thus remove the alignment.
rubidium
parents:
9541
diff
changeset
|
184 |
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_INVALID, "AIOF_INVALID"); |
9525
1d6c509b56ee
(svn r9445) [NoAI] -Change: changed from sq_createslot to sq_newslot (first is deprecated)
truelight
parents:
9524
diff
changeset
|
185 |
|
9541
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
186 |
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetClassName, "GetClassName", 1, "x"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
187 |
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, "xii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
188 |
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, "xii"); |
9532
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9530
diff
changeset
|
189 |
|
9541
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
190 |
SQAIOrder.DefSQMethod(engine, &AIOrder::GetNumberOfOrders, "GetNumberOfOrders", 2, "xi"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
191 |
SQAIOrder.DefSQMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, "xii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
192 |
SQAIOrder.DefSQMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, "xii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
193 |
SQAIOrder.DefSQMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, "xiii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
194 |
SQAIOrder.DefSQMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, "xiiii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
195 |
SQAIOrder.DefSQMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, "xii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
196 |
SQAIOrder.DefSQMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, "xiii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
197 |
SQAIOrder.DefSQMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, "xii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
198 |
SQAIOrder.DefSQMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, "xii"); |
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
199 |
SQAIOrder.DefSQMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, "xi"); |
9526
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
9525
diff
changeset
|
200 |
|
9500
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
201 |
SQAIOrder.PostRegister(engine); |
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
202 |
} |
9520
f7cf8bea10db
(svn r9440) [NoAI] -Codechange: use the identifier used for the #ifdef in the #endif not something that looks like the identifier.
rubidium
parents:
9510
diff
changeset
|
203 |
#endif /* DEFINE_SQUIRREL_CLASS */ |
9500
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
204 |
|
d67653613da4
(svn r9374) [NoAI] -Add: functionality to modify orders.
rubidium
parents:
diff
changeset
|
205 |
#endif /* AI_ORDER_HPP */ |