diff options
author | rubidium <rubidium@openttd.org> | 2009-01-04 15:53:43 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-01-04 15:53:43 +0000 |
commit | e557c88667206f9db5c8ed5958d2ca0279aefa87 (patch) | |
tree | 477f1fe69eee3708626efee298ca9d92dac76b91 /src | |
parent | 9658c83a338562eb7c5dd8b8653af194440a55cc (diff) | |
download | openttd-e557c88667206f9db5c8ed5958d2ca0279aefa87.tar.xz |
(svn r14830) -Fix [FS#2495]: overflow of number of orders per vehicle (based on patch by Swallow)
Diffstat (limited to 'src')
-rw-r--r-- | src/order_cmd.cpp | 1 | ||||
-rw-r--r-- | src/order_type.h | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 4686a564d..a14468b07 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -567,6 +567,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, c if (sel_ord > v->GetNumOrders()) return CMD_ERROR; + if (v->GetNumOrders() >= MAX_VEH_ORDER_ID) return_cmd_error(STR_8832_TOO_MANY_ORDERS); if (!Order::CanAllocateItem()) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS); if (v->orders.list == NULL && !OrderList::CanAllocateItem()) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS); diff --git a/src/order_type.h b/src/order_type.h index 55653b825..0a43dc8f7 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -12,10 +12,12 @@ typedef uint16 OrderID; typedef uint16 OrderListID; typedef uint16 DestinationID; -enum { - INVALID_VEH_ORDER_ID = 0xFF, -}; +/** Invalid vehicle order index (sentinel) */ +static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF; +/** Last valid VehicleOrderID. */ +static const VehicleOrderID MAX_VEH_ORDER_ID = INVALID_VEH_ORDER_ID - 1; +/** Invalid order (sentinel) */ static const OrderID INVALID_ORDER = 0xFFFF; /* Order types */ |