summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-04-15 13:10:01 +0000
committerfrosch <frosch@openttd.org>2008-04-15 13:10:01 +0000
commit9346e067f39870943d979ae5deb82f831190dc25 (patch)
treec2aba7bcd05c772b05d72b03293b3c554c4c9a11
parent7ba1d9076f4eea0930214be0ec1a054a467e301b (diff)
downloadopenttd-9346e067f39870943d979ae5deb82f831190dc25.tar.xz
(svn r12717) -Fix (r11107): Check the TILE_NOT_SLOPED flag of the _north_ tile of multi-tile houses to decide if autoslope is allowed.
-rw-r--r--src/town_cmd.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 70295f596..156eb66de 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1992,6 +1992,33 @@ static void DoClearTownHouseHelper(TileIndex tile)
DeleteAnimatedTile(tile);
}
+/**
+ * Determines if a given HouseID is part of a multitile house.
+ * The given ID is set to the ID of the north tile and the TileDiff to the north tile is returned.
+ *
+ * @param house Is changed to the HouseID of the north tile of the same house
+ * @return TileDiff from the tile of the given HouseID to the north tile
+ */
+static TileIndex GetHouseNorthPart(HouseID &house)
+{
+ if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
+ if (GetHouseSpecs(house - 1)->building_flags & TILE_SIZE_2x1) {
+ house--;
+ return TileDiffXY(-1, 0);
+ } else if (GetHouseSpecs(house - 1)->building_flags & BUILDING_2_TILES_Y) {
+ house--;
+ return TileDiffXY(0, -1);
+ } else if (GetHouseSpecs(house - 2)->building_flags & BUILDING_HAS_4_TILES) {
+ house -= 2;
+ return TileDiffXY(-1, 0);
+ } else if (GetHouseSpecs(house - 3)->building_flags & BUILDING_HAS_4_TILES) {
+ house -= 3;
+ return TileDiffXY(-1, -1);
+ }
+ }
+ return 0;
+}
+
void ClearTownHouse(Town *t, TileIndex tile)
{
assert(IsTileType(tile, MP_HOUSE));
@@ -1999,21 +2026,7 @@ void ClearTownHouse(Town *t, TileIndex tile)
HouseID house = GetHouseType(tile);
/* need to align the tile to point to the upper left corner of the house */
- if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
- if (GetHouseSpecs(house-1)->building_flags & TILE_SIZE_2x1) {
- house--;
- tile += TileDiffXY(-1, 0);
- } else if (GetHouseSpecs(house-1)->building_flags & BUILDING_2_TILES_Y) {
- house--;
- tile += TileDiffXY(0, -1);
- } else if (GetHouseSpecs(house-2)->building_flags & BUILDING_HAS_4_TILES) {
- house-=2;
- tile += TileDiffXY(-1, 0);
- } else if (GetHouseSpecs(house-3)->building_flags & BUILDING_HAS_4_TILES) {
- house-=3;
- tile += TileDiffXY(-1, -1);
- }
- }
+ tile += GetHouseNorthPart(house); // modifies house to the ID of the north tile
const HouseSpec *hs = GetHouseSpecs(house);
@@ -2536,6 +2549,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, uint32 flags, uint z_new,
{
if (AutoslopeEnabled()) {
HouseID house = GetHouseType(tile);
+ GetHouseNorthPart(house); // modifies house to the ID of the north tile
const HouseSpec *hs = GetHouseSpecs(house);
/* Here we differ from TTDP by checking TILE_NOT_SLOPED */