diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_commons.cpp | 10 | ||||
-rw-r--r-- | src/newgrf_commons.h | 1 | ||||
-rw-r--r-- | src/newgrf_house.cpp | 25 |
3 files changed, 22 insertions, 14 deletions
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 5291bbac9..9e796aa60 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -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); +} diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 070fb1feb..a7c00e65c 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -67,5 +67,6 @@ public: extern HouseOverrideManager _house_mngr; uint32 GetTerrainType(TileIndex tile); +TileIndex GetNearbyTile(byte parameter, TileIndex tile); #endif /* NEWGRF_COMMONS_H */ diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index b36628c2a..d5d68e844 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -178,6 +178,16 @@ static uint32 GetGRFParameter(HouseID house_id, byte parameter) 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 ResolverObject *object, byte variable, byte } /* 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); |