10 #include "../stdafx.h"
18 #include "../safeguards.h"
36 for (uint i = 0; i < this->mapping.GetMaxMapping(); i++) {
37 if (this->mapping.
mappings[i].grfid == 0 &&
38 this->mapping.mappings[i].entity_id == 0)
continue;
55 uint max_id = this->mapping.GetMaxMapping();
59 if ((uint)index >= max_id)
SlErrorCorrupt(
"Too many NewGRF entity mappings");
65 static const SaveLoad _grfconfig_desc[] = {
87 SlSetArrayIndex(index++);
93 void LoadCommon(
GRFConfig *&grfconfig)
const
110 if (_game_mode == GM_MENU) {
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
void ResetMapping()
Resets the mapping, which is used while initializing game.
std::vector< EntityIDMapping > mappings
mapping of ids from grf files. Public out of convenience
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el)
Appends an element to a list of GRFs.
GRFConfig * _grfconfig
First item in list of current GRF set up.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
void AppendStaticGRFConfigs(GRFConfig **dst)
Appends the static GRFs to a list of GRFs.
@ GCF_INIT_ONLY
GRF file is processed up to GLS_INIT.
@ GCF_STATIC
GRF file is used statically (can be used in any MP game)
static const SaveLoad _newgrf_mapping_desc[]
Save and load the mapping between a spec and the NewGRF it came from.
Code handling saving and loading of NewGRF mappings.
Loading of newgrf chunks before table headers were added.
const SaveLoadCompat _grfconfig_sl_compat[]
Original field order for _newgrf_desc.
const SaveLoadCompat _newgrf_mapping_sl_compat[]
Original field order for _newgrf_mapping_desc.
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.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Functions/types related to saving and loading games.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLE_ARR(base, variable, type, length)
Storage of fixed-size array of SL_VAR elements in every version of a savegame.
#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.
#define SLE_SSTR(base, variable, type)
Storage of a std::string in every savegame version.
@ SL_MAX_VERSION
Highest possible saveload version.
@ SL_MIN_VERSION
First savegame version.
@ SLV_EXTEND_ENTITY_MAPPING
311 PR#10672 Extend entity mapping range.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Handlers and description of chunk.
Maps an entity id stored on the map to a GRF file.
Information about GRF, used in the game and (part of it) in savegames.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
void SetSuitablePalette()
Set the palette of this GRFConfig to something suitable.
GRFConfig * grfconfig
NewGrf configuration from save.
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.
void Load() const override
Load a GRF ID + local id -> OpenTTD's id mapping.
void Save() const override
Save a GRF ID + local id -> OpenTTD's id mapping.