put ice colour in uVariables, add check for land that is already ice icegun
authornemo
Tue, 26 Feb 2013 09:10:48 -0500
branchicegun
changeset 8584 ea20d9cc8515
parent 8583 f2edd6d5f958
child 8588 47084c6fcb4e
put ice colour in uVariables, add check for land that is already ice
hedgewars/GSHandlers.inc
hedgewars/uLandGraphics.pas
hedgewars/uVariables.pas
--- a/hedgewars/GSHandlers.inc	Tue Feb 26 15:15:20 2013 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Feb 26 09:10:48 2013 -0500
@@ -5133,10 +5133,8 @@
     pictureX, pictureY: LongInt;
     w, c: LongWord;
 begin
+    if Land[y, x] and lfIce <> 0 then exit;
 // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness
-    c:= $7dc1ccff;
-    // FIXME should be a global value, not set every single pixel.  Just for test purposes
-    c:= ($44 shl RShift) or ($97 shl GShift) or ($A9 shl BShift) or ($A0 shl AShift);
     iceSurface:= SpritesData[sprIceTexture].Surface;
     pictureX := x mod iceSurface^.w;
     pictureY := y mod iceSurface^.h;
@@ -5149,10 +5147,10 @@
     if w > 255 then w:= 255;
     w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask);
     //LandPixels[y, x]:= w;
-    LandPixels[y, x]:= addBgColor(w, c);
+    LandPixels[y, x]:= addBgColor(w, IceColor);
     LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
 
-    Land[y, x] := land[y, x] or lfIce;
+    Land[y, x] := Land[y, x] or lfIce;
 end;
 
 procedure DrawIce(x, y: Longint); 
--- a/hedgewars/uLandGraphics.pas	Tue Feb 26 15:15:20 2013 +0200
+++ b/hedgewars/uLandGraphics.pas	Tue Feb 26 09:10:48 2013 -0500
@@ -265,15 +265,15 @@
 function getPixelWeight(x, y:Longint): Longint;
 var
     i, j:Longint;
-begin    
+begin
     result := 0;
     for i := x - 1 to x + 1 do
-        for j := y - 1 to y + 1 do 
+        for j := y - 1 to y + 1 do
         begin
-        if (i < 0) or 
-           (i > LAND_WIDTH - 1) or 
-           (j < 0) or 
-           (j > LAND_HEIGHT -1) or 
+        if (i < 0) or
+           (i > LAND_WIDTH - 1) or
+           (j < 0) or
+           (j > LAND_HEIGHT -1) or
            ((Land[j, i] and $FF00) = 0) then
            begin
            result := result + 1;
@@ -282,7 +282,7 @@
 end;
 
 procedure drawIcePixel(y, x:Longint);
-var 
+var
     iceSurface: PSDL_Surface;
     icePixels: PLongwordArray;
     pictureX, pictureY: LongInt;
@@ -293,9 +293,6 @@
     if isLandscape(weight) then
         begin
         // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness
-        c:= $7dc1ccff;
-        // FIXME should be a global value, not set every single pixel.  Just for test purposes
-        c:= ($44 shl RShift) or ($97 shl GShift) or ($A9 shl BShift) or ($A0 shl AShift);
         iceSurface:= SpritesData[sprIceTexture].Surface;
         pictureX := x mod iceSurface^.w;
         pictureY := y mod iceSurface^.h;
@@ -308,14 +305,14 @@
         if w > 255 then w:= 255;
         w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask);
         //LandPixels[y, x]:= w;
-        LandPixels[y, x]:= addBgColor(w, c);
+        LandPixels[y, x]:= addBgColor(w, IceColor);
         LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
-        Land[y, x] := land[y, x] or lfIce;            
+        Land[y, x] := land[y, x] or lfIce;
         end
     else if (isLandscapeEdge(weight)) then
         begin
-            LandPixels[y, x] := $FFB2AF8A;                    
-            if Land[y, x] > 255 then Land[y, x] := Land[y, x] or lfIce;
+        LandPixels[y, x] := $FFB2AF8A;
+        if Land[y, x] > 255 then Land[y, x] := Land[y, x] or lfIce;
         end;
 
 end;
@@ -323,14 +320,14 @@
 function getIncrementInquarter(dx, dy, quarter: Longint): Longint;
 const directionX : array [0..3] of Longint = (0, 0, 1, -1);
 const directionY : array [0..3] of Longint = (1, -1, 0, 0);
-begin    
+begin
     getIncrementInquarter := directionX[quarter] * dx + directionY[quarter] * dy;
 end;
 
 function getIncrementInquarter2(dx, dy, quarter: Longint): Longint;
 const directionY : array [0..3] of Longint = (0, 0, 1, 1);
 const directionX : array [0..3] of Longint = (1, 1, 0, 0);
-begin    
+begin
     getIncrementInquarter2 := directionX[quarter] * dx + directionY[quarter] * dy;
 end;
 
@@ -342,11 +339,11 @@
         t:= y + getIncrementInquarter(dx, dy, q);
         if (t and LAND_HEIGHT_MASK) = 0 then
             for i:= Max(x - getIncrementInquarter2(dx, dy, q), 0) to Min(x + getIncrementInquarter2(dx, dy, q), LAND_WIDTH - 1) do
-                if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
+                if (Land[t, i] and (lfIndestructible or lfIce) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
                     if (cReducedQuality and rqBlurryLand) = 0 then
                        drawIcePixel(t, i)
                     else
-                       drawIcePixel(t div 2, i div 2) ;        
+                       drawIcePixel(t div 2, i div 2) ;
     end;
 end;
 
--- a/hedgewars/uVariables.pas	Tue Feb 26 15:15:20 2013 +0200
+++ b/hedgewars/uVariables.pas	Tue Feb 26 09:10:48 2013 -0500
@@ -115,6 +115,7 @@
 
     // originally typed consts
     ExplosionBorderColor: LongWord;
+    IceColor            : LongWord;
     WaterOpacity: byte;
     SDWaterOpacity: byte;
     GrayScale: Boolean;
@@ -2409,6 +2410,7 @@
     SDWaterOpacity:= $80;
     SDTint:= $80;
     ExplosionBorderColor:= $FF808080;
+    IceColor:= ($44 shl RShift) or ($97 shl GShift) or ($A9 shl BShift) or ($A0 shl AShift);
     WaterOpacity:= $80;
 
     cDrownSpeed.QWordValue  := 257698038;       // 0.06