From 3407b3edc0112ebae47c2a69359c36c6952a2b86 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 10 Feb 2024 23:07:11 +0000 Subject: [PATCH] Fix tile hash cache check warnings when loading very old savegames See: #648 --- src/aircraft_cmd.cpp | 2 +- src/saveload/afterload.cpp | 5 +++++ src/settings.cpp | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 08c9878821..6f646a9767 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1005,12 +1005,12 @@ static bool AircraftController(Aircraft *v) int z = GetSlopePixelZ(x, y) + 1 + afc->delta_z; if (z == v->z_pos) { + v->UpdatePosition(); Vehicle *u = v->Next()->Next(); /* Increase speed of rotors. When speed is 80, we've landed. */ if (u->cur_speed >= 80) { ClrBit(v->flags, VAF_HELI_DIRECT_DESCENT); - v->UpdatePosition(); return true; } u->cur_speed += 4; diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 8b2abf6a03..72a135a5f4 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1218,6 +1218,9 @@ bool AfterLoadGame() /* Force the freeform edges to false for old savegames. */ if (IsSavegameVersionBefore(SLV_111)) { _settings_game.construction.freeform_edges = false; + for (Vehicle *v : Vehicle::Iterate()) { + if (v->tile == 0) v->UpdatePosition(); + } } /* From version 9.0, we update the max passengers of a town (was sometimes negative @@ -2960,10 +2963,12 @@ bool AfterLoadGame() if (dir == vdir) { // Entering tunnel hidden = frame >= _tunnel_visibility_frame[dir]; v->tile = vtile; + v->UpdatePosition(); } else if (dir == ReverseDiagDir(vdir)) { // Leaving tunnel hidden = frame < TILE_SIZE - _tunnel_visibility_frame[dir]; /* v->tile changes at the moment when the vehicle leaves the tunnel. */ v->tile = hidden ? GetOtherTunnelBridgeEndOld(vtile) : vtile; + v->UpdatePosition(); } else { /* We could get here in two cases: * - for road vehicles, it is reversing at the end of the tunnel diff --git a/src/settings.cpp b/src/settings.cpp index f5250bf2ca..cd048b1036 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1678,6 +1678,9 @@ static void UpdateFreeformEdges(int32_t new_value) MakeSea(TileXY(0, i)); } } + for (Vehicle *v : Vehicle::Iterate()) { + if (v->tile == 0) v->UpdatePosition(); + } MarkWholeScreenDirty(); }