Repository navigation
OpenCiv4's own autosaves: each game its own name again after a load - #191
Open
MortenLyhr wants to merge 2 commits into
Open
MortenLyhr wants to merge 2 commits into
MortenLyhr wants to merge 2 commits into
Conversation
OpenCiv4's own autosaves are named AutoSave_<civilization>_<game>_<n>, so that each game keeps its own. After a load both parts were empty: the init core's civilization name is empty unless the player typed one, and its map seed is not in a save (CvInitCore::read/write). So every loaded game shared AutoSave__00000000_<n> and overwrote the others' (seen in the user's play sessions 2026-11-25/26, oc4core's log). The civilization now comes from CvPlayer::getCivilizationShortDescription (the init core's name, else the civilization's), and the game from a hash of the map's plot types, which a save keeps and nothing in BtS changes. This is OpenCiv4's own naming, not the original's: no rule of the original is involved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CvPlot::getPlotType and GET_PLAYER's inline player array are not exported from the Windows game core (LNK2001 on bssth#191's windows-x64). The plot type now comes from the exported isPeak/isHills/isWater, numbered as PlotTypes numbers them, so the hash is unchanged; the player from CvPlayerAI::getPlayerNonInl. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it changes
OpenCiv4 saves a game played by hand at each turn's start, in
Documents\My Games\openciv4\Saves\auto, ten in turn, asAutoSave_<civilization>_<game>_<n>(master'smain.cpp). The civilization and the game are in the name so that each game keeps its own files. This is OpenCiv4's own naming: no rule of the original is involved, and the original's autosaves are not touched.Before: after a load both parts of the name were empty, and every loaded game was saved as
AutoSave__00000000_<n>, over the others' files. Seen in the user's play sessions of 2026-11-25 and 26 (oc4core's log:autosaved turn 173: …/Saves/auto/AutoSave__00000000_3.CivBeyondSwordSave).getCivShortDesc, which is empty unless the player typed a name.getMapRandSeed. A save doesn't hold it (CvInitCore::read/writein the SDK have no seed), so after a load it is 0.Now (
apps/oc4core/AutoSaveStem.h, used bymain.cpp):CvPlayer::getCivilizationShortDescription: the init core's name, else the civilization's own short name, as the game shows it. Anything but letters and digits becomes_, as before.The save format doesn't change: only the file's name does.
What it is based on
CvInitCore::read/write(no map seed saved),CvPlayer::getCivilizationShortDescription,CvPlot::getPlotType.How it was checked
strings/dumpbin/objdump), and nothing here comes from someone else's (CONTRIBUTING)ctest --test-dir build\Releasepasses: 15/15 (macOS arm64 build of this branch on master)--turns 100 --map Fractal --size STANDARD --seed 7givesD7D43800at turn 100 on this branch, the same as masterAutosaves are made only in a game played by hand, so an AI autoplay doesn't run this code.
Julius Caesar BC-0250loaded and a turn played wroteAutoSave_Rome_EF6DCD01_1. The same hash, computed again in Python from that save's plots, isEF6DCD01. Two saves of another game,Julius Caesar AD-1020andAD-1110, both give4D3A7092.Not done / not checked:
setPlotTypeis otherwise called only while the map is made (CvMapGenerator,CvGame::normalize…) and byCvPlot::setTerrainTypewhen land turns to water or back. Whether a mod or scenario script does that in play was not checked.AutoSave__00000000_*files are left as they are.<stem>_turn<N>) uses the same stem and was not looked at separately.🤖 Generated with Claude Code