summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-01-16 14:42:53 +0000
committertruelight <truelight@openttd.org>2005-01-16 14:42:53 +0000
commit07647737d5d52cb548662ffbec4eca3514090b18 (patch)
tree6a56912dfd4ec0a7d3c46aa7b8cd50edb2d28031
parent8493f68c96d9dbc4deaf0dac53c80a04511a2b70 (diff)
downloadopenttd-07647737d5d52cb548662ffbec4eca3514090b18.tar.xz
(svn r1544) -Fix: SwapOrder did not use AssignOrder, which caused the saveroutine to
crash from time to time -Codechange: added const before 'Order *' where possible
-rw-r--r--ai.c2
-rw-r--r--aircraft_cmd.c2
-rw-r--r--order.h2
-rw-r--r--order_cmd.c6
-rw-r--r--order_gui.c2
5 files changed, 8 insertions, 6 deletions
diff --git a/ai.c b/ai.c
index 8ae388dc4..6881d7e2a 100644
--- a/ai.c
+++ b/ai.c
@@ -3609,7 +3609,7 @@ static void AiStateRemoveStation(Player *p)
{
// Remove stations that aren't in use by any vehicle
byte in_use[256], *used;
- Order *ord;
+ const Order *ord;
Station *st;
uint tile;
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index d13af1a41..4f61d21a7 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -1023,7 +1023,7 @@ static void HandleAircraftSmoke(Vehicle *v)
static void ProcessAircraftOrder(Vehicle *v)
{
- Order *order;
+ const Order *order;
// OT_GOTO_DEPOT, OT_LOADING
if (v->current_order.type == OT_GOTO_DEPOT ||
diff --git a/order.h b/order.h
index dc7da1fa7..07fd95e4a 100644
--- a/order.h
+++ b/order.h
@@ -74,7 +74,7 @@ static inline Order *GetOrder(uint index)
static inline bool HasOrderPoolFree(uint amount)
{
- Order *order;
+ const Order *order;
FOR_ALL_ORDERS(order)
if (order->type == OT_NOTHING)
diff --git a/order_cmd.c b/order_cmd.c
index 1e074bcd4..3a40e2241 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -67,8 +67,10 @@ static void SwapOrders(Order *order1, Order *order2)
Order temp_order;
temp_order = *order1;
- *order1 = *order2;
- *order2 = temp_order;
+ AssignOrder(order1, *order2);
+ order1->next = order2->next;
+ AssignOrder(order2, temp_order);
+ order2->next = temp_order.next;
}
/**
diff --git a/order_gui.c b/order_gui.c
index ca2c3be0a..5c99bb557 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -387,7 +387,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
sel += w->vscroll.pos;
if (_ctrl_pressed && sel < v->num_orders) {
- Order *ord = GetVehicleOrder(v, sel);
+ const Order *ord = GetVehicleOrder(v, sel);
int xy = 0;
switch (ord->type) {
case OT_GOTO_STATION: /* station order */