From 3d9436bd75d2d6ff2024ac4ccacf8d6e1e730cc3 Mon Sep 17 00:00:00 2001 From: PeterN Date: Wed, 12 May 2021 08:11:14 +0100 Subject: Fix #9202: Invalid test for unset NewGRF override mapping. (#9226) --- src/newgrf_commons.h | 1 - src/saveload/newgrf_sl.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index b86e3d10a..ed18aaa9e 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -218,7 +218,6 @@ 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 f7f6ab72e..2e9f1ccaf 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -30,7 +30,8 @@ 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; + if (mapping.mapping_ID[i].grfid == 0 && + mapping.mapping_ID[i].entity_id == 0) continue; SlSetArrayIndex(i); SlObject(&mapping.mapping_ID[i], _newgrf_mapping_desc); } -- cgit v1.2.3-70-g09d2