src/newgrf_house.cpp
branchgamebalance
changeset 9912 1ac8aac92385
parent 9911 0b8b245a2391
child 9913 e79cd19772dd
--- a/src/newgrf_house.cpp	Wed Jun 13 11:45:14 2007 +0000
+++ b/src/newgrf_house.cpp	Wed Jun 13 12:05:56 2007 +0000
@@ -83,7 +83,7 @@
 {
 	HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
 
-	if (!_have_newhouses) return;
+	if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return;
 
 	/* If there are 255 buildings of this type in this town, there are also
 	 * at least that many houses of the same class in the town, and
@@ -111,7 +111,7 @@
 {
 	HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
 
-	if (!_have_newhouses) return;
+	if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return;
 
 	if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--;
 	if (_building_counts.id_count[house_id] > 0)   _building_counts.id_count[house_id]--;
@@ -129,7 +129,7 @@
  */
 void AfterLoadCountBuildings()
 {
-	if (!_have_newhouses) return;
+	if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return;
 
 	for (TileIndex t = 0; t < MapSize(); t++) {
 		if (!IsTileType(t, MP_HOUSE)) continue;
@@ -169,15 +169,6 @@
 	return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
 }
 
-static uint32 GetTerrainType(TileIndex tile)
-{
-	switch (_opt.landscape) {
-		case LT_TROPIC: return GetTropicZone(tile) == TROPICZONE_DESERT ? 1 : 2;
-		case LT_ARCTIC: return GetTileZ(tile) >= GetSnowLine() ? 4 : 0;
-		default:        return 0;
-	}
-}
-
 static uint32 GetGRFParameter(HouseID house_id, byte parameter)
 {
 	const HouseSpec *hs = GetHouseSpecs(house_id);
@@ -187,6 +178,16 @@
 	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():
  *
@@ -238,20 +239,7 @@
 		}
 
 		/* 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);