Calculate max. recommended hog count for perlin maps
authorWuzzy <Wuzzy2@mail.ru>
Sun, 19 May 2019 23:52:13 +0200
changeset 15016 bea068dd9356
parent 15015 5d8068ee16fc
child 15017 73edada4d71d
Calculate max. recommended hog count for perlin maps
ChangeLog.txt
hedgewars/uLandGenPerlin.pas
--- a/ChangeLog.txt	Sun May 19 21:14:53 2019 +0200
+++ b/ChangeLog.txt	Sun May 19 23:52:13 2019 +0200
@@ -124,6 +124,7 @@
  + Display a warning when the same key is used multiple times
  + Stats screen now hides empty sections
  + Visual notification when someone joins the room online
+ + Display recommended max. hedgehog count for Perlin maps
  + Various minor style tweaks
  * Fix broken handling of /watch chat command on official server
  * Fix renaming a video leading to loss of thumbnail after restart
--- a/hedgewars/uLandGenPerlin.pas	Sun May 19 21:14:53 2019 +0200
+++ b/hedgewars/uLandGenPerlin.pas	Sun May 19 23:52:13 2019 +0200
@@ -135,6 +135,43 @@
 
     df:= detail * (6 - param2 * 2);
 
+    // Calculate estimate for max. hedgehog count
+    // Tunnels
+    if param1 = 0 then
+        begin
+        // Small tunnels
+        if param2 = 0 then
+            // 12..24
+            MaxHedgehogs:= 12 + 1 * (cFeatureSize - 1)
+        // Medium tunnels
+        else if param2 = 1 then
+            // 14..24
+            MaxHedgehogs:= 14 + max(0, 1 * (cFeatureSize - 3))
+        // Large tunnels
+        else if param2 = 2 then
+            // 16..24
+            MaxHedgehogs:= 16 + max(0, 1 * (cFeatureSize - 5));
+        if MaxHedgehogs > 24 then
+            MaxHedgehogs:= 24;
+        end
+    // Islands
+    else if (param1 = 1) and (cFeatureSize <= 25) then
+        // Small islands
+        if param2 = 0 then
+            // 64..32
+            MaxHedgehogs:= 32 + ((((25 - (cFeatureSize-1))*1000000) div 24) * 32) div 1000000
+        // Medium islands
+        else if param2 = 1 then
+            // 56..28
+            MaxHedgehogs:= 28 + ((((25 - (cFeatureSize-1))*1000000) div 24) * 28) div 1000000
+        // Large islands
+        else if param2 = 2 then
+            // 48..24
+            MaxHedgehogs:= 24 + ((((25 - (cFeatureSize-1))*1000000) div 24) * 24) div 1000000;
+    // We only want even numbers
+    if (MaxHedgehogs > 0) and ((MaxHedgehogs mod 2) = 1) then
+        MaxHedgehogs:= MaxHedgehogs - 1;
+
     inoise_setup();
 
     for y:= minY to pred(height) do