Mercurial > hg > openttd
diff src/openttd.cpp @ 8926:9999383297b8 draft
(svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 13 Apr 2008 19:46:26 +0000 (2008-04-13) |
parents | f15d5f7bf51b |
children | 454ba10a0cff |
line wrap: on
line diff
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2301,6 +2301,40 @@ } } + + 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 @@ } } - 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(); }