GRF: Use access mask when evaluating get nearby tile information variable
This commit is contained in:
@@ -444,22 +444,33 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axi
|
||||
* @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
|
||||
* @return 0czzbbss: c = TileType; zz = TileZ; bb: 7-3 zero, 4-2 TerrainType, 1 water/shore, 0 zero; ss = TileSlope
|
||||
*/
|
||||
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
|
||||
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8, uint32 mask)
|
||||
{
|
||||
TileType tile_type = GetTileType(tile);
|
||||
uint32 result = 0;
|
||||
TileType tile_type = MP_CLEAR;
|
||||
if (mask & 0xFF000200) {
|
||||
tile_type = GetTileType(tile);
|
||||
|
||||
/* Fake tile type for trees on shore */
|
||||
if (IsTileType(tile, MP_TREES) && GetTreeGround(tile) == TREE_GROUND_SHORE) tile_type = MP_WATER;
|
||||
/* Fake tile type for trees on shore */
|
||||
if (IsTileType(tile, MP_TREES) && GetTreeGround(tile) == TREE_GROUND_SHORE) tile_type = MP_WATER;
|
||||
|
||||
/* Fake tile type for road waypoints */
|
||||
if (IsRoadWaypointTile(tile)) tile_type = MP_ROAD;
|
||||
/* Fake tile type for road waypoints */
|
||||
if (IsRoadWaypointTile(tile)) tile_type = MP_ROAD;
|
||||
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
/* Return 0 if the tile is a land tile */
|
||||
byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
|
||||
if (grf_version8) z /= TILE_HEIGHT;
|
||||
return tile_type << 24 | Clamp(z, 0, 0xFF) << 16 | terrain_type << 8 | tileh;
|
||||
result |= tile_type << 24;
|
||||
}
|
||||
if (mask & 0xFF00) {
|
||||
/* Return 0 if the tile is a land tile */
|
||||
byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
|
||||
result |= terrain_type << 8;
|
||||
}
|
||||
if (mask & 0xFF00FF) {
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
if (grf_version8) z /= TILE_HEIGHT;
|
||||
result |= Clamp(z, 0, 0xFF) << 16 | tileh;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user