From 3d2a561c808eca6600ded3a059eecfa4dc7ed009 Mon Sep 17 00:00:00 2001
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Date: Fri, 13 Nov 2026 22:24:15 -0800
Subject: [PATCH] sg_save_player_cities(): Do not refresh cities

Cities are refreshed lazily, so between refreshes some of their derived
values can be out of date. Saving refreshed every city, so a game that
autosaves played on with different values than the same game without
saves, and the two games diverged.

The sanity check itself does not need the refresh, and the loader
refreshes every city it reads.

See RM #2480

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
 server/savegame/savegame3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c
index 07450b0555..3b14ada5b4 100644
--- a/server/savegame/savegame3.c
+++ b/server/savegame/savegame3.c
@@ -5723,8 +5723,8 @@ static void sg_save_player_cities(struct savedata *saving,
   city_list_iterate(plr->cities, pcity) {
     int routes;
 
-    /* Check the sanity of the city. */
-    city_refresh(pcity);
+    /* Check the sanity of the city. Do not city_refresh() it first:
+     * saving must not change the game state. */
     sanity_check_city(pcity);
 
     if (pcity->worklist.length > wlist_max_length) {
-- 
2.55.0

