summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-07-28 19:23:19 +0000
committertron <tron@openttd.org>2005-07-28 19:23:19 +0000
commitae44d3aa1f3669ab8e176a9ecf7afeae561674f2 (patch)
treee5fe7890cb50c2ac5b67eea65cded930ecd72c26
parent0e64dc50b6d4dd53c3585c2d4cf5691883caf782 (diff)
downloadopenttd-ae44d3aa1f3669ab8e176a9ecf7afeae561674f2.tar.xz
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
-rw-r--r--clear_cmd.c61
1 files changed, 19 insertions, 42 deletions
diff --git a/clear_cmd.c b/clear_cmd.c
index aa4ae1c25..c7b1208a9 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -570,88 +570,65 @@ static void AnimateTile_Clear(TileIndex tile)
void TileLoopClearHelper(TileIndex tile)
{
- byte img_1;
- byte img_2;
- static const byte img_by_map5[] = { 0, 0, 0, 2, 1, 1, 0, 0 };
+ byte self;
+ byte neighbour;
TileIndex dirty = INVALID_TILE;
switch (GetTileType(tile)) {
case MP_CLEAR:
- img_1 = img_by_map5[(_m[tile].m5 & 0x1C) >> 2];
- break;
-
- case MP_TREES:
- if ((_m[tile].m2 & 0x30) == 0x20)
- img_1 = 1;
- else
- img_1 = 0;
+ self = (GB(_m[tile].m5, 0, 5) == 15);
break;
default:
- img_1 = 0;
+ self = 0;
break;
}
switch (GetTileType(TILE_ADDXY(tile, 1, 0))) {
case MP_CLEAR:
- img_2 = img_by_map5[(_m[TILE_ADDXY(tile, 1, 0)].m5 & 0x1C) >> 2];
- break;
-
- case MP_TREES:
- if ((_m[TILE_ADDXY(tile, 1, 0)].m2 & 0x30) == 0x20)
- img_2 = 1;
- else
- img_2 = 0;
+ neighbour = (GB(_m[TILE_ADDXY(tile, 1, 0)].m5, 0, 5) == 15);
break;
default:
- img_2 = 0;
+ neighbour = 0;
break;
}
- if ((_m[tile].m4 & 0xE0) == 0) {
- if ((img_1 & 2) != (img_2 & 2)) {
- _m[tile].m4 |= 3 << 5;
+ if (GB(_m[tile].m4, 5, 3) == 0) {
+ if (self != neighbour) {
+ SB(_m[tile].m4, 5, 3, 3);
dirty = tile;
}
} else {
- if (img_1 == 1 && img_2 == 1) {
- _m[tile].m4 &= ~(3 << 5);
+ if (self == 0 && neighbour == 0) {
+ SB(_m[tile].m4, 5, 3, 0);
dirty = tile;
}
}
switch (GetTileType(TILE_ADDXY(tile, 0, 1))) {
case MP_CLEAR:
- img_2 = img_by_map5[(_m[TILE_ADDXY(tile, 0, 1)].m5 & 0x1C) >> 2];
- break;
-
- case MP_TREES:
- if ((_m[TILE_ADDXY(tile, 0, 1)].m2 & 0x30) == 0x20)
- img_2 = 1;
- else
- img_2 = 0;
+ neighbour = (GB(_m[TILE_ADDXY(tile, 0, 1)].m5, 0, 5) == 15);
break;
default:
- img_2 = 0;
+ neighbour = 0;
break;
}
- if ((_m[tile].m4 & 0x1C) == 0) {
- if ((img_1 & 2) != (img_2 & 2)) {
- _m[tile].m4 |= 3 << 2;
+ if (GB(_m[tile].m4, 2, 3) == 0) {
+ if (self != neighbour) {
+ SB(_m[tile].m4, 2, 3, 3);
dirty = tile;
}
} else {
- if (img_1 == 1 && img_2 == 1) {
- _m[tile].m4 &= ~(3 << 2);
+ if (self == 0 && neighbour == 0) {
+ SB(_m[tile].m4, 2, 3, 0);
dirty = tile;
}
}
- if (dirty != INVALID_TILE)
- MarkTileDirtyByTile(dirty);
+ if (dirty != INVALID_TILE) MarkTileDirtyByTile(dirty);
}