summaryrefslogtreecommitdiff
path: root/landscape.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-07-20 15:29:28 +0000
committertron <tron@openttd.org>2005-07-20 15:29:28 +0000
commitf09638ad3d3eaf3574086e351a56bf5c14159894 (patch)
treea82679a91beaee405777f0f3c5e3c45814f1ea5d /landscape.c
parentf3645d73073e262d9dba2f4d69a9848be435b7df (diff)
downloadopenttd-f09638ad3d3eaf3574086e351a56bf5c14159894.tar.xz
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
Diffstat (limited to 'landscape.c')
-rw-r--r--landscape.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/landscape.c b/landscape.c
index bd708aea4..2d6b772e8 100644
--- a/landscape.c
+++ b/landscape.c
@@ -352,7 +352,7 @@ void CDECL ModifyTile(TileIndex tile, uint flags, ...)
va_start(va, flags);
- if ((i = (flags >> 8) & 0xF) != 0) {
+ if ((i = GB(flags, 8, 4)) != 0) {
SetTileType(tile, i - 1);
}
@@ -485,7 +485,7 @@ static void GenerateTerrain(int type, int flag)
if (x < 2 || y < 2)
return;
- direction = (r >> 22) & 3;
+ direction = GB(r, 22, 2);
if (direction & 1) {
w = template->height;
h = template->width;
@@ -632,16 +632,16 @@ void GenerateLandscape(void)
GenerateTerrain(2, 0);
r = Random();
- flag = (r & 3) | 4;
- for (i = ScaleByMapSize(((r >> 16) & 0x7F) + 450); i != 0; --i)
+ flag = GB(r, 0, 2) | 4;
+ for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i)
GenerateTerrain(4, flag);
} else if (_opt.landscape == LT_DESERT) {
for (i = ScaleByMapSize((Random()&0x7F) + 170); i != 0; --i)
GenerateTerrain(0, 0);
r = Random();
- flag = (r & 3) | 4;
- for (i = ScaleByMapSize(((r >> 16) & 0xFF) + 1700); i != 0; --i)
+ flag = GB(r, 0, 2) | 4;
+ for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i)
GenerateTerrain(0, flag);
flag ^= 2;