15#include "../settings_type.h"
16#include "../settings_table.h"
17#include "../network/network.h"
20#include "../safeguards.h"
27 memset(_old_diff_custom, 0,
sizeof(_old_diff_custom));
40 uint options_to_load = GAME_DIFFICULTY_NUM - (has_no_town_council_tolerance ? 1 : 0);
44 bool old_diff_custom_used =
false;
45 for (uint i = 0; i < options_to_load && !old_diff_custom_used; i++) {
46 old_diff_custom_used = (_old_diff_custom[i] != 0);
49 if (!old_diff_custom_used)
return;
54 for (
const auto &name : _old_diff_settings) {
55 if (has_no_town_council_tolerance && name ==
"town_council_tolerance")
continue;
57 std::string fullname =
"difficulty." + name;
66 int32_t value = (int32_t)((name ==
"max_loan" ? 1000 : 1) * _old_diff_custom[i++]);
79 std::vector<SaveLoad> saveloads;
92 saveloads.push_back(sd->
save);
165 static const SettingTable saveload_settings_tables[] = {
166 _difficulty_settings,
171 _pathfinding_settings,
175 static std::vector<SettingVariant> settings_table;
177 if (settings_table.empty()) {
178 for (
auto &saveload_settings_table : saveload_settings_tables) {
179 for (
auto &saveload_setting : saveload_settings_table) {
180 settings_table.push_back(saveload_setting);
185 return settings_table;
195 for (
auto &desc : settings_table) {
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
fluid_settings_t * settings
FluidSynth settings handle.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
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.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Functions/types related to saving and loading games.
@ SLE_VAR_NULL
useful to write zeros in savegame.
@ CH_READONLY
Chunk is never saved.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
constexpr VarType GetVarFileType(VarType type)
Get the FileType of a setting.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
Checks if some version from/to combination falls within the range of the active savegame version.
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ SLV_4
4.0 1 4.1 122 0.3.3, 0.3.4 4.2 1222 0.3.5 4.3 1417 4.4 1426
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
@ SLV_TABLE_CHUNKS
295 PR#9322 Introduction of CH_TABLE and CH_SPARSE_TABLE.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static const SettingDesc * GetSettingFromName(const std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
@ SF_NOT_IN_SAVE
Do not save with savegame, basically client-based.
@ SF_NO_NETWORK_SYNC
Do not synchronize over network (but it is saved if SF_NOT_IN_SAVE is not set).
static constexpr const SettingDesc * GetSettingDesc(const SettingVariant &desc)
Helper to convert the type of the iterated settings description to a pointer to it.
void HandleOldDiffCustom(bool savegame)
Reading of the old diff_custom array and transforming it to the new format.
static void LoadSettings(const SettingTable &settings, void *object, const SaveLoadCompatTable &slct)
Save and load handler for settings.
static std::vector< SaveLoad > GetSettingsDesc(const SettingTable &settings, bool is_loading)
Get the SaveLoad description for the SettingTable.
void PrepareOldDiffCustom()
Prepare for reading and old diff_custom by zero-ing the memory.
static void SaveSettings(const SettingTable &settings, void *object)
Save and load handler for settings.
Loading of settings chunks before table headers were added.
const SaveLoadCompat _gameopt_sl_compat[]
Original field order for _gameopt.
const SaveLoadCompat _settings_sl_compat[]
Original field order for _settings.
Handlers and description of chunk.
Base integer type, including boolean, settings.
void MakeValueValidAndWrite(const void *object, int32_t value) const
Make the value valid and then write it to the setting.
int32_t Read(const void *object) const
Read the integer from the the actual setting.
void Load() const override
Load the chunk.
void Load() const override
Load the chunk.
void LoadCheck(size_t) const override
Load the chunk for game preview.
SettingTable GetSettingTable() const
Create a single table with all settings that should be stored/loaded in the savegame.
void Save() const override
Save the chunk.
uint16_t length
(Conditional) length of the variable (eg. arrays) (max array size is 65536 elements).
SaveLoadVersion version_to
Save/load the variable before this savegame version.
SaveLoadType cmd
The action to take with the saved/loaded type, All types need different action.
VarType conv
Type of the variable to be saved; this field combines both FileVarType and MemVarType.
SaveLoadVersion version_from
Save/load the variable starting from this savegame version.
Properties of config file settings.
virtual void ResetToDefault(void *object) const =0
Reset the setting to its default value.
constexpr const std::string & GetName() const
Get the name of this setting.
SaveLoad save
Internal structure (going to savegame, parts to config).
virtual bool IsIntSetting() const
Check whether this setting is an integer type setting.
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
SettingFlag flags
Handles how a setting would show up in the GUI (text/currency, etc.).