OpenTTD Source: src/saveload/settings_sl.cpp File Reference

OpenTTD Source 15.0-RC2

Data Structures | Functions | Variables
settings_sl.cpp File Reference

Handles the saveload part of the settings. More...

`#include "../stdafx.h"`
`#include "saveload.h"`
`#include "compat/settings_sl_compat.h"`
`#include "../settings_type.h"`
`#include "../settings_table.h"`
`#include "../settings_internal.h"`
`#include "../network/network.h"`
`#include "../fios.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | OPTSChunkHandler
struct | PATSChunkHandler

## Functions
void | PrepareOldDiffCustom ()
| Prepare for reading and old diff_custom by zero-ing the memory.
void | HandleOldDiffCustom (bool savegame)
| Reading of the old diff_custom array and transforming it to the new format.
static std::vector< SaveLoad > | GetSettingsDesc (const SettingTable &settings, bool is_loading)
| Get the SaveLoad description for the SettingTable.
static void | LoadSettings (const SettingTable &settings, void *object, const SaveLoadCompatTable &slct)
| Save and load handler for settings.
static void | SaveSettings (const SettingTable &settings, void *object)
| Save and load handler for settings.
const ChunkHandlerTable | _setting_chunk_handlers (setting_chunk_handlers)

## Variables
static const OPTSChunkHandler | OPTS
static const PATSChunkHandler | PATS
static const ChunkHandlerRef | setting_chunk_handlers []

## Detailed Description

Handles the saveload part of the settings.

Definition in file settings_sl.cpp.

## Function Documentation

## ◆ GetSettingsDesc()

static std::vector< SaveLoad > GetSettingsDesc | ( | const SettingTable & | settings,
|  | bool | is_loading
| ) |  |
| static

Get the SaveLoad description for the SettingTable.

Parameters

  settings | SettingDesc struct containing all information.
  is_loading | True iff the SaveLoad table is for loading.

Returns
  Vector with SaveLoad entries for the SettingTable.

Definition at line 78 of file settings_sl.cpp.

References _network_server, _networking, SaveLoad::cmd, SaveLoad::conv, SettingDesc::flags, SettingDesc::GetName(), GetSettingDesc(), GetVarFileType(), IsSavegameVersionBefore(), SaveLoad::length, NoNetworkSync, NotInSave, SettingDesc::save, settings, SLE_VAR_NULL, SLV_TABLE_CHUNKS, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), SaveLoad::version_from, and SaveLoad::version_to.

Referenced by LoadSettings(), and SaveSettings().

## ◆ HandleOldDiffCustom()

void HandleOldDiffCustom | ( | bool | savegame | ) |

Reading of the old diff_custom array and transforming it to the new format.

Parameters

  savegame | is it read from the config or savegame. In the latter case we are sure there is an array; in the former case we have to check that.

Definition at line 37 of file settings_sl.cpp.

References _settings_game, _settings_newgame, SettingDesc::AsIntSetting(), GetSettingFromName(), IsSavegameVersionBefore(), IntSettingDesc::MakeValueValidAndWrite(), and SLV_4.

Referenced by OPTSChunkHandler::Load(), and LoadFromConfig().

## ◆ LoadSettings()

static void LoadSettings | ( | const SettingTable & | settings,
|  | void * | object,
|  | const SaveLoadCompatTable & | slct
| ) |  |
| static

Save and load handler for settings.

Parameters

  settings | SettingDesc struct containing all information
  object | can be either nullptr in which case we load global variables or a pointer to a struct which is getting saved

Definition at line 105 of file settings_sl.cpp.

References _network_server, _networking, SettingDesc::AsIntSetting(), SettingDesc::flags, GetSettingDesc(), GetSettingsDesc(), SettingDesc::IsIntSetting(), IsSavegameVersionBefore(), IntSettingDesc::MakeValueValidAndWrite(), NoNetworkSync, NotInSave, IntSettingDesc::Read(), SettingDesc::save, settings, SlCompatTableHeader(), SlErrorCorrupt(), SlIsObjectCurrentlyValid(), SlIterateArray(), SlObject(), SLV_RIFF_TO_ARRAY, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), SaveLoad::version_from, and SaveLoad::version_to.

Referenced by OPTSChunkHandler::Load(), PATSChunkHandler::Load(), and PATSChunkHandler::LoadCheck().

## ◆ PrepareOldDiffCustom()

void PrepareOldDiffCustom | ( |  | ) |

Prepare for reading and old diff_custom by zero-ing the memory.

Definition at line 26 of file settings_sl.cpp.

Referenced by OPTSChunkHandler::Load(), and LoadFromConfig().

## ◆ SaveSettings()

static void SaveSettings | ( | const SettingTable & | settings,
|  | void * | object
| ) |  |
| static

Save and load handler for settings.

Parameters

  settings | SettingDesc struct containing all information
  object | can be either nullptr in which case we load global variables or a pointer to a struct which is getting saved

Definition at line 133 of file settings_sl.cpp.

References GetSettingsDesc(), settings, SlObject(), and SlTableHeader().

Referenced by PATSChunkHandler::Save().

## Variable Documentation

## ◆ OPTS

const OPTSChunkHandler OPTS
| static

Definition at line 180 of file settings_sl.cpp.

## ◆ PATS

const PATSChunkHandler PATS
| static

Definition at line 181 of file settings_sl.cpp.

## ◆ setting_chunk_handlers

const ChunkHandlerRef setting_chunk_handlers[]
| static

Initial value:
= {
OPTS,
PATS,
}

Definition at line 182 of file settings_sl.cpp.