Saveload: Add wrapper to simplify conditionally upstream chunks
Where they're always saved as upstream and conditional on a feature
This commit is contained in:
@@ -3693,28 +3693,9 @@ static void Check_PATX()
|
|||||||
LoadSettingsPatx(&_load_check_data.settings);
|
LoadSettingsPatx(&_load_check_data.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PATSChunkInfo
|
|
||||||
{
|
|
||||||
static SaveLoadVersion GetLoadVersion()
|
|
||||||
{
|
|
||||||
extern SaveLoadVersion _sl_xv_upstream_version;
|
|
||||||
return _sl_xv_upstream_version;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool SaveUpstream()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool LoadUpstream()
|
|
||||||
{
|
|
||||||
return SlXvIsFeaturePresent(XSLFI_TABLE_PATS);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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),
|
MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler<'PATS', XSLFI_TABLE_PATS>(Load_PATS, nullptr, Check_PATS),
|
||||||
{ 'PATX', nullptr, Load_PATX, nullptr, Check_PATX, CH_RIFF },
|
{ 'PATX', nullptr, Load_PATX, nullptr, Check_PATX, CH_RIFF },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -133,6 +133,26 @@ void SlExecWithSlVersion(SaveLoadVersion use_version, F proc)
|
|||||||
proc();
|
proc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <SlXvFeatureIndex feature, uint16_t min_version, uint16_t max_version>
|
||||||
|
struct SaveUpstreamFeatureConditionalLoadUpstreamChunkInfo
|
||||||
|
{
|
||||||
|
static SaveLoadVersion GetLoadVersion()
|
||||||
|
{
|
||||||
|
extern SaveLoadVersion _sl_xv_upstream_version;
|
||||||
|
return _sl_xv_upstream_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool SaveUpstream()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool LoadUpstream()
|
||||||
|
{
|
||||||
|
return SlXvIsFeaturePresent(feature, min_version, max_version);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
namespace upstream_sl {
|
namespace upstream_sl {
|
||||||
template <uint32_t id, typename F>
|
template <uint32_t id, typename F>
|
||||||
ChunkHandler MakeUpstreamChunkHandler()
|
ChunkHandler MakeUpstreamChunkHandler()
|
||||||
@@ -220,10 +240,17 @@ namespace upstream_sl {
|
|||||||
};
|
};
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <uint32_t id, SlXvFeatureIndex feature, uint16_t min_version = 1, uint16_t max_version = 0xFFFF>
|
||||||
|
ChunkHandler MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler(ChunkSaveLoadProc *load_proc, ChunkSaveLoadProc *ptrs_proc, ChunkSaveLoadProc *load_check_proc)
|
||||||
|
{
|
||||||
|
return MakeConditionallyUpstreamChunkHandler<id, SaveUpstreamFeatureConditionalLoadUpstreamChunkInfo<feature, min_version, max_version>>(nullptr, load_proc, ptrs_proc, load_check_proc, CH_UNUSED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using upstream_sl::MakeUpstreamChunkHandler;
|
using upstream_sl::MakeUpstreamChunkHandler;
|
||||||
using upstream_sl::MakeConditionallyUpstreamChunkHandler;
|
using upstream_sl::MakeConditionallyUpstreamChunkHandler;
|
||||||
|
using upstream_sl::MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler;
|
||||||
|
|
||||||
struct NullStruct {
|
struct NullStruct {
|
||||||
byte null;
|
byte null;
|
||||||
|
Reference in New Issue
Block a user