Project

General

Profile

Actions

Bug #2480

closed

sg_save_player_cities() refreshes cities, so saving changes the game

Added by Sweet Tea Dorminy 14 days ago. Updated 1 day ago.

Status:
Closed
Priority:
Normal
Category:
Server
Target version:
Start date:
11/14/2026
Due date:
% Done:

0%

Estimated time:

Description

sg_save_player_cities() calls city_refresh() on every city before sanity_check_city(). Cities are otherwise refreshed lazily, so a game that autosaves plays on with different values than the same game without saves, and the two diverge.

The sanity check doesn't need the refresh, and the loader refreshes every city anyway. Attached patch drops it; it applies to main, S3_3 and S3_2.

Repro: AI-only game twice, once as is and once with "set autosaves GAMEOVER" in place of the autosaves and saveturns lines, and compare the "data" lines of the two scorelogs:

rulesetdir classic
set minplayers 0
set timeout -1
set topology ISO
set mapsize PLAYER
set tilesperplayer 400
set aifill 6
hard
set endturn 150
set autosaves "TURN|GAMEOVER" 
set saveturns 10
set scorelog enabled
set scoreloglevel ALL
set scorefile scorelog.txt
set gameseed 411
set mapseed 411
start

On main (cc1260068c) the two scorelogs are identical through turn 100 and differ from turn 101, right after the turn 100 autosave (player 0 mfg 85 vs 88). With the patch they are identical to turn 150, and the game without saves is unchanged by the patch.

There are some other indeterminacies I haven't tracked down yet, and this seems low priority imho, but it's harder to tweak things when the seeds don't always have the same result :)


Files

Actions #1

Updated by Marko Lindqvist 13 days ago

  • Category set to Server
  • Status changed from New to In Review
  • Assignee set to Marko Lindqvist
  • Priority changed from Low to Normal
  • Target version set to 3.2.8

Sweet Tea Dorminy wrote:

but it's harder to tweak things when the seeds don't always have the same result :)

Or debug! This likely explains some of my failures to repro issues reported by the autogame stress tester.

Actions #2

Updated by Marko Lindqvist 6 days ago

  • Target version changed from 3.2.8 to 3.3.0-beta1

There a risk, albeit small, that some code path allows saving while city is in the middle of a change and thus in inconsistent state, leading to sanity check errors without the refresh -> maybe we shouldn't target this to S3_2.

Actions #3

Updated by Dean Brown 6 days ago

I have also seen this happen - when replaying a saved game I get different outcomes at the end if another "save game as..." has been done.

Actions #4

Updated by Marko Lindqvist 1 day ago

  • Status changed from In Review to Closed
Actions

Also available in: Atom PDF