summaryrefslogtreecommitdiff
path: root/unmovable_cmd.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-19 10:00:30 +0000
committertruelight <truelight@openttd.org>2006-08-19 10:00:30 +0000
commit7abad2b20ee239c96f702b2463c98aca4f58aacf (patch)
treecd9ad6758b68622254b2545359b5d87f88f7074b /unmovable_cmd.c
parentd3f2180438830f8fefc1e319276d33a914fee767 (diff)
downloadopenttd-7abad2b20ee239c96f702b2463c98aca4f58aacf.tar.xz
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin) - Load heightmaps (either BMP or PNG) - Progress dialog while generating worlds (no longer a 'hanging' screen) - New dialogs for NewGame, Create Scenario and Play Heightmap - Easier to configure your landscape - More things to configure (tree-placer, ..) - Speedup of world generation - New console command 'restart': restart the map EXACTLY as it was when you first started it (needs a game made after or with this commit) - New console command 'getseed': get the seed of your map and share it with others (of course only works with generated maps) - Many new, world generation related, things - Many internal cleanups and rewrites Many tnx to those people who helped making this: Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic) Many tnx to those who helped testing: Arnau, Bjarni, and tokai (alfabetic) And to all other people who helped testing and sending comments / bugs Stats: 673 lines changed, 3534 new lines, 79 new strings
Diffstat (limited to 'unmovable_cmd.c')
-rw-r--r--unmovable_cmd.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 0188900e6..7bcca8940 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -18,6 +18,7 @@
#include "unmovable_map.h"
#include "variables.h"
#include "table/unmovable_land.h"
+#include "genworld.h"
/** Destroy a HQ.
* During normal gameplay you can only implicitely destroy a HQ when you are
@@ -309,12 +310,13 @@ static bool IsRadioTowerNearby(TileIndex tile)
BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
if (IsTransmitterTile(tile)) return true;
END_TILE_LOOP(tile, 9, 9, tile_s)
+
return false;
}
void GenerateUnmovables(void)
{
- int i,j;
+ int i, li, j, loop_count;
TileIndex tile;
uint h;
uint maxx;
@@ -324,12 +326,16 @@ void GenerateUnmovables(void)
/* add radio tower */
i = ScaleByMapSize(1000);
- j = ScaleByMapSize(40); // maximum number of radio towers on the map
+ j = ScaleByMapSize(15); // maximum number of radio towers on the map
+ li = ScaleByMapSize1D((Random() & 3) + 7);
+ SetGeneratingWorldProgress(GWP_UNMOVABLE, j + li);
+
do {
tile = RandomTile();
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4) {
if (IsRadioTowerNearby(tile)) continue;
MakeTransmitter(tile);
+ IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
if (--j == 0) break;
}
} while (--i);
@@ -337,16 +343,27 @@ void GenerateUnmovables(void)
if (_opt.landscape == LT_DESERT) return;
/* add lighthouses */
- i = ScaleByMapSize1D((Random() & 3) + 7);
+ i = li;
maxx = MapMaxX();
maxy = MapMaxY();
+ loop_count = 0;
do {
uint32 r;
DiagDirection dir;
+ int perimeter;
restart:
+ /* Avoid infinite loops */
+ if (++loop_count > 1000) break;
+
r = Random();
- dir = GB(r, 30, 2);
+
+ /* Scatter the lighthouses more evenly around the perimeter */
+ perimeter = (GB(r, 16, 16) % (2 * (maxx + maxy))) - maxy;
+ for (dir = DIAGDIR_NE; perimeter > 0; dir++) {
+ perimeter -= (DiagDirToAxis(dir) == AXIS_X) ? maxx : maxy;
+ }
+
switch (dir) {
default:
case DIAGDIR_NE: tile = TileXY(maxx, r % maxy); break;
@@ -363,6 +380,7 @@ restart:
assert(tile == TILE_MASK(tile));
MakeLighthouse(tile);
+ IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
} while (--i);
}