mirror of https://github.com/OpenTTD/OpenTTD
Fix #12901: Savegame format of company allow lists
parent
d1463f415f
commit
c277ff121e
|
@ -441,6 +441,38 @@ public:
|
||||||
void LoadCheck(CompanyProperties *c) const override { this->Load(c); }
|
void LoadCheck(CompanyProperties *c) const override { this->Load(c); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SlAllowListData : public DefaultSaveLoadHandler<SlAllowListData, CompanyProperties> {
|
||||||
|
public:
|
||||||
|
struct KeyWrapper {
|
||||||
|
std::string key;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static const SaveLoad description[] = {
|
||||||
|
SLE_SSTR(KeyWrapper, key, SLE_STR),
|
||||||
|
};
|
||||||
|
inline const static SaveLoadCompatTable compat_description = {};
|
||||||
|
|
||||||
|
void Save(CompanyProperties *cprops) const override
|
||||||
|
{
|
||||||
|
SlSetStructListLength(cprops->allow_list.size());
|
||||||
|
for (std::string &str : cprops->allow_list) {
|
||||||
|
SlObject(&str, this->GetDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Load(CompanyProperties *cprops) const override
|
||||||
|
{
|
||||||
|
size_t num_keys = SlGetStructListLength(UINT32_MAX);
|
||||||
|
cprops->allow_list.clear();
|
||||||
|
cprops->allow_list.resize(num_keys);
|
||||||
|
for (std::string &str : cprops->allow_list) {
|
||||||
|
SlObject(&str, this->GetLoadDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadCheck(CompanyProperties *cprops) const override { this->Load(cprops); }
|
||||||
|
};
|
||||||
|
|
||||||
/* Save/load of companies */
|
/* Save/load of companies */
|
||||||
static const SaveLoad _company_desc[] = {
|
static const SaveLoad _company_desc[] = {
|
||||||
SLE_VAR(CompanyProperties, name_2, SLE_UINT32),
|
SLE_VAR(CompanyProperties, name_2, SLE_UINT32),
|
||||||
|
@ -451,7 +483,8 @@ static const SaveLoad _company_desc[] = {
|
||||||
SLE_VAR(CompanyProperties, president_name_2, SLE_UINT32),
|
SLE_VAR(CompanyProperties, president_name_2, SLE_UINT32),
|
||||||
SLE_CONDSSTR(CompanyProperties, president_name, SLE_STR | SLF_ALLOW_CONTROL, SLV_84, SL_MAX_VERSION),
|
SLE_CONDSSTR(CompanyProperties, president_name, SLE_STR | SLF_ALLOW_CONTROL, SLV_84, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDVECTOR(CompanyProperties, allow_list, SLE_STR, SLV_COMPANY_ALLOW_LIST, SL_MAX_VERSION),
|
SLE_CONDVECTOR(CompanyProperties, allow_list, SLE_STR, SLV_COMPANY_ALLOW_LIST, SLV_COMPANY_ALLOW_LIST_V2),
|
||||||
|
SLEG_CONDSTRUCTLIST("allow_list", SlAllowListData, SLV_COMPANY_ALLOW_LIST_V2, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_VAR(CompanyProperties, face, SLE_UINT32),
|
SLE_VAR(CompanyProperties, face, SLE_UINT32),
|
||||||
|
|
||||||
|
|
|
@ -386,6 +386,7 @@ enum SaveLoadVersion : uint16_t {
|
||||||
SLV_COMPANY_INAUGURATED_PERIOD, ///< 339 PR#12798 Companies show the period inaugurated in wallclock mode.
|
SLV_COMPANY_INAUGURATED_PERIOD, ///< 339 PR#12798 Companies show the period inaugurated in wallclock mode.
|
||||||
|
|
||||||
SLV_ROAD_STOP_TILE_DATA, ///< 340 PR#12883 Move storage of road stop tile data, also save for road waypoints.
|
SLV_ROAD_STOP_TILE_DATA, ///< 340 PR#12883 Move storage of road stop tile data, also save for road waypoints.
|
||||||
|
SLV_COMPANY_ALLOW_LIST_V2, ///< 341 PR#12908 Fixed savegame format for saving of list of client keys that are allowed to join this company.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue