Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
authorsheepluva
Wed, 27 Apr 2016 16:20:59 +0200
changeset 11744 ac58a063d26a
parent 11743 eefa04b23c3b
child 11745 2ca312efcbb8
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
ChangeLog.txt
QTfrontend/model/MapModel.cpp
QTfrontend/model/MapModel.h
QTfrontend/model/roomslistmodel.cpp
QTfrontend/net/hwmap.h
QTfrontend/ui/widget/mapContainer.cpp
hedgewars/uLand.pas
hedgewars/uTypes.pas
--- a/ChangeLog.txt	Wed Apr 27 13:01:38 2016 +0200
+++ b/ChangeLog.txt	Wed Apr 27 16:20:59 2016 +0200
@@ -8,6 +8,7 @@
  + Small visual effects enhancements
  + Divided Teams mode will now work with more than 2 teams (Hint: you probably want to set world edges to "wrap" in such games)
  + Fort Mode will now work with more than 2 teams
+ + Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
  * Video recording functionality is restored
  * Gameplay fix: Hammer damage is now rounded down. This means it will cause NO DAMAGE to a hedgehog with less than 3 hp.
  * Fixed bee not being affected by wrap world edge while still being thrown
--- a/QTfrontend/model/MapModel.cpp	Wed Apr 27 13:01:38 2016 +0200
+++ b/QTfrontend/model/MapModel.cpp	Wed Apr 27 16:20:59 2016 +0200
@@ -32,7 +32,7 @@
 MapModel::MapInfo MapModel::MapInfoMaze = {MapModel::GeneratedMaze, "+maze+", "", 0, "", "", "", false};
 MapModel::MapInfo MapModel::MapInfoPerlin = {MapModel::GeneratedMaze, "+perlin+", "", 0, "", "", "", false};
 MapModel::MapInfo MapModel::MapInfoDrawn = {MapModel::HandDrawnMap, "+drawn+", "", 0, "", "", "", false};
-
+MapModel::MapInfo MapModel::MapInfoForts = {MapModel::FortsMap, "+forts+", "", 0, "", "", "", false};
 
 MapModel::MapModel(MapType maptype, QObject *parent) : QStandardItemModel(parent)
 {
--- a/QTfrontend/model/MapModel.h	Wed Apr 27 13:01:38 2016 +0200
+++ b/QTfrontend/model/MapModel.h	Wed Apr 27 16:20:59 2016 +0200
@@ -52,7 +52,8 @@
             GeneratedPerlin,
             HandDrawnMap,
             MissionMap,
-            StaticMap
+            StaticMap,
+            FortsMap
         };
 
         /// a struct for holding the attributes of a map.
@@ -99,7 +100,7 @@
         QStandardItem * getMap(const QString & map);
 
         // Static MapInfos for drawn and generated maps
-        static MapInfo MapInfoRandom, MapInfoMaze, MapInfoPerlin, MapInfoDrawn;
+        static MapInfo MapInfoRandom, MapInfoMaze, MapInfoPerlin, MapInfoDrawn, MapInfoForts;
 
         /// Loads the maps
         bool loadMaps();
--- a/QTfrontend/model/roomslistmodel.cpp	Wed Apr 27 13:01:38 2016 +0200
+++ b/QTfrontend/model/roomslistmodel.cpp	Wed Apr 27 16:20:59 2016 +0200
@@ -150,6 +150,7 @@
                 if (content == "+maze+") return tr("Random Maze");
                 if (content == "+perlin+") return tr("Random Perlin");
                 if (content == "+drawn+") return tr("Hand-drawn");
+                if (content == "+forts+") return tr("Forts");
             }
 
             // prefix ? if map not available
--- a/QTfrontend/net/hwmap.h	Wed Apr 27 13:01:38 2016 +0200
+++ b/QTfrontend/net/hwmap.h	Wed Apr 27 16:20:59 2016 +0200
@@ -32,7 +32,8 @@
     MAPGEN_MAZE = 1,
     MAPGEN_PERLIN = 2,
     MAPGEN_DRAWN = 3,
-    MAPGEN_MAP = 4
+    MAPGEN_FORTS = 4,
+    MAPGEN_MAP = 5
 };
 
 class HWMap : public TCPBase
--- a/QTfrontend/ui/widget/mapContainer.cpp	Wed Apr 27 13:01:38 2016 +0200
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Wed Apr 27 16:20:59 2016 +0200
@@ -109,6 +109,7 @@
     cType->insertItem(3, tr("Randomly generated"), MapModel::GeneratedMap);
     cType->insertItem(4, tr("Random maze"), MapModel::GeneratedMaze);
     cType->insertItem(5, tr("Random perlin"), MapModel::GeneratedPerlin);
+    cType->insertItem(6, tr("Forts"), MapModel::FortsMap);
     connect(cType, SIGNAL(currentIndexChanged(int)), this, SLOT(mapTypeChanged(int)));
     m_childWidgets << cType;
 
@@ -461,6 +462,10 @@
     {
         //changeMapType(MapModel::HandDrawnMap);
     }
+    else if (map == "+forts+")
+    {
+        //nuffin
+    }
     else if (m_staticMapModel->mapExists(map))
     {
         changeMapType(MapModel::StaticMap, m_staticMapModel->index(m_staticMapModel->findMap(map), 0));
@@ -500,6 +505,7 @@
         case MapModel::GeneratedMap:
         case MapModel::GeneratedMaze:
         case MapModel::GeneratedPerlin:
+        case MapModel::FortsMap:
             setRandomTheme();
             break;
         case MapModel::MissionMap:
@@ -588,6 +594,10 @@
                 m_mapInfo.type = MapModel::HandDrawnMap;
                 f = true;
                 break;
+            case MAPGEN_FORTS:
+                m_mapInfo.type = MapModel::FortsMap;
+                f = true;
+                break;
             case MAPGEN_MAP:
                 switch (m_mapInfo.type)
                 {
@@ -595,6 +605,7 @@
                     case MapModel::GeneratedMaze:
                     case MapModel::GeneratedPerlin:
                     case MapModel::HandDrawnMap:
+                    case MapModel::FortsMap:
                         m_mapInfo.type = MapModel::Invalid;
                     default:
                         break;
@@ -679,6 +690,7 @@
         case MapModel::GeneratedMaze:
         case MapModel::GeneratedPerlin:
         case MapModel::HandDrawnMap:
+        case MapModel::FortsMap:
             askForGeneratedPreview();
             break;
         default:
@@ -804,6 +816,11 @@
             staticMapList->show();
             emit mapChanged(m_curMap);
             break;
+        case MapModel::FortsMap:
+            mapgen = MAPGEN_FORTS;
+            setMapInfo(MapModel::MapInfoForts);
+            lblMapList->hide();
+            break;
         default:
             break;
     }
--- a/hedgewars/uLand.pas	Wed Apr 27 13:01:38 2016 +0200
+++ b/hedgewars/uLand.pas	Wed Apr 27 16:20:59 2016 +0200
@@ -348,27 +348,70 @@
     AddProgress();
 end;
 
+procedure MakeFortsPreview;
+var gap, offset, h1, h2, w1, w2, x, y: LongInt;
+const fortHeight = 960;
+      fortWidth  = 720;
+begin
+ResizeLand(4096,2048);
+
+gap:= (1024 - fortWidth) + 60 + 20 * cFeatureSize;
+offset:= fortWidth + gap;
+
+h2:= LAND_HEIGHT-1;
+h1:= h2 - fortHeight;
+w2:= (LAND_WIDTH - gap) div 2;
+w1:= w2 - fortWidth;
+
+// generate 2 forts in center
+for y:= h1 to h2 do
+    for x:= w1 to w2 do
+        begin
+        Land[y,x]:= lfBasic;
+        Land[y,x+offset]:= lfBasic;
+        end;
+
+w2:= w1 - gap;
+w1:= w2 - fortWidth;
+offset:= offset + 2 * (fortWidth + gap);
+if w1 < 0 then
+    begin
+    offset:= LAND_WIDTH - 1 - (fortWidth+w1);
+    w1:= 0;
+    end;
+
+for y:= h1 to h2 do
+    for x:= w1 to w2 do
+        if ((x - y) mod 2) = 0 then
+            begin
+            Land[y,x]:= lfBasic;
+            Land[y,x+offset]:= lfBasic;
+            end;
+end;
+
 procedure MakeFortsMap;
 var tmpsurf: PSDL_Surface;
-    i, t, p: integer;
+    sectionWidth, i, t, p: integer;
     mirror: boolean;
     pc: PClan;
-const sectionWidth = 1024 + 300;
 begin
 
+// make the gaps between forts adjustable if fort map was selected
+if cMapGen = mgForts then
+    sectionWidth:= 1024 + 60 + 20 * cFeatureSize
+else
+    sectionWidth:= 1024 * 300;
+
 // mix up spawn/fort order of clans
-if ((GameFlags and gfForts) <> 0) then
+for i:= 0 to ClansCount - 1 do
     begin
-    for i:= 0 to ClansCount - 1 do
+    t:= GetRandom(ClansCount);
+    p:= GetRandom(ClansCount);
+    if t <> p then
         begin
-        t:= GetRandom(ClansCount);
-        p:= GetRandom(ClansCount);
-        if t <> p then
-            begin
-            pc:= SpawnClansArray[t];
-            SpawnClansArray[t]:= SpawnClansArray[p];
-            SpawnClansArray[p]:= pc;
-            end;
+        pc:= SpawnClansArray[t];
+        SpawnClansArray[t]:= SpawnClansArray[p];
+        SpawnClansArray[p]:= pc;
         end;
     end;
 
@@ -597,10 +640,12 @@
                 mgMaze  : begin ResizeLand(4096,2048); GenMaze; end;
                 mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
                 mgDrawn : GenDrawnMap;
+                mgForts : begin GameFlags:= (GameFlags or gfForts or gfDivideTeams); MakeFortsMap(); end;
             else
                 OutError('Unknown mapgen', true);
             end;
-            GenLandSurface
+            if cMapGen <> mgForts then
+                GenLandSurface
             end
     else
         MakeFortsMap;
@@ -740,6 +785,7 @@
         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
         mgDrawn: GenDrawnMap;
+        mgForts: MakeFortsPreview();
     else
         OutError('Unknown mapgen', true);
     end;
@@ -788,6 +834,7 @@
         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
         mgDrawn: GenDrawnMap;
+        mgForts: MakeFortsPreview;
     else
         OutError('Unknown mapgen', true);
     end;
--- a/hedgewars/uTypes.pas	Wed Apr 27 13:01:38 2016 +0200
+++ b/hedgewars/uTypes.pas	Wed Apr 27 16:20:59 2016 +0200
@@ -180,7 +180,7 @@
     TStereoMode = (smNone, smRedCyan, smCyanRed, smRedBlue, smBlueRed, smRedGreen, smGreenRed, smHorizontal, smVertical);
     TWorldEdge = (weNone, weWrap, weBounce, weSea, weSky);
     TUIDisplay = (uiAll, uiNoTeams, uiNone);
-    TMapGen = (mgRandom, mgMaze, mgPerlin, mgDrawn);
+    TMapGen = (mgRandom, mgMaze, mgPerlin, mgDrawn, mgForts);
 
 
     THHFont = record