Make refactoring. Remove DrawIce function
authorUrbertar@gmail.com
Thu, 28 Feb 2013 20:11:16 +0200
changeset 8601 7668f92734b8
parent 8599 6bd1950de78b
child 8602 f510cca2b988
Make refactoring. Remove DrawIce function
hedgewars/GSHandlers.inc
hedgewars/uLandGraphics.pas
--- a/hedgewars/GSHandlers.inc	Thu Feb 28 09:08:25 2013 -0500
+++ b/hedgewars/GSHandlers.inc	Thu Feb 28 20:11:16 2013 +0200
@@ -5091,22 +5091,6 @@
   end;
 end;
 
-procedure DrawIce(x, y: Longint); 
-    const iceRadius :Longint = 32;
-var
-    i, j: Longint;
-    weight: Longint;
-    landRect : TSDL_RECT;
-begin
-    FillRoundInLandWithIce(x, y, iceRadius);
-    SetAllHHToActive; 
-    landRect.x := min(max(x - iceRadius, 0), LAND_WIDTH - 1);
-    landRect.y := min(max(y - iceRadius, 0), LAND_HEIGHT - 1);
-    landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
-    landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
-    UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
-end;
-
 
 procedure doStepIceGun(Gear: PGear);
 const iceWaitCollision:Longint = 0;
@@ -5114,6 +5098,7 @@
 const iceWaitNextTarget:Longint = 2;
 const iceCollideWithHog:Longint = 4;
 const groundFreezingTime:Longint = 1000;
+const iceRadius = 32;
 var
     HHGear: PGear;
     ndX, ndY: hwFloat;
@@ -5175,7 +5160,8 @@
 
                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
                 begin 
-                    DrawIce(Target.X, Target.Y);                                        
+                    FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
+                    SetAllHHToActive;                                     
                     IceState := iceWaitNextTarget;
                 end;
 
--- a/hedgewars/uLandGraphics.pas	Thu Feb 28 09:08:25 2013 -0500
+++ b/hedgewars/uLandGraphics.pas	Thu Feb 28 20:11:16 2013 +0200
@@ -328,7 +328,6 @@
                     end;
                 if isLandscapeEdge(getPixelWeight(i, t)) then
                     begin
-                    if Land[t, i] > 255 then Land[t, i] := Land[t, i] or lfIce and not lfDamaged;
                     if (LandPixels[py, px] and AMask < 255) and (LandPixels[py, px] and AMask > 0) then
                         LandPixels[py, px] := (IceEdgeColor and not AMask) or (LandPixels[py, px] and AMask)
                     else if (LandPixels[py, px] and AMask < 255) or (Land[t, i] > 255) then
@@ -336,33 +335,39 @@
                     end
                 else if Land[t, i] > 255 then
                     begin
-                    Land[t, i] := Land[t, i] or lfIce and not lfDamaged;
                     drawIcePixel(py, px)
                     end
-                end
+                end;
+                if Land[t, i] > 255 then Land[t, i] := Land[t, i] or lfIce and not lfDamaged;
     end
 end;
 
 procedure FillRoundInLandWithIce(X, Y, Radius: LongInt);
 var dx, dy, d: LongInt;
+    landRect: TSDL_Rect;
 begin
 dx:= 0;
 dy:= Radius;
 d:= 3 - 2 * Radius;
-    while (dx < dy) do
+while (dx < dy) do
+    begin
+    FillLandCircleLinesIce(x, y, dx, dy);
+    if (d < 0) then
+        d:= d + 4 * dx + 6
+    else
         begin
-        FillLandCircleLinesIce(x, y, dx, dy);
-        if (d < 0) then
-            d:= d + 4 * dx + 6
-        else
-            begin
-            d:= d + 4 * (dx - dy) + 10;
-            dec(dy)
-            end;
-        inc(dx)
+        d:= d + 4 * (dx - dy) + 10;
+        dec(dy)
         end;
-    if (dx = dy) then
-        FillLandCircleLinesIce(x, y, dx, dy);
+    inc(dx)
+    end;
+if (dx = dy) then
+    FillLandCircleLinesIce(x, y, dx, dy);
+landRect.x := min(max(x - Radius, 0), LAND_WIDTH - 1);
+landRect.y := min(max(y - Radius, 0), LAND_HEIGHT - 1);
+landRect.w := min(2*Radius, LAND_WIDTH - landRect.x - 1);
+landRect.h := min(2*Radius, LAND_HEIGHT - landRect.y - 1);
+UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);        
 end;