Give a more accurate hedgehog limit estimate for small drawn maps
authorWuzzy <Wuzzy2@mail.ru>
Sun, 19 May 2019 21:14:53 +0200
changeset 15031 5d8068ee16fc
parent 15030 d45c41b223cf
child 15032 bea068dd9356
Give a more accurate hedgehog limit estimate for small drawn maps
QTfrontend/ui/widget/mapContainer.cpp
hedgewars/uLand.pas
--- a/QTfrontend/ui/widget/mapContainer.cpp	Sun May 19 11:26:36 2019 +0200
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Sun May 19 21:14:53 2019 +0200
@@ -1093,13 +1093,8 @@
 {
     m_mapFeatureSize = val;
     intSetFeatureSize(val);
-    //m_mapFeatureSize = val>>2<<2;
-    //if (qAbs(m_prevMapFeatureSize-m_mapFeatureSize) > 4)
-    {
-        m_prevMapFeatureSize = m_mapFeatureSize;
-        if(m_mapInfo.type!= MapModel::HandDrawnMap || m_script.length() > 0)
-            updatePreview();
-    }
+    m_prevMapFeatureSize = m_mapFeatureSize;
+    updatePreview();
 }
 
 // unused because I needed the space for the slider
--- a/hedgewars/uLand.pas	Sun May 19 11:26:36 2019 +0200
+++ b/hedgewars/uLand.pas	Sun May 19 21:14:53 2019 +0200
@@ -285,10 +285,22 @@
 
 procedure GenDrawnMap;
 begin
+    if (cFeatureSize <= 6) then
+        MaxHedgehogs:= 6 + (cFeatureSize-1) * 2
+    else if (cFeatureSize < 11) then
+        MaxHedgehogs:= 16 + (cFeatureSize-6) * 4
+    else if (cFeatureSize = 11) then
+        MaxHedgehogs:= 48
+    else if (cFeatureSize = 12) then
+        MaxHedgehogs:= 64
+    else
+        MaxHedgehogs:= cMaxHHs;
+
+    if GameType = gmtLandPreview then
+        cFeatureSize:= 3;
     ResizeLand((4096 * max(min(cFeatureSize,24),3)) div 12, (2048 * max(min(cFeatureSize,24),3)) div 12);
     uLandPainted.Draw;
 
-    MaxHedgehogs:= 64;
     hasGirders:= true;
     playHeight:= LAND_HEIGHT;
     playWidth:= LAND_WIDTH;
@@ -886,7 +898,7 @@
         mgRandom: GenTemplated(EdgeTemplates[SelectTemplate]);
         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
-        mgDrawn: begin cFeatureSize:= 3;GenDrawnMap; end;
+        mgDrawn: begin GenDrawnMap; end;
         mgForts: MakeFortsPreview();
     else
         OutError('Unknown mapgen', true);
@@ -945,7 +957,7 @@
         mgRandom: GenTemplated(EdgeTemplates[SelectTemplate]);
         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
-        mgDrawn: begin cFeatureSize:= 3;GenDrawnMap; end;
+        mgDrawn: begin GenDrawnMap; end;
         mgForts: MakeFortsPreview;
     else
         OutError('Unknown mapgen', true);