mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r6145) -Codechange: added OrderID to indicate Order indexes out of the pool
This commit is contained in:
parent
39ae8d29e1
commit
c6f4f95438
|
@ -41,6 +41,7 @@ typedef uint16 TownID;
|
||||||
typedef uint16 IndustryID;
|
typedef uint16 IndustryID;
|
||||||
typedef uint16 DepotID;
|
typedef uint16 DepotID;
|
||||||
typedef uint16 WaypointID;
|
typedef uint16 WaypointID;
|
||||||
|
typedef uint16 OrderID;
|
||||||
typedef byte PlayerID;
|
typedef byte PlayerID;
|
||||||
typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
|
typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
|
||||||
typedef byte CargoID;
|
typedef byte CargoID;
|
||||||
|
|
4
order.h
4
order.h
|
@ -82,7 +82,7 @@ typedef struct Order {
|
||||||
|
|
||||||
struct Order *next; ///< Pointer to next order. If NULL, end of list
|
struct Order *next; ///< Pointer to next order. If NULL, end of list
|
||||||
|
|
||||||
uint16 index; ///< Index of the order, is not saved or anything, just for reference
|
OrderID index; ///< Index of the order, is not saved or anything, just for reference
|
||||||
} Order;
|
} Order;
|
||||||
|
|
||||||
#define MAX_BACKUP_ORDER_COUNT 40
|
#define MAX_BACKUP_ORDER_COUNT 40
|
||||||
|
@ -103,7 +103,7 @@ extern MemoryPool _order_pool;
|
||||||
/**
|
/**
|
||||||
* Get the pointer to the order with index 'index'
|
* Get the pointer to the order with index 'index'
|
||||||
*/
|
*/
|
||||||
static inline Order *GetOrder(uint index)
|
static inline Order *GetOrder(OrderID index)
|
||||||
{
|
{
|
||||||
return (Order*)GetItemFromPool(&_order_pool, index);
|
return (Order*)GetItemFromPool(&_order_pool, index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ static Order *AllocateOrder(void)
|
||||||
* TODO - This is just a temporary stage, this will be removed. */
|
* TODO - This is just a temporary stage, this will be removed. */
|
||||||
for (order = GetOrder(0); order != NULL; order = (order->index + 1 < GetOrderPoolSize()) ? GetOrder(order->index + 1) : NULL) {
|
for (order = GetOrder(0); order != NULL; order = (order->index + 1 < GetOrderPoolSize()) ? GetOrder(order->index + 1) : NULL) {
|
||||||
if (!IsValidOrder(order)) {
|
if (!IsValidOrder(order)) {
|
||||||
uint index = order->index;
|
OrderID index = order->index;
|
||||||
|
|
||||||
memset(order, 0, sizeof(*order));
|
memset(order, 0, sizeof(*order));
|
||||||
order->index = index;
|
order->index = index;
|
||||||
|
|
Loading…
Reference in New Issue