diff options
author | tron <tron@openttd.org> | 2005-07-21 06:31:02 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-07-21 06:31:02 +0000 |
commit | d71788c40206fa35b792d34769fde7768b4456c1 (patch) | |
tree | dc5c9c74cec9bfa29f94932a20193cd902a80f15 /clear_cmd.c | |
parent | 5c5840417e2f03514c51098f4786c6c1d6030b59 (diff) | |
download | openttd-d71788c40206fa35b792d34769fde7768b4456c1.tar.xz |
(svn r2660) Get rid of some more shifting/anding/casting
Diffstat (limited to 'clear_cmd.c')
-rw-r--r-- | clear_cmd.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/clear_cmd.c b/clear_cmd.c index 38f1ccd68..7d0227f64 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -742,7 +742,7 @@ static void TileLoop_Clear(TileIndex tile) } /* did overflow, so continue */ } else { - m5 = ((byte)Random() > 21) ? (2) : (6); + m5 = (GB(Random(), 0, 8) > 21) ? 2 : 6; } m5++; } else if (_game_mode != GM_EDITOR) { @@ -767,29 +767,27 @@ static void TileLoop_Clear(TileIndex tile) void GenerateClearTile(void) { - int i,j; + uint i; TileIndex tile; - uint32 r; /* add hills */ i = ScaleByMapSize((Random() & 0x3FF) + 0x400); do { tile = RandomTile(); - if (IsTileType(tile, MP_CLEAR)) - _m[tile].m5 = (byte)((_m[tile].m5 & ~(3<<2)) | (1<<2)); + if (IsTileType(tile, MP_CLEAR)) SB(_m[tile].m5, 2, 2, 1); } while (--i); /* add grey squares */ i = ScaleByMapSize((Random() & 0x7F) + 0x80); do { - r = Random(); + uint32 r = Random(); tile = RandomTileSeed(r); if (IsTileType(tile, MP_CLEAR)) { - j = GB(r, 16, 4) + 5; + uint j = GB(r, 16, 4) + 5; for(;;) { TileIndex tile_new; - _m[tile].m5 = (byte)((_m[tile].m5 & ~(3<<2)) | (2<<2)); + SB(_m[tile].m5, 2, 2, 2); do { if (--j == 0) goto get_out; tile_new = tile + TileOffsByDir(Random() & 3); |