tweaks to sea ice appearance
authornemo
Fri, 01 Mar 2013 22:32:49 -0500
changeset 8624 12bdc51a6790
parent 8623 93645b4ba0de
child 8625 d77090a8a35e
child 8626 cfc44db21d72
tweaks to sea ice appearance
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Fri Mar 01 17:22:09 2013 -0500
+++ b/hedgewars/uLandGraphics.pas	Fri Mar 01 22:32:49 2013 -0500
@@ -264,15 +264,13 @@
            (i > LAND_WIDTH - 1) or
            (j < 0) or
            (j > LAND_HEIGHT -1) then
-               begin               
-                result := 0;
-                exit;
-               end;
+           begin               
+           result := 0;
+           exit;
+           end;
 
-        if ((Land[j, i] and $FF00) = 0) and ((Land[j, i] and lfIce) = 0) then
-           begin
+        if Land[j, i] and $FF00 and not lfIce = 0 then
            result := result + 1;
-           end;
         end;
 end;
 
@@ -288,15 +286,25 @@
     iceSurface:= SpritesData[sprIceTexture].Surface;
     icePixels := iceSurface^.pixels;
     w:= LandPixels[y, x];
-    w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
-          (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
-          (w shr GShift and $FF) * RGB_LUMINANCE_BLUE));
-    if w < 128 then w:= w+128;
-    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, IceColor);
-    LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
+    if w > 0 then
+        begin
+        w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
+              (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
+              (w shr GShift and $FF) * RGB_LUMINANCE_BLUE));
+        if w < 128 then w:= w+128;
+        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]:= addBgColor(w, IceColor);
+        LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)])
+        end
+    else 
+        begin
+        LandPixels[y, x]:= IceColor and not AMask or $E8 shl AShift;
+        LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
+        // silly workaround to avoid having to make background erasure a tadb it smarter about sea ice
+        if LandPixels[y, x] and AMask shr AShift = 255 then 
+            LandPixels[y, x]:= LandPixels[y, x] and not AMask or 254 shl AShift;
+        end;
 end;
 
 function getIncrementInquarter(dx, dy, quarter: Longint): Longint; inline;
@@ -385,10 +393,10 @@
     begin
     for j := min(max(y, 0), LAND_HEIGHT - 1) to min(max(y + iceHeight, 0), LAND_HEIGHT - 1) do
         begin
-        if land[j, i] = 0 then
+        if Land[j, i] = 0 then
             begin
-                land[j, i] := lfIce;                
-                drawIcePixel(j, i);
+            Land[j, i] := lfIce;                
+            drawIcePixel(j, i);
             end;
         end;        
     end;