mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-21 06:34:23 +00:00
(svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
This commit is contained in:
parent
9a73b698d4
commit
4f0bfa91ab
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user