diff options
author | belugas <belugas@openttd.org> | 2007-06-08 17:54:18 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2007-06-08 17:54:18 +0000 |
commit | e8c6d571508fbb49636b7fc1b70b58813d2caaa3 (patch) | |
tree | cd5fc9ecbc88d18cd0dec7eeae1bc0713a76e991 /src | |
parent | 6983d0b547ce9248a658ffa5d6c76c860d08a72e (diff) | |
download | openttd-e8c6d571508fbb49636b7fc1b70b58813d2caaa3.tar.xz |
(svn r10066) -Codechange: Expose function GetNearbyTile by moving it to newgrf_commons.[cpp|h]. Will be used by industries in a few.
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); |