mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Saveload: Simplify use of custom tags in SaveLoadTags
This commit is contained in:
parent
6b4ce10ac4
commit
b2c0a9c22e
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user