# HG changeset patch # User glx # Date 1202489812 0 # Node ID 6fc05c8ecf87187516a0050f5d054830634af93d # Parent f68ac871be5cfe440e49bf1228a4584260fcfa92 (svn r12086) -Fix [FS#1747] (r11425): check overrides only for industries when mapping newgrf entities to 'real' entities diff -r f68ac871be5c -r 6fc05c8ecf87 src/newgrf_commons.cpp --- a/src/newgrf_commons.cpp Fri Feb 08 16:25:55 2008 +0000 +++ b/src/newgrf_commons.cpp Fri Feb 08 16:56:52 2008 +0000 @@ -91,11 +91,6 @@ } } - /* No mapping found, try the overrides */ - for (uint16 id = 0; id < max_offset; id++) { - if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id; - } - return invalid_ID; } @@ -169,6 +164,24 @@ } } +/** Return the ID (if ever available) of a previously inserted entity. + * @param grf_local_id ID of this enity withing the grfID + * @param grfid ID of the grf file + * @return the ID of the candidate, of the Invalid flag item ID + */ +uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) +{ + uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid); + if (id != invalid_ID) return id; + + /* No mapping found, try the overrides */ + for (id = 0; id < max_offset; id++) { + if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id; + } + + return invalid_ID; +} + /** Method to find an entity ID and to mark it as reserved for the Industry to be included. * @param grf_local_id ID used by the grf file for pre-installation work (equivalent of TTDPatch's setid * @param grfid ID of the current grf file diff -r f68ac871be5c -r 6fc05c8ecf87 src/newgrf_commons.h --- a/src/newgrf_commons.h Fri Feb 08 16:25:55 2008 +0000 +++ b/src/newgrf_commons.h Fri Feb 08 16:56:52 2008 +0000 @@ -49,7 +49,7 @@ virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id); uint16 GetSubstituteID(byte entity_id); - uint16 GetID(uint8 grf_local_id, uint32 grfid); + virtual uint16 GetID(uint8 grf_local_id, uint32 grfid); inline uint16 GetMaxMapping() { return max_new_entities; } inline uint16 GetMaxOffset() { return max_offset; } @@ -72,6 +72,7 @@ OverrideManagerBase(offset, maximum, invalid) {} virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id); + virtual uint16 GetID(uint8 grf_local_id, uint32 grfid); void SetEntitySpec(IndustrySpec *inds); };