nemo's template patch (invertion)
authorunc0rr
Tue, 27 Jan 2009 15:34:37 +0000
changeset 1773 bc6ad6136675
parent 1772 0fe436fb5f81
child 1774 3627ba6099ca
nemo's template patch (invertion)
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
hedgewars/uLandTemplates.pas
--- a/hedgewars/uLand.pas	Mon Jan 26 21:46:53 2009 +0000
+++ b/hedgewars/uLand.pas	Tue Jan 27 15:34:37 2009 +0000
@@ -494,7 +494,16 @@
          with FillPoints^[i] do
               FillLand(x, y);
 
-DrawEdge(pa, COLOR_LAND)
+DrawEdge(pa, COLOR_LAND);
+
+if (Template.canInvert and (getrandom(2) = 0)) or
+    (not Template.canInvert and Template.isNegative) then 
+    for y:= 0 to LAND_HEIGHT - 1 do
+        for x:= 0 to LAND_WIDTH - 1 do
+            if Land[y, x] = 0 then
+                Land[y, x]:= COLOR_LAND
+            else if Land[y, x] = COLOR_LAND then
+                Land[y, x]:= 0;
 end;
 
 function SelectTemplate: LongInt;
--- a/hedgewars/uLandObjects.pas	Mon Jan 26 21:46:53 2009 +0000
+++ b/hedgewars/uLandObjects.pas	Tue Jan 27 15:34:37 2009 +0000
@@ -273,9 +273,9 @@
                    end
                 end;
              inc(y, 3);
-         until y > LAND_HEIGHT - Height;
+         until y > LAND_HEIGHT - 1 - Height;
          inc(x, getrandom(6) + 3)
-     until x > LAND_WIDTH - Width;
+     until x > LAND_WIDTH - 1 - Width;
      Result:= cnt <> 0;
      if Result then
         begin
--- a/hedgewars/uLandTemplates.pas	Mon Jan 26 21:46:53 2009 +0000
+++ b/hedgewars/uLandTemplates.pas	Tue Jan 27 15:34:37 2009 +0000
@@ -32,7 +32,8 @@
                      FillPointsCount: Longword;
                      BezierizeCount: Longword;
                      RandPassesCount: Longword;
-                     canMirror, canFlip: boolean;
+                     TemplateHeight, TemplateWidth: LongInt;
+                     canMirror, canFlip, isNegative, canInvert: boolean;
                      end;
 
 //////////////////////////////////////////////////////////////////////////////
@@ -86,12 +87,24 @@
       (
        (x: 2047; y:    0)
       );
+const Template1Points: array[0..4] of TSDL_Rect =
+      (
+       (x:  100; y:  100; w:    1; h:    1),
+       (x:  100; y:  100; w: 3000; h: 1500),
+       (x:  500; y:  500; w: 2000; h: 1000),
+       (x: 4000; y: 2000; w:    1; h:    1),
+       (x: NTPX; y:    0; w:    1; h:    1)
+      );
+      Template1FPoints: array[0..0] of TPoint =
+      (
+       (x: 2047; y:    0)
+      );
 
 //////////////////////////////////////////////////////////////////////////////
 /////////////////// END MIRRORED TWO TIMES ///////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
-const EdgeTemplates: array[0..0] of TEdgeTemplate =
+const EdgeTemplates: array[0..1] of TEdgeTemplate =
       (
        (BasePoints: @Template0Points;
         BasePointsCount: Succ(High(Template0Points));
@@ -99,7 +112,19 @@
         FillPointsCount: Succ(High(Template0FPoints));
         BezierizeCount: 3;
         RandPassesCount: 8;
-        canMirror: true; canFlip: false;
+        TemplateHeight: 1024; TemplateWidth: 4096;
+        canMirror: true; canFlip: false; isNegative: false; canInvert: true;
+// Yes. I know this isn't a good map to invert, just testing
+       ),
+       (BasePoints: @Template1Points;
+        BasePointsCount: Succ(High(Template1Points));
+        FillPoints: @Template0FPoints;
+        FillPointsCount: Succ(High(Template1FPoints));
+        BezierizeCount: 6;
+        RandPassesCount: 8;
+        TemplateHeight: 2048; TemplateWidth: 4096;
+        canMirror: true; canFlip: false; isNegative: true; canInvert: false;
+// make a decent cave about one time in, oh, 5 or 6 :-/
        )
       );