summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_commons.h1
-rw-r--r--src/saveload/newgrf_sl.cpp1
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);
}