Changeset - r6827:5f08bab6696e
[Not reviewed]
master
0 3 0
belugas - 17 years ago 2007-06-08 17:54:18
belugas@openttd.org
(svn r10066) -Codechange: Expose function GetNearbyTile by moving it to newgrf_commons.[cpp|h]. Will be used by industries in a few.
3 files changed with 22 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/newgrf_commons.cpp
Show inline comments
 
@@ -165,3 +165,13 @@ uint32 GetTerrainType(TileIndex tile)
 
	}
 
}
 

	
 
TileIndex GetNearbyTile(byte parameter, TileIndex tile)
 
{
 
	int8 x = GB(parameter, 0, 4);
 
	int8 y = GB(parameter, 4, 4);
 

	
 
	if (x >= 8) x -= 16;
 
	if (y >= 8) y -= 16;
 

	
 
	return tile + TileDiffXY(x, y);
 
}
src/newgrf_commons.h
Show inline comments
 
@@ -67,5 +67,6 @@ public:
 
extern HouseOverrideManager _house_mngr;
 

	
 
uint32 GetTerrainType(TileIndex tile);
 
TileIndex GetNearbyTile(byte parameter, TileIndex tile);
 

	
 
#endif /* NEWGRF_COMMONS_H */
src/newgrf_house.cpp
Show inline comments
 
@@ -178,6 +178,16 @@ static uint32 GetGRFParameter(HouseID ho
 
	return file->param[parameter];
 
}
 

	
 
uint32 GetNearbyTileInformation(byte parameter, TileIndex tile)
 
{
 
	uint32 tile_type;
 

	
 
	tile = GetNearbyTile(parameter, tile);
 
	tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1;
 

	
 
	return GetTileType(tile) << 24 | (TileHeight(tile) * 8) << 16 | tile_type << 8 | GetTileSlope(tile, NULL);
 
}
 

	
 
/**
 
 * HouseGetVariable():
 
 *
 
@@ -229,20 +239,7 @@ static uint32 HouseGetVariable(const Res
 
		}
 

	
 
		/* Land info for nearby tiles. */
 
		case 0x62: {
 
			int8 x = GB(parameter, 0, 4);
 
			int8 y = GB(parameter, 4, 4);
 
			byte tile_type;
 

	
 
			if (x >= 8) x -= 16;
 
			if (y >= 8) y -= 16;
 

	
 
			tile += TileDiffXY(x, y);
 

	
 
			tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1;
 

	
 
			return GetTileType(tile) << 24 | (TileHeight(tile) * 8) << 16 | tile_type << 8 | GetTileSlope(tile, NULL);
 
		}
 
		case 0x62: return GetNearbyTileInformation(parameter, tile);
 

	
 
		/* Read GRF parameter */
 
		case 0x7F: return GetGRFParameter(object->u.house.house_id, parameter);
0 comments (0 inline, 0 general)