summaryrefslogtreecommitdiff
path: root/src/newgrf_house.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-06-08 17:54:18 +0000
committerbelugas <belugas@openttd.org>2007-06-08 17:54:18 +0000
commite8c6d571508fbb49636b7fc1b70b58813d2caaa3 (patch)
treecd5fc9ecbc88d18cd0dec7eeae1bc0713a76e991 /src/newgrf_house.cpp
parent6983d0b547ce9248a658ffa5d6c76c860d08a72e (diff)
downloadopenttd-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/newgrf_house.cpp')
-rw-r--r--src/newgrf_house.cpp25
1 files changed, 11 insertions, 14 deletions
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);