diff options
author | PeterN <peter1138@openttd.org> | 2021-05-08 11:36:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-08 11:36:39 +0100 |
commit | 69e5da0b544e83ed445cf500938c24602230fa2c (patch) | |
tree | 5cfd1526084cc242bd78d2fcffa9b3f99b2001e6 | |
parent | 881e1da51d47bde0b6ddf86be1da55aceced7839 (diff) | |
download | openttd-69e5da0b544e83ed445cf500938c24602230fa2c.tar.xz |
Codechange: Don't save unused NewGRF override mappings. (#9202)
-rw-r--r-- | src/newgrf_commons.h | 1 | ||||
-rw-r--r-- | src/saveload/newgrf_sl.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index ed18aaa9e..b86e3d10a 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -218,6 +218,7 @@ public: inline uint16 GetMaxMapping() const { return max_new_entities; } inline uint16 GetMaxOffset() const { return max_offset; } + inline bool IsValidID(uint16 entity_id) const { return entity_overrides[entity_id] != invalid_ID; } }; diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index b2d2b0df9..f7f6ab72e 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -30,6 +30,7 @@ static const SaveLoad _newgrf_mapping_desc[] = { void Save_NewGRFMapping(const OverrideManagerBase &mapping) { for (uint i = 0; i < mapping.GetMaxMapping(); i++) { + if (!mapping.IsValidID(i)) continue; SlSetArrayIndex(i); SlObject(&mapping.mapping_ID[i], _newgrf_mapping_desc); } |