summaryrefslogtreecommitdiff
path: root/landscape.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-02-13 21:15:00 +0000
committertron <tron@openttd.org>2006-02-13 21:15:00 +0000
commit5352e9fbcbd3b4dca63746f5cf74b1541b8ebb6c (patch)
tree19340b96ef341c9784a27b719a1a90c2c691ca56 /landscape.c
parent8744075a6cb64578f7e255220d76b77b26eb1a45 (diff)
downloadopenttd-5352e9fbcbd3b4dca63746f5cf74b1541b8ebb6c.tar.xz
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
Diffstat (limited to 'landscape.c')
-rw-r--r--landscape.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/landscape.c b/landscape.c
index 4cffefe65..af0b8cb9b 100644
--- a/landscape.c
+++ b/landscape.c
@@ -461,8 +461,8 @@ void ConvertGroundTilesIntoWaterTiles(void)
for (tile = 0; tile < MapSize(); ++tile) {
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
SetTileType(tile, MP_WATER);
- _m[tile].m5 = 0;
SetTileOwner(tile, OWNER_WATER);
+ _m[tile].m5 = 0;
}
}
}
@@ -630,37 +630,48 @@ void GenerateLandscape(void)
uint flag;
uint32 r;
- if (_opt.landscape == LT_HILLY) {
- for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i)
- GenerateTerrain(2, 0);
+ switch (_opt.landscape) {
+ case LT_HILLY:
+ for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i) {
+ GenerateTerrain(2, 0);
+ }
+
+ r = Random();
+ flag = GB(r, 0, 2) | 4;
+ for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i) {
+ GenerateTerrain(4, flag);
+ }
+ break;
+
+ case LT_DESERT:
+ for (i = ScaleByMapSize((Random() & 0x7F) + 170); i != 0; --i) {
+ GenerateTerrain(0, 0);
+ }
- r = Random();
- 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 = GB(r, 0, 2) | 4;
+ for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i) {
+ GenerateTerrain(0, flag);
+ }
- r = Random();
- flag = GB(r, 0, 2) | 4;
- for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i)
- GenerateTerrain(0, flag);
+ flag ^= 2;
- flag ^= 2;
+ for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i) {
+ GenerateTerrain(3, flag);
+ }
+ break;
- for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i)
- GenerateTerrain(3, flag);
- } else {
- i = ScaleByMapSize((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
- for (; i != 0; --i)
- GenerateTerrain(_opt.diff.terrain_type, 0);
+ default:
+ i = ScaleByMapSize((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
+ for (; i != 0; --i) {
+ GenerateTerrain(_opt.diff.terrain_type, 0);
+ }
+ break;
}
ConvertGroundTilesIntoWaterTiles();
- if (_opt.landscape == LT_DESERT)
- CreateDesertOrRainForest();
+ if (_opt.landscape == LT_DESERT) CreateDesertOrRainForest();
}
void OnTick_Town(void);