summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-13 19:46:26 +0000
committerrubidium <rubidium@openttd.org>2008-04-13 19:46:26 +0000
commit4f0bfa91ab9af4d0ff53f8cebf6890f25563a563 (patch)
tree00f00886228a39126d927de52a704a9f9e33b28c /src
parent9a73b698d4045fcf19a46193cecde62bb9626bae (diff)
downloadopenttd-4f0bfa91ab9af4d0ff53f8cebf6890f25563a563.tar.xz
(svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
Diffstat (limited to 'src')
-rw-r--r--src/openttd.cpp65
-rw-r--r--src/order_cmd.cpp4
2 files changed, 35 insertions, 34 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 13edd2423..3d138d7f7 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -2301,6 +2301,40 @@ bool AfterLoadGame()
}
}
+
+ if (CheckSavegameVersion(93)) {
+ /* Rework of orders. */
+ Order *order;
+ FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame();
+
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (v->orders != NULL && !v->orders->IsValid()) v->orders = NULL;
+
+ v->current_order.ConvertFromOldSavegame();
+ if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->prev_shared == NULL) {
+ FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ }
+ }
+ } else if (CheckSavegameVersion(94)) {
+ /* Unload and transfer are now mutual exclusive. */
+ Order *order;
+ FOR_ALL_ORDERS(order) {
+ if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
+ order->SetUnloadType(OUFB_TRANSFER);
+ order->SetLoadType(OLFB_NO_LOAD);
+ }
+ }
+
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
+ v->current_order.SetUnloadType(OUFB_TRANSFER);
+ v->current_order.SetLoadType(OLFB_NO_LOAD);
+ }
+ }
+ }
+
if (CheckSavegameVersion(84)) {
/* Update go to buoy orders because they are just waypoints */
Order *order;
@@ -2445,37 +2479,6 @@ bool AfterLoadGame()
}
}
- if (CheckSavegameVersion(93)) {
- /* Rework of orders. */
- Order *order;
- FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame();
-
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- v->current_order.ConvertFromOldSavegame();
- if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->prev_shared == NULL) {
- FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
- }
- }
- } else if (CheckSavegameVersion(94)) {
- /* Unload and transfer are now mutual exclusive. */
- Order *order;
- FOR_ALL_ORDERS(order) {
- if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
- order->SetUnloadType(OUFB_TRANSFER);
- order->SetLoadType(OLFB_NO_LOAD);
- }
- }
-
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
- v->current_order.SetUnloadType(OUFB_TRANSFER);
- v->current_order.SetLoadType(OLFB_NO_LOAD);
- }
- }
- }
-
return InitializeWindowsAndCaches();
}
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 1929760c3..ccb104d2a 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -216,9 +216,7 @@ Order UnpackOldOrder(uint16 packed)
* Sanity check
* TTD stores invalid orders as OT_NOTHING with non-zero flags/station
*/
- if (!order.IsValid() && (order.GetLoadType() != 0 || order.GetUnloadType() != 0 || order.GetDestination() != 0)) {
- order.MakeDummy();
- }
+ if (!order.IsValid() && packed != 0) order.MakeDummy();
return order;
}