Home › Engine executable › Game start, save and load sequence
Engine executable. Settings and tools of the game program (CivilizationVI.exe), usable without a mod. Mostly undocumented debug and configuration functionality; descriptions come from analysis of the executable and have not all been tried in the running game.
Game start, save and load sequence
When a game starts (a new game or a loaded save) the exe runs one state machine, LoadGameViewState::LaunchNextStage (0x84870), and writes its progress to LoadGameViewState.log (see the files page). This page lists its states in the order the code reaches them, the log lines each state writes (useful to read a load log), the steps of the game state loader, the flags of a save location and the keys of the save metadata. Verified: state numbers, assigned next states, log texts and names (decompiled code and strings). Inferred: the conditions behind a transition and the meaning of state 8 and the failure state 11, which were not analysed.
Flow. New game: 0 -> 1 -> 2 -> 3 -> 6 -> 8. Loading a save: 0 -> 1 -> 4 -> 5 -> 2 -> 3 -> 7. State 11 is the failure exit used by most states.
States
| State |
Name |
Next |
Log lines it writes |
Timed steps |
What it does |
| 0 |
Start |
1 |
— |
— |
Entry: moves on to state 1 (to state 11, the failure state, when the start fails). |
| 1 |
Decide: load a save or start new |
2 or 4 |
— |
— |
Asks the serializer for the request type (function 0x167ce0): when the result is 2 (inferred: a saved game is to be loaded) the next state is 4, otherwise 2. |
| 2 |
Configure Content |
3 |
CONFIGURE_CONTENT Begin, CONFIGURE_CONTENT took ... |
Restarting asset load |
Stage label Stage: Configure Content. Configure Content: the game content is configured and the asset load restarted; then state 3 (11 on failure). |
| 3 |
Set gameplay logging |
6 or 7 |
— |
— |
Reads the gameplay logging options (listed below), then goes to 6 (new game) or 7 (unserialize a game state): the value is (x != 0) + 6 for a pointer x read in this state (inferred: whether a saved game stream was loaded). |
| 4 |
Load a save file |
5 |
GAMECORE_LOAD_SAVEFILE Begin, GAMECORE_LOAD_SAVEFILE took ... |
— |
Stage label Stage: Loading a save. Loads the save file, then state 5 (11 on failure). |
| 5 |
Save load pending (apply mod state) |
2 |
GAMECORE_LOAD_SAVEFILE_PENDING Begin |
ApplyModdingState |
Save load pending: when done the mod state is applied (ApplyModdingState) and the sequence continues with Configure Content (state 2); 11 on failure. |
| 6 |
New game |
8 |
GAMECORE_NEW_GAME Begin |
Block on asset load, InitializeNewGame |
Starts a new game (InitializeNewGame), records the StartupGameTimings numbers, goes to state 8; 11 on failure. |
| 7 |
Unserialize game state |
(not read) |
GAMECORE_UNSERIALIZE_GAMESTATE Begin |
Unserialize, InitializeCache, PostGameInitialization, PostInitialize |
Stage label Stage: Unserializing Game State. Unserializes the game state, initialises the cache, runs post-initialisation and records the timings; the successor state was not read out. |
Each block logs <NAME> Begin and <NAME> took N seconds with a timestamp prefix; sub-steps are logged as ,<step> took N seconds. The times of new-game and load runs are also recorded under Timings / StartupGameTimings (keys Session, InitializeNewGame, PostLoad).
Game state loader steps
GameCore::Serializer::Manager::UnserializeGameState (0x16e340) logs "<step> - Complete" in this order:
| # |
Step |
| 1 |
LoadHeader |
| 2 |
AttachToSession |
| 3 |
LoadGameCoreState |
| 4 |
LoadAudioState |
| 5 |
LoadUIState |
| 6 |
LoadRecorderState |
Gameplay logging options read in state 3
Switches of the Gameplay section of UserOptions.txt that are applied before the game starts; the second column is the log id the exe passes along.
| Option |
Log id |
GameHistoryLogLevel |
HISTORY_LOGGING_ID |
GameHistorySequentialLogLevel |
HISTORY_LOGGING_SEQUENTIAL_ID |
AI_MasterLogging |
AI_MASTER_LOGGING |
AICityBuildPlotLog |
CITY_PLOT_ANALYSIS_LOG_ID |
GameEraMomentsLog |
GAME_ERA_MOMENTS_LOG_ID |
AISettlementEvaluationLog |
PLAYER_SETTLEMENT_ANALYSIS_LOG_ID |
AiDiplomaticActionLog |
DIPLOMATIC_ACTION_LOG_ID |
AIOperationEvalLog |
AI_OPERATION_EVAL |
ProfileEnabled |
CACHE_PERF_LOGGING |
GameEffectsLogLevel |
— |
Save location flags
Fields of the table GetSaveLocation builds for a save location (0x168310): AccountReference, IsDirectory, IsAutosave, IsQuicksave, IsPrevious.
Save metadata
A save carries a MetaData table of name and value rows (INSERT INTO MetaData (Name, Value) VALUES (?,?)). The keys the exe writes or reads by name:
| Key |
Meaning |
Function |
MetaDataVersion |
Version of the save metadata layout (written by SaveMetaData). |
SaveMetaData (0x16d500) |
AppVersion |
Game version, written as "%d.%d.%d.%d (%d)" from the application version fields. |
SaveMetaData (0x16d500) |
DisplayName |
Display name of the save. |
SaveMetaData (0x16d500) |
IsMod |
Read back by ApplyModdingState (SELECT Value from MetaData where Name = 'IsMod'): whether the game was started with mods. |
ApplyModdingState (0x1639b0) |
When a save is applied, ApplyModdingState also reads the save's Players (CivilizationType), ModDependencies (ID, Title), StartPositions (Type, Value) and MapAttributes (Name = Ruleset) tables; see the database statements.