Remove PATX chunk, move to PATS
This commit is contained in:
@@ -36,7 +36,7 @@ static std::vector<SaveLoad> GetSettingsDesc(bool is_loading)
|
|||||||
std::vector<SaveLoad> saveloads;
|
std::vector<SaveLoad> saveloads;
|
||||||
for (auto &sd : GetSettingsTableInternal()) {
|
for (auto &sd : GetSettingsTableInternal()) {
|
||||||
if (sd->flags & SF_NOT_IN_SAVE) continue;
|
if (sd->flags & SF_NOT_IN_SAVE) continue;
|
||||||
if (sd->patx_name != nullptr && !(sd->flags & SF_ENABLE_TABLE_PATS)) continue;
|
if (!SlXvIsFeaturePresent(XSLFI_TABLE_PATS) && sd->patx_name != nullptr && !(sd->flags & SF_ENABLE_TABLE_PATS)) continue;
|
||||||
if (!sd->save.ext_feature_test.IsFeaturePresent(_sl_version, sd->save.version_from, sd->save.version_to)) continue;
|
if (!sd->save.ext_feature_test.IsFeaturePresent(_sl_version, sd->save.version_from, sd->save.version_to)) continue;
|
||||||
|
|
||||||
VarType new_type = 0;
|
VarType new_type = 0;
|
||||||
|
@@ -3220,7 +3220,7 @@ static const SaveLoad _settings_ext_load_desc[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal structure used in SaveSettingsPatx() and SaveSettingsPlyx()
|
* Internal structure used in SaveSettingsPlyx()
|
||||||
*/
|
*/
|
||||||
struct SettingsExtSave {
|
struct SettingsExtSave {
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
@@ -3286,56 +3286,6 @@ static void LoadSettingsPatx(const SettingTable &settings, void *object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save handler for settings which go in the PATX chunk
|
|
||||||
* @param sd SettingDesc struct containing all information
|
|
||||||
* @param object can be either nullptr in which case we load global variables or
|
|
||||||
* a pointer to a struct which is getting saved
|
|
||||||
*/
|
|
||||||
static void SaveSettingsPatx(const SettingTable &settings, void *object)
|
|
||||||
{
|
|
||||||
SettingsExtSave current_setting;
|
|
||||||
|
|
||||||
struct SettingToAdd {
|
|
||||||
const SettingDesc *setting;
|
|
||||||
uint32 setting_length;
|
|
||||||
};
|
|
||||||
std::vector<SettingToAdd> settings_to_add;
|
|
||||||
|
|
||||||
size_t length = 8;
|
|
||||||
for (auto &sd : settings) {
|
|
||||||
if (sd->patx_name == nullptr) continue;
|
|
||||||
if (sd->flags & SF_ENABLE_TABLE_PATS) continue;
|
|
||||||
uint32 setting_length = (uint32)SlCalcObjMemberLength(object, sd->save);
|
|
||||||
if (!setting_length) continue;
|
|
||||||
|
|
||||||
current_setting.name = sd->patx_name;
|
|
||||||
|
|
||||||
// add length of setting header
|
|
||||||
length += SlCalcObjLength(¤t_setting, _settings_ext_save_desc);
|
|
||||||
|
|
||||||
// add length of actual setting
|
|
||||||
length += setting_length;
|
|
||||||
|
|
||||||
// duplicate copy made for compiler backwards compatibility
|
|
||||||
SettingToAdd new_setting = { sd.get(), setting_length };
|
|
||||||
settings_to_add.push_back(new_setting);
|
|
||||||
}
|
|
||||||
SlSetLength(length);
|
|
||||||
|
|
||||||
SlWriteUint32(0); // flags
|
|
||||||
SlWriteUint32((uint32)settings_to_add.size()); // settings count
|
|
||||||
|
|
||||||
for (size_t i = 0; i < settings_to_add.size(); i++) {
|
|
||||||
const SettingDesc *desc = settings_to_add[i].setting;
|
|
||||||
current_setting.flags = 0;
|
|
||||||
current_setting.name = desc->patx_name;
|
|
||||||
current_setting.setting_length = settings_to_add[i].setting_length;
|
|
||||||
SlObject(¤t_setting, _settings_ext_save_desc);
|
|
||||||
SlObjectMember(object, desc->save);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* The PLYX chunk stores additional company settings in an unordered
|
* The PLYX chunk stores additional company settings in an unordered
|
||||||
@@ -3527,11 +3477,6 @@ static void Check_PATX()
|
|||||||
LoadSettingsPatx(_settings, &_load_check_data.settings);
|
LoadSettingsPatx(_settings, &_load_check_data.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Save_PATX()
|
|
||||||
{
|
|
||||||
SaveSettingsPatx(_settings, &_settings_game);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PATSChunkInfo
|
struct PATSChunkInfo
|
||||||
{
|
{
|
||||||
static SaveLoadVersion GetLoadVersion()
|
static SaveLoadVersion GetLoadVersion()
|
||||||
@@ -3554,7 +3499,7 @@ struct PATSChunkInfo
|
|||||||
static const ChunkHandler setting_chunk_handlers[] = {
|
static const ChunkHandler setting_chunk_handlers[] = {
|
||||||
{ 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF },
|
{ 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF },
|
||||||
MakeConditionallyUpstreamChunkHandler<'PATS', PATSChunkInfo>(nullptr, Load_PATS, nullptr, Check_PATS, CH_RIFF),
|
MakeConditionallyUpstreamChunkHandler<'PATS', PATSChunkInfo>(nullptr, Load_PATS, nullptr, Check_PATS, CH_RIFF),
|
||||||
{ 'PATX', Save_PATX, Load_PATX, nullptr, Check_PATX, CH_RIFF },
|
{ 'PATX', nullptr, Load_PATX, nullptr, Check_PATX, CH_RIFF },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers);
|
extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers);
|
||||||
|
Reference in New Issue
Block a user