Changeset - r25438:91ac2a71fe27
[Not reviewed]
master
0 2 0
PeterN - 3 years ago 2021-05-12 07:11:14
peter1138@openttd.org
Fix #9202: Invalid test for unset NewGRF override mapping. (#9226)
2 files changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/newgrf_commons.h
Show inline comments
 
@@ -209,25 +209,24 @@ public:
 
	void ResetOverride();
 
	void ResetMapping();
 

	
 
	void Add(uint8 local_id, uint32 grfid, uint entity_type);
 
	virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id);
 

	
 
	uint32 GetGRFID(uint16 entity_id) const;
 
	uint16 GetSubstituteID(uint16 entity_id) const;
 
	virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const;
 

	
 
	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; }
 
};
 

	
 

	
 
struct HouseSpec;
 
class HouseOverrideManager : public OverrideManagerBase {
 
public:
 
	HouseOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
 
			OverrideManagerBase(offset, maximum, invalid) {}
 

	
 
	void SetEntitySpec(const HouseSpec *hs);
 
};
 

	
src/saveload/newgrf_sl.cpp
Show inline comments
 
@@ -21,25 +21,26 @@ static const SaveLoad _newgrf_mapping_de
 
	SLE_VAR(EntityIDMapping, entity_id,     SLE_UINT8),
 
	SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8),
 
	SLE_END()
 
};
 

	
 
/**
 
 * Save a GRF ID + local id -> OpenTTD's id mapping.
 
 * @param mapping The mapping to save.
 
 */
 
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);
 
	}
 
}
 

	
 
/**
 
 * Load a GRF ID + local id -> OpenTTD's id mapping.
 
 * @param mapping The mapping to load.
 
 */
 
void Load_NewGRFMapping(OverrideManagerBase &mapping)
 
{
 
	/* Clear the current mapping stored.
0 comments (0 inline, 0 general)