Saveload: Simplify use of custom tags in SaveLoadTags

This commit is contained in:
Jonathan G Rennison 2024-07-29 17:26:11 +01:00
parent 6b4ce10ac4
commit b2c0a9c22e
3 changed files with 8 additions and 6 deletions

View File

@ -22,8 +22,8 @@ struct AnimatedTileStructHandler : public SaveLoadStructHandler {
NamedSaveLoadTable GetDescription() const override
{
static const NamedSaveLoad _anim_tiles_sub_desc[] = {
NSLT("tile", SLTAG(SLTAG_CUSTOM_START, SLE_VAR(AnimatedTilePair, first, SLE_UINT32))),
NSLT("speed", SLTAG(SLTAG_CUSTOM_START + 1, SLE_VAR(AnimatedTilePair, second.speed, SLE_UINT8))),
NSLT("tile", SLTAG(SLTAG_CUSTOM_0, SLE_VAR(AnimatedTilePair, first, SLE_UINT32))),
NSLT("speed", SLTAG(SLTAG_CUSTOM_1, SLE_VAR(AnimatedTilePair, second.speed, SLE_UINT8))),
};
return _anim_tiles_sub_desc;
}
@ -45,7 +45,7 @@ struct AnimatedTileStructHandler : public SaveLoadStructHandler {
void Load([[maybe_unused]] void *object) const override
{
auto slt = this->GetLoadDescription();
if (slt.size() != 2 || slt[0].label_tag != SLTAG_CUSTOM_START || slt[1].label_tag != SLTAG_CUSTOM_START + 1) {
if (slt.size() != 2 || slt[0].label_tag != SLTAG_CUSTOM_0 || slt[1].label_tag != SLTAG_CUSTOM_1) {
SlErrorCorrupt("Table format ANIT chunk fields not as expected");
}

View File

@ -313,8 +313,8 @@ using DispatchSupplementaryNamePair = std::pair<const uint32_t, std::string>;
NamedSaveLoadTable GetDispatchSupplementaryNamePairDescription()
{
static const NamedSaveLoad _dispatch_name_pair_desc[] = {
NSL("key", SLTAG(SLTAG_CUSTOM_START, SLE_VAR(DispatchSupplementaryNamePair, first, SLE_UINT32))),
NSL("value", SLTAG(SLTAG_CUSTOM_START + 1, SLE_SSTR(DispatchSupplementaryNamePair, second, SLE_STR))),
NSL("key", SLTAG(SLTAG_CUSTOM_0, SLE_VAR(DispatchSupplementaryNamePair, first, SLE_UINT32))),
NSL("value", SLTAG(SLTAG_CUSTOM_1, SLE_SSTR(DispatchSupplementaryNamePair, second, SLE_STR))),
};
return _dispatch_name_pair_desc;
@ -338,7 +338,7 @@ struct DispatchNameStructHandler final : public TypedSaveLoadStructHandler<Dispa
void Load(DispatchSchedule *ds) const override
{
SaveLoadTable slt = this->GetLoadDescription();
if (slt.size() != 2 || slt[0].label_tag != SLTAG_CUSTOM_START || slt[1].label_tag != SLTAG_CUSTOM_START + 1) {
if (slt.size() != 2 || slt[0].label_tag != SLTAG_CUSTOM_0 || slt[1].label_tag != SLTAG_CUSTOM_1) {
SlErrorCorrupt("Dispatch names sub-chunk fields not as expected");
}

View File

@ -160,6 +160,8 @@ enum SaveLoadTags {
SLTAG_DEFAULT,
SLTAG_TABLE_UNKNOWN,
SLTAG_CUSTOM_START,
SLTAG_CUSTOM_0 = SLTAG_CUSTOM_START,
SLTAG_CUSTOM_1,
};
enum NamedSaveLoadFlags : uint8_t {