187 const std::filesystem::path& file);
197 std::uint64_t world_seed,
199 std::int64_t playtime_seconds);
208 const std::filesystem::path& file,
int backups);
215 static int countBackups(
const std::filesystem::path& file);
218 static std::vector<SaveBackup>
listBackups(
const std::filesystem::path& file);
232 const std::filesystem::path& backup);
235 static void deleteSave(
const std::filesystem::path& file);
240 int last_autosave_season,
242 bool managed_match_yesterday);
244 static std::filesystem::path
backupPath(
const std::filesystem::path& file,
246 static std::filesystem::path
tempPath(
const std::filesystem::path& file);
Manages the SQLite database connection and transaction lifecycle.
Definition database_connection.h:24
Exception thrown for database-related errors.
Definition database_exception.h:19
Definition save_manager.h:62
SaveError error
Definition save_manager.h:65
Definition save_manager.h:161
static void preserveBeforeMigration(const std::filesystem::path &file, int schema_version)
Definition save_manager.cpp:567
std::function< void(FaultPoint, sqlite3 *temp_db)> FaultHook
Definition save_manager.h:171
static SaveTimings persist(const DatabaseConnection &working, const std::filesystem::path &file, int backups)
Definition save_manager.cpp:543
static std::shared_ptr< DatabaseConnection > createWorkingCopy()
Definition save_manager.cpp:491
static int countBackups(const std::filesystem::path &file)
Definition save_manager.cpp:578
static void restoreBackup(const std::filesystem::path &file, const std::filesystem::path &backup)
Definition save_manager.cpp:632
static std::shared_ptr< DatabaseConnection > openWorkingCopy(const std::filesystem::path &file)
Definition save_manager.cpp:496
static std::vector< SaveBackup > listBackups(const std::filesystem::path &file)
Definition save_manager.cpp:586
static bool isAutosaveDue(AutosaveFrequency frequency, const GameDateValue &last_autosave, int last_autosave_season, const GameDateValue &today, int season, bool managed_match_yesterday)
Definition save_manager.cpp:695
static void deleteSave(const std::filesystem::path &file)
Definition save_manager.cpp:680
FaultPoint
Definition save_manager.h:165
@ MidFlush
Inside Game::saveGame's transaction.
@ Rotated
Backups rotated, before the rename.
@ TempOpened
Temporary file opened, before the backup.
@ SnapshotWritten
Backup done, before verification.
static std::filesystem::path tempPath(const std::filesystem::path &file)
Definition save_manager.cpp:440
static std::filesystem::path backupPath(const std::filesystem::path &file, int index)
Definition save_manager.cpp:435
static SaveInspection inspect(const std::filesystem::path &file, SaveCheck check=SaveCheck::Full)
Definition save_manager.cpp:445
static const SaveBackup * newestUsable(const std::vector< SaveBackup > &backups)
Definition save_manager.cpp:623
static void stampMetadata(const DatabaseConnection &working, std::uint64_t world_seed, const GameDateValue &game_date, std::int64_t playtime_seconds)
Definition save_manager.cpp:514
static void setFaultHook(FaultHook hook)
Definition save_manager.cpp:425
static void fault(FaultPoint point, sqlite3 *temp_db=nullptr)
Definition save_manager.cpp:430
int index
Definition runtime_editor.cpp:94
SaveCheck
Definition save_manager.h:87
@ Quick
PRAGMA quick_check (load screens).
@ Full
PRAGMA integrity_check + foreign_key_check (before loading).
SaveStatus
Definition save_manager.h:27
@ Incomplete
No game state: the game stopped while creating it.
@ Corrupt
Damaged file (integrity check failed / not a database).
@ FutureVersion
Written by a newer game; left untouched.
SaveErrorKind
Definition save_manager.h:37
AutosaveFrequency
Definition save_manager.h:135
@ SeasonEnd
When a new season starts.
@ Matchday
The day after a match of the managed club.
Definition save_manager.h:145
AutosaveFrequency frequency
Definition save_manager.h:146
int backups
Definition save_manager.h:148
Represents a specific date in the game world.
Definition gamedate.h:20
Definition save_manager.h:111
int index
Rotation index, or the schema version for PreMigration.
Definition save_manager.h:118
std::filesystem::path path
Definition save_manager.h:119
Kind kind
Definition save_manager.h:117
SaveInspection inspection
Definition save_manager.h:120
Kind
Definition save_manager.h:113
@ PreMigration
The file as it was before a schema upgrade.
@ Rotation
Previous save; index 1 is the newest.
Definition save_manager.h:49
int supported_version
Definition save_manager.h:54
SaveErrorKind kind
Definition save_manager.h:50
const char * langKey() const
Definition save_manager.cpp:395
int found_version
Definition save_manager.h:53
std::string detail
Technical detail for logs (not localized).
Definition save_manager.h:51
Definition save_manager.h:94
int foreign_key_issues
Definition save_manager.h:106
std::string game_date
Definition save_manager.h:103
SaveMetadata metadata
Definition save_manager.h:100
SaveStatus status
Definition save_manager.h:95
int supported_version
Definition save_manager.h:98
std::string detail
Why it is not Ok (technical).
Definition save_manager.h:96
int schema_version
Definition save_manager.h:97
bool has_metadata
False for saves from before versioning.
Definition save_manager.h:99
int season
Definition save_manager.h:104
std::string club_name
Empty while no club is managed.
Definition save_manager.h:102
int managed_team_id
Definition save_manager.h:101
Definition save_manager.h:125
double sync_ms
fsync, backup rotation and rename.
Definition save_manager.h:129
double snapshot_ms
Online backup to the temporary file.
Definition save_manager.h:127
double flush_ms
In-memory state written to the working DB.
Definition save_manager.h:126
double verify_ms
quick_check of the temporary file.
Definition save_manager.h:128
double total_ms
Definition save_manager.h:130