Changeset - r17938:d5dd4c8acedd
[Not reviewed]
master
0 1 0
planetmaker - 13 years ago 2011-08-18 14:08:51
planetmaker@openttd.org
(svn r22757) -Fix [FS#4730]: [NewGRF] Invalid memory access when querying the grfID of the default objects
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/newgrf_object.cpp
Show inline comments
 
@@ -131,24 +131,29 @@ static void ObjectSetTriggers(const Reso
 
 * @param tile TileIndex of the tile to query
 
 * @param cur_grfid GRFID of the current callback chain
 
 * @return value encoded as per NFO specs
 
 */
 
static uint32 GetObjectIDAtOffset(TileIndex tile, uint32 cur_grfid)
 
{
 
	if (!IsTileType(tile, MP_OBJECT)) {
 
		return 0xFFFF;
 
	}
 

	
 
	const ObjectSpec *spec = ObjectSpec::GetByTile(tile);
 

	
 
	/* Default objects have no associated NewGRF file */
 
	if (spec->grf_prop.grffile == NULL) {
 
		return 0xFFFE; // Defined in another grf file
 
	}
 

	
 
	if (spec->grf_prop.grffile->grfid == cur_grfid) { // same object, same grf ?
 
		return spec->grf_prop.local_id;
 
	}
 

	
 
	return 0xFFFE; // Defined in another grf file
 
}
 

	
 
/**
 
 * Based on newhouses equivalent, but adapted for newobjects
 
 * @param parameter from callback.  It's in fact a pair of coordinates
 
 * @param tile TileIndex from which the callback was initiated
 
 * @param index of the object been queried for
0 comments (0 inline, 0 general)