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

Also available in: Atom PDF