24 static inline const SaveLoad description[] = {
47 static const size_t GAMELOG_REVISION_LENGTH = 15;
48 static char revision_text[GAMELOG_REVISION_LENGTH];
50 static inline const SaveLoad description[] = {
71 static_cast<LoggedChangeRevision *
>(lc)->text =
StrMakeValid(std::string_view(std::begin(SlGamelogRevision::revision_text), std::end(SlGamelogRevision::revision_text)));
78 char SlGamelogRevision::revision_text[GAMELOG_REVISION_LENGTH];
82 static inline const SaveLoad description[] = {
105 static inline const SaveLoad description[] = {
129 static inline const SaveLoad description[] = {
152 static inline const SaveLoad description[] = {
174 static inline const SaveLoad description[] = {
197 static inline const SaveLoad description[] = {
219 static inline const SaveLoad description[] = {
242 static inline const SaveLoad description[] = {
264static bool _is_emergency_save =
true;
278 _is_emergency_save =
true;
315 static inline const SaveLoad description[] = {
335 for (
auto &lc : la->
change) {
337 SlObject(lc.get(), this->GetDescription());
343 std::unique_ptr<LoggedChange> lc = MakeLoggedChange(type);
344 SlObject(lc.get(), this->GetLoadDescription());
345 la->
change.push_back(std::move(lc));
360 la->
change.reserve(length);
362 for (
size_t i = 0; i < length; i++) {
370static const SaveLoad _gamelog_desc[] = {
377struct GLOGChunkHandler : ChunkHandler {
380 void LoadCommon(
Gamelog &gamelog)
const
382 assert(gamelog.data->action.empty());
410 SlSetArrayIndex(i++);
Default handler for saving/loading an object to/from disk.
SaveLoadTable GetDescription() const override
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
void Save(LoggedAction *la) const override
Save the object to disk.
void Load(LoggedAction *la) const override
Load the object from disk.
void LoadCheck(LoggedAction *la) const override
Similar to load, but used only to validate savegames.
static const SaveLoad description[]
We need to store something, so store a "true" value.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
Declarations for savegames operations.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Gamelog _gamelog
Gamelog instance.
GamelogChangeType
Type of logged change.
@ GRFCompat
Loading compatible GRF.
@ Revision
Changed game revision string.
@ GRFParam
GRF parameter changed.
@ Setting
Non-networksafe setting value changed.
@ GRFMove
GRF order changed.
@ Mode
Scenario editor x Game, different landscape.
@ None
In savegames, end of list.
@ Emergency
Emergency savegame.
@ GRFBug
GRF bug triggered.
@ OldVer
Loaded from savegame without logged data.
GamelogActionType
The actions we log.
@ None
No logging active; in savegames, end of list.
Declaration shared among gamelog.cpp and saveload/gamelog_sl.cpp.
Loading for gamelog chunks before table headers were added.
const SaveLoadCompat _gamelog_emergency_sl_compat[]
Original field order for SlGamelogEmergency.
const SaveLoadCompat _gamelog_mode_sl_compat[]
Original field order for SlGamelogMode.
const SaveLoadCompat _gamelog_grfmove_sl_compat[]
Original field order for SlGamelogGrfmove.
const SaveLoadCompat _gamelog_action_sl_compat[]
Original field order for SlGamelogAction.
const SaveLoadCompat _gamelog_oldver_sl_compat[]
Original field order for SlGamelogOldver.
const SaveLoadCompat _gamelog_revision_sl_compat[]
Original field order for SlGamelogRevision.
const SaveLoadCompat _gamelog_sl_compat[]
Original field order for _gamelog_desc.
const SaveLoadCompat _gamelog_setting_sl_compat[]
Original field order for SlGamelogSetting.
const SaveLoadCompat _gamelog_grfrem_sl_compat[]
Original field order for SlGamelogGrfrem.
const SaveLoadCompat _gamelog_grfbug_sl_compat[]
Original field order for SlGamelogGrfbug.
const SaveLoadCompat _gamelog_grfadd_sl_compat[]
Original field order for SlGamelogGrfadd.
const SaveLoadCompat _gamelog_grfcompat_sl_compat[]
Original field order for SlGamelogGrfcompat.
const SaveLoadCompat _gamelog_grfparam_sl_compat[]
Original field order for SlGamelogGrfparam.
A number of safeguards to prevent using unsafe methods.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
uint8_t SlReadByte()
Wrapper for reading a byte from the buffer.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlSetStructListLength(size_t length)
Set the length of this list.
Functions/types related to saving and loading games.
@ U64
A 64 bit unsigned int.
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SaveLoadType::Variable elements in some savegame versions.
@ U16
A 16 bit unsigned int.
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
#define SLE_CONDSSTRNAME(base, variable, name, type, from, to)
Storage of a std::string in some savegame versions.
#define SLE_SSTRNAME(base, variable, name, type)
Storage of a std::string in every savegame version.
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
#define SLE_VARNAME(base, variable, name, type)
Storage of a variable in every version of a savegame.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
#define SLE_ARRNAME(base, variable, name, type, length)
Storage of fixed-size array of SaveLoadType::Variable elements in every version of a savegame.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLE_SAVEBYTE(base, variable)
Only write byte during saving; never read it during loading.
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
#define SLEG_STRUCT(name, handler)
Storage of a structs in every savegame version.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ StringGamelog
Saveload version: 314, GitHub pull request: 10801 Use std::string in gamelog.
@ U64TickCounter
Saveload version: 300, GitHub pull request: 10035 Make tick counter 64bit to avoid wrapping.
@ MinVersion
First savegame version.
@ MaxVersion
Highest possible saveload version.
@ RiffToArray
Saveload version: 294, GitHub pull request: 9375 Changed many ChunkType::Riff chunks to ChunkType::A...
@ Table
An Array with a header describing the elements.
Definition of base types and functions in a cross-platform compatible way.
static void StrMakeValid(Builder &builder, StringConsumer &consumer, StringValidationSettings settings)
Copies the valid (UTF-8) characters from consumer to the builder.
Functions related to low-level strings.
ChunkType type
Type of the chunk.
void LoadCheck(size_t) const override
Load the chunk for game preview.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
Contains information about one logged action that caused at least one logged change.
std::vector< std::unique_ptr< LoggedChange > > change
Logged changes in this action.
GamelogActionType at
Type of action.
A log entry for a NewGRF that was added.
A log entry for a NewGRF bug.
A log entry for a NewGRF that was changed.
A log entry for a NewGRF that was moved.
A log entry for a NewGRF for which a parameter was changed.
A log entry for a NewGRF that was removed.
Log element for the change of the game mode and landscape.
A log entry for loading a really old savegame.
A log entry for a change in OpenTTD version.
A log entry for changing a setting.
Container for any change that we deem needs to be logged.
GamelogChangeType ct
The type of change.
static constexpr VarType U16
Store a 16 bits unsigned int.
static constexpr VarType U8
Store a 8 bits unsigned int.
static constexpr VarType STR
Store string.
static constexpr VarType U64
Store a 64 bits unsigned int.
static constexpr VarType U32
Store a 32 bits unsigned int.
static constexpr VarType I32
Store a 32 bits signed int.
static constexpr VarType BOOL
Store a boolean (as int8).