merge correction, also what's with all those trailing whitespaces?
authorkoda
Wed, 27 Mar 2013 11:18:00 +0100
changeset 8795 b5b79a8f9354
parent 8793 43e106417a05 (diff)
parent 8777 cce79a042cfc (current diff)
child 8797 b7e0b7a18e3a
merge correction, also what's with all those trailing whitespaces?
hedgewars/GSHandlers.inc
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsList.pas
hedgewars/uLandGraphics.pas
hedgewars/uTypes.pas
--- a/hedgewars/GSHandlers.inc	Tue Mar 26 17:52:27 2013 -0400
+++ b/hedgewars/GSHandlers.inc	Wed Mar 27 11:18:00 2013 +0100
@@ -53,7 +53,7 @@
         sX:= dX / steps;
         sY:= dY / steps;
         end
-        
+
     else
         begin
         sX:= dX;
@@ -75,7 +75,7 @@
 end;
 
 procedure makeHogsWorry(x, y: hwFloat; r: LongInt);
-var 
+var
     gi: PGear;
     d: LongInt;
 begin
@@ -89,7 +89,7 @@
                 begin
                 if (CurrentHedgehog^.Gear = gi) then
                     PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack)
-                    
+
                 else
                     begin
                     if ((gi^.State and gstMoving) = 0) and (gi^.Hedgehog^.Effects[heFrozen] = 0) then
@@ -97,15 +97,15 @@
                         gi^.dX.isNegative:= X<gi^.X;
                         gi^.State := gi^.State or gstLoser;
                         end;
-                        
+
                     if d > r div 2 then
-                        PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) 
+                        PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack)
                     else
                         PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
                     end;
                 end;
             end;
-            
+
         gi := gi^.NextGear
         end;
 end;
@@ -116,10 +116,10 @@
     DeleteCI(HH^.Gear);
     if FollowGear = HH^.Gear then
         FollowGear:= nil;
-        
+
     if lastGearByUID = HH^.Gear then
         lastGearByUID := nil;
-    
+
     HH^.Gear^.Message:= HH^.Gear^.Message or gmRemoveFromList;
     with HH^.Gear^ do
         begin
@@ -165,7 +165,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepFallingGear(Gear: PGear);
-var 
+var
     isFalling: boolean;
     //tmp: QWord;
     tdX, tdY: hwFloat;
@@ -220,16 +220,16 @@
         else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then
             collV := 1;
         end
-    else 
+    else
         begin // Gear^.dY.isNegative is false
         land:= TestCollisionYwithGear(Gear, 1);
         if land <> 0 then
             begin
             collV := 1;
             isFalling := false;
-            if land and lfIce <> 0 then 
+            if land and lfIce <> 0 then
                 Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1)
-            else 
+            else
                 Gear^.dX := Gear^.dX * Gear^.Friction;
 
             Gear^.dY := - Gear^.dY * Gear^.Elasticity;
@@ -252,7 +252,7 @@
         Gear^.State := Gear^.State or gstCollision
         end
     else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then
-        collH := -hwSign(Gear^.dX); 
+        collH := -hwSign(Gear^.dX);
     //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then
     if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=-1)
     or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)) then
@@ -285,18 +285,18 @@
     else
         Gear^.State := Gear^.State or gstMoving;
 
-    if (Gear^.nImpactSounds > 0) and 
+    if (Gear^.nImpactSounds > 0) and
         (Gear^.State and gstCollision <> 0) and
         (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and
         (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or
-            ((Gear^.Radius >= 3) and 
+            ((Gear^.Radius >= 3) and
                 ((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then
         PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true);
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBomb(Gear: PGear);
-var 
+var
     i, x, y: LongInt;
     dX, dY, gdX: hwFloat;
     vg: PVisualGear;
@@ -307,7 +307,7 @@
 
     dec(Gear^.Timer);
     if Gear^.Timer = 1000 then // might need adjustments
-        case Gear^.Kind of 
+        case Gear^.Kind of
             gtGrenade: makeHogsWorry(Gear^.X, Gear^.Y, 50);
             gtClusterBomb: makeHogsWorry(Gear^.X, Gear^.Y, 20);
             gtWatermelon: makeHogsWorry(Gear^.X, Gear^.Y, 75);
@@ -331,10 +331,10 @@
 
     if Gear^.Timer = 0 then
         begin
-        case Gear^.Kind of 
+        case Gear^.Kind of
             gtGrenade: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
             gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear^.Hedgehog, EXPLAutoSound);
-            gtClusterBomb: 
+            gtClusterBomb:
                 begin
                 x := hwRound(Gear^.X);
                 y := hwRound(Gear^.Y);
@@ -347,7 +347,7 @@
                     FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25)
                     end
                 end;
-            gtWatermelon: 
+            gtWatermelon:
                 begin
                 x := hwRound(Gear^.X);
                 y := hwRound(Gear^.Y);
@@ -361,7 +361,7 @@
                     FollowGear^.DirAngle := i * 60
                     end
                 end;
-            gtHellishBomb: 
+            gtHellishBomb:
                 begin
                 x := hwRound(Gear^.X);
                 y := hwRound(Gear^.Y);
@@ -377,7 +377,7 @@
                         AddGear(x, y, gtFlame, 0, dX, -dY, 0)
                         end
                     else
-                        begin 
+                        begin
                         AddGear(x, y, gtFlame, 0, dX, dY, 0);
                         AddGear(x, y, gtFlame, gstTmpFlag, dX, -dY, 0)
                         end;
@@ -417,7 +417,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepMolotov(Gear: PGear);
-var 
+var
     s: Longword;
     i, gX, gY: LongInt;
     dX, dY: hwFloat;
@@ -437,7 +437,7 @@
             i:= 130
         else
             i:= 50;
-            
+
         smoke:= AddVisualGear(hwRound(Gear^.X)-round(cos((Gear^.DirAngle+i) * pi / 180)*20), hwRound(Gear^.Y)-round(sin((Gear^.DirAngle+i) * pi / 180)*20), vgtSmoke);
         if smoke <> nil then
             smoke^.Scale:= 0.75;
@@ -697,10 +697,10 @@
                     end;
                 p:= @(p^[s^.pitch shr 2])
                 end;
-            
-            // Why is this here.  For one thing, there's no test on +1 being safe. 
+
+            // Why is this here.  For one thing, there's no test on +1 being safe.
             //Land[py, px+1]:= lfBasic;
-            
+
             if allpx then
                 UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w), true)
             else
@@ -765,7 +765,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBeeWork(Gear: PGear);
-var 
+var
     t: hwFloat;
     gX,gY,i: LongInt;
     uw, nuw: boolean;
@@ -880,7 +880,7 @@
         Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and (not gmAttack);
         Gear^.Hedgehog^.Gear^.State:= Gear^.Hedgehog^.Gear^.State and (not gstAttacking);
         AttackBar:= 0;
-        
+
         Gear^.SoundChannel := LoopSound(sndBee);
         Gear^.Timer := 5000;
         // save initial speed in otherwise unused Friction variable
@@ -902,7 +902,7 @@
 end;
 
 procedure doStepShotgunShot(Gear: PGear);
-var 
+var
     i: LongWord;
     shell: PVisualGear;
 begin
@@ -978,7 +978,7 @@
 
         // Bullet trail
         VGear := AddVisualGear(hwRound(ox), hwRound(oy), vgtLineTrail);
-        
+
         if VGear <> nil then
             begin
             VGear^.X:= hwFloat2Float(ox);
@@ -1001,7 +1001,7 @@
 end;
 
 procedure doStepBulletWork(Gear: PGear);
-var 
+var
     i, x, y: LongWord;
     oX, oY: hwFloat;
     VGear: PVisualGear;
@@ -1016,7 +1016,7 @@
         Gear^.Y := Gear^.Y + Gear^.dY;
         x := hwRound(Gear^.X);
         y := hwRound(Gear^.Y);
-        
+
         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
             inc(Gear^.Damage);
         // let's interrupt before a collision to give portals a chance to catch the bullet
@@ -1038,7 +1038,7 @@
         else
             AmmoShove(Gear, Gear^.Timer, 20);
         CheckGearDrowning(Gear);
-        dec(i) 
+        dec(i)
     until (i = 0) or (Gear^.Damage > Gear^.Health) or ((Gear^.State and gstDrowning) <> 0);
 
     if Gear^.Damage > 0 then
@@ -1066,7 +1066,7 @@
                 cLaserSighting := false;
             if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and ((GameFlags and gfArtillery) = 0) then
                 cArtillery := false;
-        
+
         // Bullet Hit
             if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then
                 begin
@@ -1076,7 +1076,7 @@
                     VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY);
                     end;
                 end;
-       
+
             spawnBulletTrail(Gear);
             Gear^.doStep := @doStepShotIdle
             end;
@@ -1092,7 +1092,7 @@
 end;
 
 procedure doStepSniperRifleShot(Gear: PGear);
-var 
+var
     HHGear: PGear;
     shell: PVisualGear;
 begin
@@ -1123,7 +1123,7 @@
         Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5;
         PlaySound(sndGun);
         // add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just weird angles
-        Gear^.X := Gear^.X + Gear^.dX * 3;  
+        Gear^.X := Gear^.X + Gear^.dX * 3;
         Gear^.Y := Gear^.Y + Gear^.dY * 3;
         Gear^.doStep := @doStepBulletWork;
         end
@@ -1152,7 +1152,7 @@
 begin
 dec(Gear^.Timer);
 case Gear^.Kind of
-    gtATStartGame: 
+    gtATStartGame:
         begin
         AllInactive := false;
         if Gear^.Timer = 0 then
@@ -1160,7 +1160,7 @@
             AddCaption(trmsg[sidStartFight], cWhiteColor, capgrpGameState);
             end
         end;
-    gtATFinishGame: 
+    gtATFinishGame:
         begin
         AllInactive := false;
         if Gear^.Timer = 1000 then
@@ -1183,7 +1183,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepPickHammerWork(Gear: PGear);
-var 
+var
     i, ei, x, y: LongInt;
     HHGear: PGear;
 begin
@@ -1274,7 +1274,7 @@
 end;
 
 procedure doStepPickHammer(Gear: PGear);
-var 
+var
     i, y: LongInt;
     ar: TRangeArray;
     HHGear: PGear;
@@ -1301,11 +1301,11 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
-var 
+var
     BTPrevAngle, BTSteps: LongInt;
 
 procedure doStepBlowTorchWork(Gear: PGear);
-var 
+var
     HHGear: PGear;
     b: boolean;
     prevX: LongInt;
@@ -1314,7 +1314,7 @@
     dec(Gear^.Timer);
     if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then
         dec(TurnTimeLeft);
-    
+
     HHGear := Gear^.Hedgehog^.Gear;
 
     HedgehogChAngle(HHGear);
@@ -1395,7 +1395,7 @@
 end;
 
 procedure doStepBlowTorch(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     BTPrevAngle := High(LongInt);
@@ -1443,7 +1443,7 @@
             inc(Gear^.Damage, hwRound(Gear^.dY * -_70))
         else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) then
             inc(Gear^.Damage, hwRound(Gear^.dX * -_70));
-        
+
         if ((GameTicks and $FF) = 0) and (Gear^.Damage > random(30)) then
             begin
             vg:= AddVisualGear(hwRound(Gear^.X) - 4  + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke);
@@ -1505,9 +1505,9 @@
 procedure doStepSMine(Gear: PGear);
 begin
     // TODO: do real calculation?
-    if TestCollisionXwithGear(Gear, 2) 
-    or (TestCollisionYwithGear(Gear, -2) <> 0) 
-    or TestCollisionXwithGear(Gear, -2) 
+    if TestCollisionXwithGear(Gear, 2)
+    or (TestCollisionYwithGear(Gear, -2) <> 0)
+    or TestCollisionXwithGear(Gear, -2)
     or (TestCollisionYwithGear(Gear, 2) <> 0) then
         begin
         if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
@@ -1582,14 +1582,14 @@
 Try tweaking friction some more
 *)
 procedure doStepRollingBarrel(Gear: PGear);
-var 
+var
     i: LongInt;
     particle: PVisualGear;
 begin
     if (Gear^.dY.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then
         SetLittle(Gear^.dY);
     Gear^.State := Gear^.State or gstAnimation;
-    
+
     if ((Gear^.dX.QWordValue <> 0)
     or (Gear^.dY.QWordValue <> 0))  then
         begin
@@ -1608,10 +1608,10 @@
             end
         else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1) then
                 inc(Gear^.Damage, hwRound(Gear^.dX * _70))
-                
+
         else if Gear^.dY.isNegative and (Gear^.dY < -_0_2) and (TestCollisionYwithGear(Gear, -1) <> 0) then
                 inc(Gear^.Damage, hwRound(Gear^.dY * -_70))
-                
+
         else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) then
                 inc(Gear^.Damage, hwRound(Gear^.dX * -_70));
 
@@ -1660,7 +1660,7 @@
 end;
 
 procedure doStepCase(Gear: PGear);
-var 
+var
     i, x, y: LongInt;
     k: TGearType;
     exBoom: boolean;
@@ -1701,7 +1701,7 @@
             exBoom := true;
         end
     else
-        begin 
+        begin
         if (Gear^.Pos <> posCaseHealth) and (GameTicks and $1FFF = 0) then // stir 'em up periodically
             begin
             gi := GearsList;
@@ -1738,12 +1738,12 @@
                 sparkles^.dX:= 0;
                 sparkles^.dY:= 0;
                 sparkles^.Angle:= 270;
-                if Gear^.Tag = 1 then 
+                if Gear^.Tag = 1 then
                     sparkles^.Tint:= $3744D7FF
                 else sparkles^.Tint:= $FAB22CFF
                 end;
             end;
-        if Gear^.Timer < 1000 then 
+        if Gear^.Timer < 1000 then
             begin
             AllInactive:= false;
             exit
@@ -1802,7 +1802,7 @@
             if Gear^.dY > _0_2 then
                 for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do
                     AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
-                    
+
             Gear^.dY := - Gear^.dY * Gear^.Elasticity;
             if Gear^.dY > - _0_001 then
                 Gear^.dY := _0
@@ -1856,7 +1856,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepShover(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -1872,7 +1872,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepWhip(Gear: PGear);
-var 
+var
     HHGear: PGear;
     i: LongInt;
 begin
@@ -1894,7 +1894,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepFlame(Gear: PGear);
-var 
+var
     gX,gY,i: LongInt;
     sticky: Boolean;
     vgt: PVisualGear;
@@ -1921,10 +1921,10 @@
 
         if Gear^.dX.QWordValue > _0_01.QWordValue then
             Gear^.dX := Gear^.dX * _0_995;
-            
+
         Gear^.dY := Gear^.dY + cGravity;
         // if sticky then Gear^.dY := Gear^.dY + cGravity;
-        
+
         if Gear^.dY.QWordValue > _0_2.QWordValue then
             Gear^.dY := Gear^.dY * _0_995;
 
@@ -1985,13 +1985,13 @@
                     Gear^.Radius := 1;
                     end
                 else if ((GameTicks and $3) = 3) then
-                    doMakeExplosion(gX, gY, 8, Gear^.Hedgehog, 0);//, EXPLNoDamage); 
+                    doMakeExplosion(gX, gY, 8, Gear^.Hedgehog, 0);//, EXPLNoDamage);
                 //DrawExplosion(gX, gY, 4);
-                
+
                 if ((GameTicks and $7) = 0) and (Random(2) = 0) then
                     for i:= Random(2) downto 0 do
                         AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke);
-                        
+
                 if Gear^.Health > 0 then
                     dec(Gear^.Health);
                 Gear^.Timer := 450 - Gear^.Tag * 8
@@ -2034,7 +2034,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepFirePunchWork(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     AllInactive := false;
@@ -2071,7 +2071,7 @@
 end;
 
 procedure doStepFirePunch(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     AllInactive := false;
@@ -2094,7 +2094,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 procedure doStepParachuteWork(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -2123,13 +2123,13 @@
 
     if (Gear^.Message and gmLeft) <> 0 then
         HHGear^.X := HHGear^.X - cMaxWindSpeed * 80
-        
+
     else if (Gear^.Message and gmRight) <> 0 then
         HHGear^.X := HHGear^.X + cMaxWindSpeed * 80;
-        
+
     if (Gear^.Message and gmUp) <> 0 then
         HHGear^.Y := HHGear^.Y - cGravity * 40
-        
+
     else if (Gear^.Message and gmDown) <> 0 then
         HHGear^.Y := HHGear^.Y + cGravity * 40;
 
@@ -2142,7 +2142,7 @@
 end;
 
 procedure doStepParachute(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -2169,7 +2169,7 @@
     if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then
         begin
         dec(Gear^.Health);
-            case Gear^.State of 
+            case Gear^.State of
                 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
                 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
                 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
@@ -2212,7 +2212,7 @@
 
     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
     if (Gear^.State = 2) then
-        Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900 
+        Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900
     // calcs for regular falling gears
     else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then
             Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 /
@@ -2246,7 +2246,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 procedure doStepGirder(Gear: PGear);
-var 
+var
     HHGear: PGear;
     x, y, tx, ty: hwFloat;
 begin
@@ -2268,7 +2268,7 @@
         isCursorVisible := true;
         DeleteGear(Gear)
         end
-    else 
+    else
         begin
         PlaySound(sndPlaced);
         DeleteGear(Gear);
@@ -2281,7 +2281,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepTeleportAfter(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -2315,7 +2315,7 @@
 end;
 
 procedure doStepTeleport(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     AllInactive := false;
@@ -2356,7 +2356,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepSwitcherWork(Gear: PGear);
-var 
+var
     HHGear: PGear;
     hedgehog: PHedgehog;
     State: Longword;
@@ -2391,12 +2391,12 @@
 
         repeat
             CurrentTeam^.CurrHedgehog := Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber);
-        until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and 
-              (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0) and 
+        until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and
+              (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0) and
               (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen]=0);
 
         SwitchCurrentHedgehog(@CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
-        AmmoMenuInvalidated:= true; 
+        AmmoMenuInvalidated:= true;
 
         HHGear := CurrentHedgehog^.Gear;
         HHGear^.State := State;
@@ -2410,7 +2410,7 @@
 end;
 
 procedure doStepSwitcher(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     Gear^.doStep := @doStepSwitcherWork;
@@ -2426,7 +2426,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepMortar(Gear: PGear);
-var 
+var
     dX, dY, gdX, gdY: hwFloat;
     i: LongInt;
     dxn, dyn: boolean;
@@ -2461,7 +2461,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepKamikazeWork(Gear: PGear);
-var 
+var
     i: LongWord;
     HHGear: PGear;
     sparkles: PVisualGear;
@@ -2496,7 +2496,7 @@
 
     i := 2;
     repeat
-        
+
         Gear^.X := Gear^.X + HHGear^.dX;
         Gear^.Y := Gear^.Y + HHGear^.dY;
         HHGear^.X := Gear^.X;
@@ -2579,7 +2579,7 @@
 end;
 
 procedure doStepKamikaze(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     AllInactive := false;
@@ -2600,7 +2600,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 const cakeh =   27;
-var 
+var
     CakePoints: array[0..Pred(cakeh)] of record
         x, y: hwFloat;
     end;
@@ -2620,7 +2620,7 @@
 end;
 
 procedure doStepCakeDown(Gear: PGear);
-var 
+var
     gi: PGear;
     dmg, dmgBase: LongInt;
     fX, fY, tdX, tdY: hwFloat;
@@ -2706,7 +2706,7 @@
 end;
 
 procedure doStepCakeUp(Gear: PGear);
-var 
+var
     i: Longword;
 begin
     AllInactive := false;
@@ -2746,7 +2746,7 @@
 end;
 
 procedure doStepCake(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     AllInactive := false;
@@ -2850,7 +2850,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepWaterUp(Gear: PGear);
-var 
+var
     i: LongWord;
 begin
     if (Gear^.Tag = 0)
@@ -2884,20 +2884,18 @@
 forward;
 
 procedure doStepDrillDrilling(Gear: PGear);
-var 
+var
     t: PGearArray;
-    ox, oy: hwFloat;
-    tempColl: Word; 
+    tempColl: Word;
 begin
     AllInactive := false;
 
+
     if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then
     begin
-        ox := Gear^.X;
-        oy := Gear^.Y;
+        DrawTunnel(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 2, 6);
         Gear^.X := Gear^.X + Gear^.dX;
         Gear^.Y := Gear^.Y + Gear^.dY;
-        DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6);
         if (Gear^.Timer mod 30) = 0 then
             AddVisualGear(hwRound(Gear^.X + _20 * Gear^.dX), hwRound(Gear^.Y + _20 * Gear^.dY), vgtDust);
         if (CheckGearDrowning(Gear)) then
@@ -2913,7 +2911,7 @@
     else t := nil;
     Gear^.CollisionMask:= tempColl;
     //fixes drill not exploding when touching HH bug
-    
+
     if (Gear^.Timer = 0) or ((t <> nil) and (t^.Count <> 0))
     or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))))
 // CheckLandValue returns true if the type isn't matched
@@ -2928,7 +2926,7 @@
         DeleteGear(Gear);
         exit
         end
-        
+
     else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then
         begin
         StopSoundChan(Gear^.SoundChannel);
@@ -2940,7 +2938,7 @@
 end;
 
 procedure doStepDrill(Gear: PGear);
-var 
+var
     t: PGearArray;
     oldDx, oldDy: hwFloat;
     t2: hwFloat;
@@ -2964,7 +2962,7 @@
         Gear^.dX := oldDx;
         Gear^.dY := oldDy;
 
-        if GameTicks > Gear^.FlightTime then 
+        if GameTicks > Gear^.FlightTime then
             t := CheckGearsCollision(Gear)
         else
             t := nil;
@@ -2975,7 +2973,7 @@
             Gear^.dX := Gear^.dX * t2;
             Gear^.dY := Gear^.dY * t2;
             end
-            
+
         else if (t <> nil) then
             begin
             //explode right on contact with HH
@@ -2989,14 +2987,14 @@
 
         Gear^.SoundChannel := LoopSound(sndDrillRocket);
         Gear^.doStep := @doStepDrillDrilling;
-        
+
         if (Gear^.State and gsttmpFlag) <> 0 then
             gear^.RenderTimer:= true;
         if Gear^.Timer > 0 then dec(Gear^.Timer)
         end
     else if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Tag <> 0) then
         begin
-        if Gear^.Timer > 0 then 
+        if Gear^.Timer > 0 then
             dec(Gear^.Timer)
         else
             begin
@@ -3008,7 +3006,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBallgunWork(Gear: PGear);
-var 
+var
     HHGear, ball: PGear;
     rx, ry: hwFloat;
     gX, gY: LongInt;
@@ -3038,7 +3036,7 @@
 end;
 
 procedure doStepBallgun(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -3051,7 +3049,7 @@
 procedure doStepRCPlaneWork(Gear: PGear);
 
 const cAngleSpeed =   3;
-var 
+var
     HHGear: PGear;
     i: LongInt;
     dX, dY: hwFloat;
@@ -3160,7 +3158,7 @@
             begin
             if TagTurnTimeLeft = 0 then
                 TagTurnTimeLeft:= TurnTimeLeft;
-                
+
             TurnTimeLeft:= 14 * 125;
             end;
 
@@ -3170,7 +3168,7 @@
 end;
 
 procedure doStepRCPlane(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -3178,7 +3176,7 @@
     HHGear^.State := HHGear^.State or gstNotKickable;
     Gear^.Angle := HHGear^.Angle;
     Gear^.Tag := hwSign(HHGear^.dX);
-    
+
     if HHGear^.dX.isNegative then
         Gear^.Angle := 4096 - Gear^.Angle;
     Gear^.doStep := @doStepRCPlaneWork
@@ -3186,7 +3184,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepJetpackWork(Gear: PGear);
-var 
+var
     HHGear: PGear;
     fuel, i: LongInt;
     move: hwFloat;
@@ -3265,9 +3263,9 @@
 
     if Gear^.Health < 0 then
         Gear^.Health := 0;
-        
+
     i:= Gear^.Health div 20;
-    
+
     if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
         begin
         Gear^.Damage:= i;
@@ -3276,9 +3274,9 @@
         Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) + '%', cWhiteColor, fntSmall)
         end;
 
-    if HHGear^.Message and (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) <> 0 then 
+    if HHGear^.Message and (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) <> 0 then
         Gear^.State := Gear^.State and (not gsttmpFlag);
-        
+
     HHGear^.Message := HHGear^.Message and (not (gmUp or gmPrecise or gmLeft or gmRight));
     HHGear^.State := HHGear^.State or gstMoving;
 
@@ -3288,7 +3286,7 @@
     if not isUnderWater and hasBorder and ((HHGear^.X < _0)
     or (hwRound(HHGear^.X) > LAND_WIDTH)) then
         HHGear^.dY.isNegative:= false;
-        
+
     if ((Gear^.State and gsttmpFlag) = 0)
     or (HHGear^.dY < _0) then
         doStepHedgehogMoving(HHGear);
@@ -3320,7 +3318,7 @@
 end;
 
 procedure doStepJetpack(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     Gear^.Pos:= 0;
@@ -3333,7 +3331,7 @@
         begin
         State := State and (not gstAttacking);
         Message := Message and (not (gmAttack or gmUp or gmPrecise or gmLeft or gmRight));
-        
+
         if (dY < _0_1) and (dY > -_0_1) then
             begin
             Gear^.State := Gear^.State or gsttmpFlag;
@@ -3356,13 +3354,13 @@
 end;
 
 procedure doStepBirdyFly(Gear: PGear);
-var 
+var
     HHGear: PGear;
     fuel, i: LongInt;
     move: hwFloat;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
-    if HHGear = nil then 
+    if HHGear = nil then
         begin
         DeleteGear(Gear);
         exit
@@ -3386,11 +3384,11 @@
         if (not HHGear^.dY.isNegative)
         or (HHGear^.Y > -_256) then
             HHGear^.dY := HHGear^.dY - move;
-            
+
         dec(Gear^.Health, fuel);
         Gear^.MsgParam := Gear^.MsgParam or gmUp;
         end;
-        
+
     if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true;
     if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
         begin
@@ -3401,7 +3399,7 @@
 
     if Gear^.Health < 0 then
         Gear^.Health := 0;
-        
+
     if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then
         for i:= ((500-Gear^.Health) div 250) downto 0 do
             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
@@ -3419,7 +3417,7 @@
 
     if HHGear^.Message and (gmUp or gmPrecise or gmLeft or gmRight) <> 0 then
         Gear^.State := Gear^.State and (not gsttmpFlag);
-        
+
     HHGear^.Message := HHGear^.Message and (not (gmUp or gmPrecise or gmLeft or gmRight));
     HHGear^.State := HHGear^.State or gstMoving;
 
@@ -3462,7 +3460,7 @@
 end;
 
 procedure doStepBirdyDescend(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     if Gear^.Timer > 0 then
@@ -3503,12 +3501,12 @@
 end;
 
 procedure doStepBirdy(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     gear^.State :=  gear^.State or gstAnimation and (not gstTmpFlag);
     Gear^.doStep := @doStepBirdyAppear;
-    
+
     if CurrentHedgehog = nil then
         begin
         DeleteGear(Gear);
@@ -3533,7 +3531,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepEggWork(Gear: PGear);
-var 
+var
     vg: PVisualGear;
     i: LongInt;
 begin
@@ -3574,18 +3572,18 @@
                 if (CurAmmoType = amPortalGun) then
                     begin
                     CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSwitch);
-                
+
                     CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
                     if CurWeapon^.Pos <> 0 then
                         CurWeapon^.Pos := 0
-                        
+
                     else
                     CurWeapon^.Pos := 1;
                     end;
 end;
 
 procedure doStepPortal(Gear: PGear);
-var 
+var
     iterator, conPortal: PGear;
     s, r, nx, ny, ox, oy, poffs, noffs, pspeed, nspeed,
     resetx, resety, resetdx, resetdy: hwFloat;
@@ -3886,7 +3884,7 @@
             resetx.QWordValue:= 4294967296 * 35;
             resetdx.isNegative:= false;
             resetdx.QWordValue:= 4294967296 * 1152;
-    
+
             resetdy:=hwAbs(iterator^.dX*4);
             resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx;
             iterator^.Angle:= hwRound(resetdy*_2048 / _PI);
@@ -3907,7 +3905,7 @@
         and (CurAmmoGear^.Kind =gtRope) then
                CurAmmoGear^.PortalCounter:= 1;
 
-        if not isbullet and (iterator^.State and gstInvisible = 0) 
+        if not isbullet and (iterator^.State and gstInvisible = 0)
         and (iterator^.Kind <> gtFlake) then
             FollowGear := iterator;
 
@@ -3953,7 +3951,7 @@
 end;
 
 procedure doStepMovingPortal_real(Gear: PGear);
-var 
+var
     x, y, tx, ty: LongInt;
     s: hwFloat;
 begin
@@ -3967,7 +3965,7 @@
         begin
         Gear^.State := Gear^.State or gstCollision;
         Gear^.State := Gear^.State and (not gstMoving);
-        
+
         if (Land[y, x] and lfBouncy <> 0)
         or (not CalcSlopeTangent(Gear, x, y, tx, ty, 255))
         or (DistanceI(tx,ty) < _12) then // reject shots at too irregular terrain
@@ -3995,7 +3993,7 @@
         else
             loadNewPortalBall(Gear, true);
     end
-    
+
     else if (y > cWaterLine)
     or (y < -max(LAND_WIDTH,4096))
     or (x > 2*max(LAND_WIDTH,4096))
@@ -4007,13 +4005,13 @@
 begin
     doPortalColorSwitch();
     doStepPerPixel(Gear, @doStepMovingPortal_real, true);
-    if (Gear^.Timer < 1) 
+    if (Gear^.Timer < 1)
     or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team) then
         deleteGear(Gear);
 end;
 
 procedure doStepPortalShot(newPortal: PGear);
-var 
+var
     iterator: PGear;
     s: hwFloat;
     CurWeapon: PAmmo;
@@ -4093,15 +4091,15 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepPiano(Gear: PGear);
-var 
+var
     r0, r1: LongInt;
     odY: hwFloat;
 begin
     AllInactive := false;
-    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and 
+    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and
         ((CurrentHedgehog^.Gear^.Message and gmSlot) <> 0) then
             begin
-                case CurrentHedgehog^.Gear^.MsgParam of 
+                case CurrentHedgehog^.Gear^.MsgParam of
                 0: PlaySound(sndPiano0);
                 1: PlaySound(sndPiano1);
                 2: PlaySound(sndPiano2);
@@ -4181,7 +4179,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepSineGunShotWork(Gear: PGear);
-var 
+var
     x, y, rX, rY, t, tmp, initHealth: LongInt;
     oX, oY, ldX, ldY, sdX, sdY, sine, lx, ly, amp: hwFloat;
     justCollided: boolean;
@@ -4276,7 +4274,7 @@
                     end;
 
                 if random(100) = 0 then
-                    AddVisualGear(x, y, vgtSmokeTrace); 
+                    AddVisualGear(x, y, vgtSmokeTrace);
                 end
                 else dec(Gear^.Health, 5); // if underwater get additional damage
             end;
@@ -4314,7 +4312,7 @@
 var
     HHGear: PGear;
 begin
-    PlaySound(sndSineGun); 
+    PlaySound(sndSineGun);
 
     // push the shooting Hedgehog back
     HHGear := CurrentHedgehog^.Gear;
@@ -4334,7 +4332,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepFlamethrowerWork(Gear: PGear);
-var 
+var
     HHGear, flame: PGear;
     rx, ry, speed: hwFloat;
     i, gX, gY: LongInt;
@@ -4344,7 +4342,7 @@
     HedgehogChAngle(HHGear);
     gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle);
     gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle);
-    
+
     if (GameTicks and $FF) = 0 then
         begin
         if (HHGear^.Message and gmRight) <> 0 then
@@ -4358,11 +4356,11 @@
             begin
             if HHGear^.dX.isNegative and (Gear^.Tag > 5) then
                 dec(Gear^.Tag)
-            else if Gear^.Tag < 20 then 
+            else if Gear^.Tag < 20 then
                 inc(Gear^.Tag);
             end
         end;
-    
+
     dec(Gear^.Timer);
     if Gear^.Timer = 0 then
         begin
@@ -4372,12 +4370,12 @@
             rx := rndSign(getRandomf * _0_1);
             ry := rndSign(getRandomf * _0_1);
             speed := _0_5 * (_10 / Gear^.Tag);
-    
+
             flame:= AddGear(gx, gy, gtFlame, gstTmpFlag,
                     SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
             flame^.CollisionMask:= lfNotCurrentMask;
-            
+
             if (Gear^.Health mod 30) = 0 then
                 begin
                 flame:= AddGear(gx, gy, gtFlame, 0,
@@ -4408,7 +4406,7 @@
 end;
 
 procedure doStepFlamethrower(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -4419,7 +4417,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepLandGunWork(Gear: PGear);
-var 
+var
     HHGear, land: PGear;
     rx, ry, speed: hwFloat;
     i, gX, gY: LongInt;
@@ -4429,7 +4427,7 @@
     HedgehogChAngle(HHGear);
     gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle);
     gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle);
-    
+
     if (GameTicks and $FF) = 0 then
         begin
         if (HHGear^.Message and gmRight) <> 0 then
@@ -4447,7 +4445,7 @@
                 inc(Gear^.Tag);
             end
         end;
-    
+
     dec(Gear^.Timer);
     if Gear^.Timer = 0 then
         begin
@@ -4457,11 +4455,11 @@
         ry := rndSign(getRandomf * _0_1);
         speed := (_3 / Gear^.Tag);
 
-        land:= AddGear(gx, gy, gtFlake, gstTmpFlag, 
-                SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, 
+        land:= AddGear(gx, gy, gtFlake, gstTmpFlag,
+                SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
                 AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
         land^.CollisionMask:= lfNotCurrentMask;
-            
+
         Gear^.Timer:= Gear^.Tag
         end;
 
@@ -4485,7 +4483,7 @@
 end;
 
 procedure doStepLandGun(Gear: PGear);
-var 
+var
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -4554,7 +4552,7 @@
 end;
 
 procedure doStepHammerHitWork(Gear: PGear);
-var 
+var
     i, j, ei: LongInt;
     HitGear: PGear;
 begin
@@ -4610,7 +4608,7 @@
 end;
 
 procedure doStepHammerHit(Gear: PGear);
-var 
+var
     i, y: LongInt;
     ar: TRangeArray;
     HHGear: PGear;
@@ -4660,7 +4658,7 @@
         begin
         if (GameTicks and $F) <> 0 then
         exit;
-        end 
+        end
     else if (GameTicks and $1FF) <> 0 then
         exit;
 
@@ -4697,8 +4695,8 @@
                 inc(graves[i]^.Health);
             end;
         end; -}
-        end 
-    else 
+        end
+    else
         begin
         // now really resurrect the hogs with the hp saved in the graves
         for i:= 0 to graves.size - 1 do
@@ -4757,9 +4755,9 @@
             RecountTeamHealth(hh^.Team);
             inc(graves.ar^[Gear^.Tag]^.Health);
             inc(Gear^.Tag)
-            end 
-        end 
-    else 
+            end
+        end
+    else
         begin
         StopSoundChan(Gear^.SoundChannel);
         Gear^.Timer := 250;
@@ -4779,7 +4777,7 @@
     begin
         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLAutoSound);
         gX := hwRound(Gear^.X);
-        gY := hwRound(Gear^.Y); 
+        gY := hwRound(Gear^.Y);
         for i:= 0 to 10 do
         begin
             dX := AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandomf + _1);
@@ -4807,7 +4805,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepStructure(Gear: PGear);
-var 
+var
     x, y: LongInt;
     HH: PHedgehog;
     t: PGear;
@@ -4824,7 +4822,7 @@
 
     dec(Gear^.Health, Gear^.Damage);
     Gear^.Damage:= 0;
-        
+
     if Gear^.Pos = 1 then
         begin
         AddGearCI(Gear);
@@ -4835,7 +4833,7 @@
             HideHog(HH);
         Gear^.Pos:= 2
         end;
-        
+
     if Gear^.Pos = 2 then
         begin
         if ((GameTicks mod 100) = 0) and (Gear^.Timer < 1000) then
@@ -4851,7 +4849,7 @@
         if Gear^.Tag <= TotalRounds then
             Gear^.Pos:= 3;
         end;
-        
+
     if Gear^.Pos = 3 then
         if Gear^.Timer < 1000 then
             begin
@@ -4869,7 +4867,7 @@
                 RestoreHog(HH);
             Gear^.Pos:= 4;
             end;
-        
+
     if Gear^.Pos = 4 then
         if ((GameTicks mod 1000) = 0) and ((GameFlags and gfInvulnerable) = 0) then
             begin
@@ -4881,12 +4879,12 @@
                 t:= t^.NextGear;
                 end;
             end;
-        
+
     if Gear^.Health <= 0 then
         begin
         if HH^.GearHidden <> nil then
             RestoreHog(HH);
-        
+
         x := hwRound(Gear^.X);
         y := hwRound(Gear^.Y);
 
@@ -4899,7 +4897,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 (*
- TARDIS needs 
+ TARDIS needs
  Warp in.  Pos = 1
  Pause.    Pos = 2
  Hide gear  (TARDIS hedgehog was nil)
@@ -4925,7 +4923,7 @@
             begin
             AfterAttack;
             if Gear = CurAmmoGear then CurAmmoGear := nil;
-            if (HH^.Gear^.Damage = 0) and  (HH^.Gear^.Health > 0) and 
+            if (HH^.Gear^.Damage = 0) and  (HH^.Gear^.Health > 0) and
             ((Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then
                 HideHog(HH)
             end
@@ -4945,7 +4943,7 @@
 if (Gear^.Pos = 1) and (GameTicks and $1F = 0) and (Gear^.Power < 255) then
     begin
     inc(Gear^.Power);
-    if (Gear^.Power = 172) and (HH^.Gear <> nil) and 
+    if (Gear^.Power = 172) and (HH^.Gear <> nil) and
         (HH^.Gear^.Damage = 0) and (HH^.Gear^.Health > 0) and
         ((HH^.Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then
             with HH^.Gear^ do
@@ -4986,7 +4984,7 @@
         begin
         if HH^.GearHidden <> nil then
             FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH,true);
-            
+
         if HH^.GearHidden <> nil then
             begin
             Gear^.X:= HH^.GearHidden^.X;
@@ -5062,7 +5060,7 @@
 WIP. The ice gun will have the following effects.  It has been proposed by sheepluva that it take the appearance of a large freezer
 spewing ice cubes.  The cubes will be visual gears only.  The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect.
 For now we assume a "ray" like a deagle projected out from the gun.
-All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".  
+All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".
   * When fired at water a layer of ice textured land is added above the water.
   * When fired at non-ice land (land and lfLandMask and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed.
   * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen.  As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head.  If the effect is interrupted before reaching the top, the freezing state is cleared.
@@ -5072,7 +5070,7 @@
 
 
 procedure updateFuel(Gear: PGear);
-var 
+var
   t:LongInt;
 begin
     t:= Gear^.Health div 10;
@@ -5088,7 +5086,8 @@
 
 
 procedure updateTarget(Gear:PGear; newX, newY:HWFloat);
-    //var iter:PGear;    
+//    var
+//    iter:PGear;
 begin
   with Gear^ do
   begin
@@ -5104,16 +5103,15 @@
     iter := GearsList;
     while iter <> nil do
         begin
-        if (iter^.Kind = gtHedgehog) and 
-        (iter^.Hedgehog^.Effects[heFrozen] and $FF = 0) then 
+        if (iter^.Kind = gtHedgehog) and
+        (iter^.Hedgehog^.Effects[heFrozen] and $FF = 0) then
         iter^.Hedgehog^.Effects[heFrozen]:= 0;
         iter:= iter^.NextGear
-        end 
+        end
 *)
   end;
 end;
 
-
 procedure doStepIceGun(Gear: PGear);
 const iceWaitCollision:Longint = 0;
 const iceCollideWithGround:Longint = 1;
@@ -5126,6 +5124,7 @@
 const iceHeight = 40;
 var
     HHGear: PGear;
+    landRect: TSDL_Rect;
     ndX, ndY: hwFloat;
     i, t, gX, gY: LongInt;
     hogs: PGearArrayS;
@@ -5144,8 +5143,8 @@
         HedgehogChAngle(HHGear);
         ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _4;
         ndY:= -AngleCos(HHGear^.Angle) * _4;
-        if (ndX <> dX) or (ndY <> dY) or 
-           ((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and 
+        if (ndX <> dX) or (ndY <> dY) or
+           ((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and
              (Target.Y and LAND_HEIGHT_MASK = 0) and ((Land[Target.Y, Target.X] = 0))) then
             begin
                 updateTarget(Gear, ndX, ndY);
@@ -5156,8 +5155,8 @@
             X:= X + dX;
             Y:= Y + dY;
             gX:= hwRound(X);
-            gY:= hwRound(Y);    
-            if Target.X = NoPointX then 
+            gY:= hwRound(Y);
+            if Target.X = NoPointX then
             begin
                 t:= hwRound(hwSqr(X-HHGear^.X)+hwSqr(Y-HHGear^.Y));
             end;
@@ -5166,19 +5165,19 @@
             begin
                 CheckCollisionWithLand(Gear);
                 if (State and gstCollision) <> 0 then
-                begin        
+                begin
                 if Health = iceWaitCollision then
                     begin
                     Health := iceCollideWithGround;
-                    Power := GameTicks;                    
-                    end                    
+                    Power := GameTicks;
+                    end
                 end
                 else if (target.y >= cWaterLine) then
                     begin
                     if Health = iceWaitCollision then
                         begin
                         Health := iceCollideWithWater;
-                        Power := GameTicks;  
+                        Power := GameTicks;
                         end;
                     end;
 
@@ -5189,16 +5188,23 @@
                     end;
 
                 if (Health = iceCollideWithGround) and ((GameTicks - Power) > groundFreezingTime) then
-                    begin 
-                    FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
-                    SetAllHHToActive;                                     
+                    begin
+                    FillRoundInLand(target.x, target.y, iceRadius, icePixel);
+                    landRect.x := min(max(target.x - iceRadius, 0), LAND_WIDTH - 1);
+                    landRect.y := min(max(target.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);
+
+                    // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
+                    SetAllHHToActive;
                     Health := iceWaitCollision;
                     end;
 
                 if (Health = iceCollideWithWater) and ((GameTicks - Power) > groundFreezingTime) then
-                    begin                    
+                    begin
                     DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight);
-                    SetAllHHToActive; 
+                    SetAllHHToActive;
                     Health := iceWaitCollision;
                     end;
 
@@ -5207,7 +5213,7 @@
                 if hogs.size > 0 then
                     for i:= 0 to hogs.size - 1 do
                         if hogs.ar^[i] <> HHGear then
-                            if GameTicks mod 5 = 0 then 
+                            if GameTicks mod 5 = 0 then
                                 begin
                                 hogs.ar^[i]^.Active:= true;
                                 if hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] < 256 then
@@ -5309,7 +5315,7 @@
         DeleteGear(Gear)
         end;
     // ssssss he essssscaped
-    if (Gear^.Timer > 250) and ((HHGear = nil) or 
+    if (Gear^.Timer > 250) and ((HHGear = nil) or
             (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) >  180) and
             (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > _180))) then
         begin
@@ -5320,7 +5326,7 @@
     end;
 
 // Search out a new target, as target seek time has expired, target is dead, target is out of range, or we did not have a target
-if (HHGear = nil) or (Gear^.Timer = 0) or 
+if (HHGear = nil) or (Gear^.Timer = 0) or
    (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) >  Gear^.Angle) and
         (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > int2hwFloat(Gear^.Angle)))
     then
@@ -5437,7 +5443,7 @@
  This didn't end up getting used, but, who knows, might be reasonable for javellin or something
 // Make the knife initial angle based on the hog attack angle, or is that too hard?
 procedure doStepKnife(Gear: PGear);
-var t, 
+var t,
     gx, gy, ga,  // gear x,y,angle
     lx, ly, la, // land x,y,angle
     ox, oy, // x,y offset
@@ -5461,7 +5467,7 @@
         begin
         if CheckLandValue(gx, gy, lfLandMask) then
             begin
-            t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10); 
+            t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10);
 
             if t < 0 then inc(t, 4096)
             else if 4095 < t then dec(t, 4096);
@@ -5498,7 +5504,7 @@
                 4:  begin
                     ox:= 29; oy:=  8;
                      w:= 19;  h:= 19;
-                    tx:=  0; ty:= 17 
+                    tx:=  0; ty:= 17
                     end;
                 5:  begin
                     ox:= 29; oy:=  32;
@@ -5508,7 +5514,7 @@
                 6:  begin
                     ox:= 51; oy:=   3;
                      w:= 11;  h:=  23;
-                    tx:=  0; ty:=  22 
+                    tx:=  0; ty:=  22
                     end;
                 7:  begin
                     ox:= 51; oy:=  34;
@@ -5516,7 +5522,7 @@
                     tx:=  0; ty:=  23
                     end
                 end;
-                
+
             surf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
             copyToXYFromRect(SpritesData[sprKnife].Surface, surf, ox, oy, w, h, 0, 0);
             // try to make the knife hit point first
@@ -5538,7 +5544,7 @@
                 AddFileLog('la: '+inttostr(la)+' ga: '+inttostr(ga)+' Angle: '+inttostr(Angle))
                 end;
             case Angle div 1024 of
-                0:  begin 
+                0:  begin
                     flipSurface(surf, true);
                     flipSurface(surf, true);
                     BlitImageAndGenerateCollisionInfo(gx-(w-tx), gy-(h-ty), w, surf)
--- a/hedgewars/uGearsHedgehog.pas	Tue Mar 26 17:52:27 2013 -0400
+++ b/hedgewars/uGearsHedgehog.pas	Wed Mar 27 11:18:00 2013 +0100
@@ -23,18 +23,18 @@
 uses uTypes;
 
 procedure doStepHedgehog(Gear: PGear);
-procedure AfterAttack; 
-procedure HedgehogStep(Gear: PGear); 
-procedure doStepHedgehogMoving(Gear: PGear); 
-procedure HedgehogChAngle(HHGear: PGear); 
+procedure AfterAttack;
+procedure HedgehogStep(Gear: PGear);
+procedure doStepHedgehogMoving(Gear: PGear);
+procedure HedgehogChAngle(HHGear: PGear);
 procedure PickUp(HH, Gear: PGear);
 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
 procedure CheckIce(Gear: PGear); inline;
 
 implementation
-uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
+uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
     uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
-    uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, 
+    uGearsList, uGears, uCollisions, uRandom, uStore, uTeams,
     uGearsUtils;
 
 var GHStepTicks: LongWord = 0;
@@ -75,7 +75,7 @@
 
     MultiShootAttacks:= 0;
     HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
-    
+
     if Ammoz[CurAmmoType].Slot = slot then
         begin
         i:= 0;
@@ -90,8 +90,8 @@
             end;
         until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0)
         and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns))
-        
-        end 
+
+        end
     else
         begin
         i:= 0;
@@ -114,7 +114,7 @@
             LoadHedgehogHat(HHGear^.Hedgehog^, Hat);
         end;
     // Try again in the next slot
-    if CurAmmoType = prevAmmo then 
+    if CurAmmoType = prevAmmo then
         begin
         if slot >= cMaxSlotIndex then slot:= 0 else inc(slot);
         HHGear^.MsgParam:= slot;
@@ -213,7 +213,7 @@
         if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0)
         or (Power > 0)
         or (CurAmmoType = amTeleport)
-        or 
+        or
         // Allow attacks while moving on ammo with AltAttack
         ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0))
         or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0))
@@ -257,7 +257,7 @@
             and ((Gear^.Message and gmLJump) <> 0)
             and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
                 begin
-                newDx:= dX; 
+                newDx:= dX;
                 newDy:= dY;
                 altUse:= true
                 end
@@ -285,15 +285,15 @@
                          amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0);
                          amMine: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
                         amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
-                        amKnife: begin 
+                        amKnife: begin
                                  newGear:= AddGear(hwRound(lx), hwRound(ly), gtKnife,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
-                                 newGear^.State:= newGear^.State or gstMoving; 
+                                 newGear^.State:= newGear^.State or gstMoving;
                                  newGear^.Radius:= 4 // temporarily shrink so it doesn't instantly embed in the ground
                                  end;
                        amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
                       amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
                     amPortalGun: begin
-                                 newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 
+                                 newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6,
                                  // set selected color
                                  CurWeapon^.Pos);
                                  end;
@@ -353,7 +353,7 @@
                                  cGravity:= cMaxWindSpeed;
                                  cGravityf:= 0.00025
                                  end;
-                  amExtraDamage: begin 
+                  amExtraDamage: begin
                                  PlaySound(sndHellishImpact4);
                                  cDamageModifier:= _1_5
                                  end;
@@ -390,11 +390,11 @@
                newGear^.dX:= newDx / newGear^.Density;
                newGear^.dY:= newDY / newGear^.Density
                end;
-             
+
             case CurAmmoType of
-                     amGrenade, amMolotov, 
-                 amClusterBomb, amGasBomb, 
-                     amBazooka, amSnowball, 
+                     amGrenade, amMolotov,
+                 amClusterBomb, amGasBomb,
+                     amBazooka, amSnowball,
                          amBee, amSMine,
                       amMortar, amWatermelon,
                  amHellishBomb, amDrill: FollowGear:= newGear;
@@ -415,7 +415,7 @@
                       amTardis, amPiano,
                       amIceGun: CurAmmoGear:= newGear;
             end;
-             
+
             if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then
                 newGear^.FlightTime:= GameTicks + 1000
             else if CurAmmoType = amDrill then
@@ -439,7 +439,7 @@
                     newGear^.Elasticity:= newGear^.Elasticity * elastic
                 else if elastic > _1 then
                     newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic);
-    (* Experimented with friction modifier. Didn't seem helpful 
+    (* Experimented with friction modifier. Didn't seem helpful
                 fric:= int2hwfloat(CurWeapon^.Bounciness) / _250;
                 if fric < _1 then newGear^.Friction:= newGear^.Friction * fric
                 else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*)
@@ -475,7 +475,7 @@
                 AfterAttack;
                 end
             end
-        else 
+        else
             Message:= Message and (not gmAttack);
     end;
     TargetPoint.X := NoPointX;
@@ -495,13 +495,13 @@
     if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then
         begin
         Inc(MultiShootAttacks);
-        
+
         if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then
             begin
             s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1);
             AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
             end;
-        
+
         if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks)
         or ((GameFlags and gfMultiWeapon) <> 0) then
             begin
@@ -516,7 +516,7 @@
                     TagTurnTimeLeft:= TurnTimeLeft;
                 TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100;
                 end;
-            if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then 
+            if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then
                 HHGear^.State:= HHGear^.State or gstAttacked;
             if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then
                 ApplyAmmoChanges(CurrentHedgehog^)
@@ -544,7 +544,7 @@
     dec(Gear^.Timer);
     if (Gear^.Timer mod frametime) = 0 then
         inc(Gear^.Pos)
-    end 
+    end
 else if Gear^.Timer = 1 then
     begin
     Gear^.State:= Gear^.State or gstNoDamage;
@@ -552,7 +552,7 @@
     AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
     DeleteGear(Gear);
     SetAllToActive
-    end 
+    end
 else // Gear^.Timer = 0
     begin
     AllInactive:= false;
@@ -605,7 +605,7 @@
     if cnt <> 0 then AddAmmo(HH, ammo, cnt)
     else AddAmmo(HH, ammo);
 
-    if (not (HH.Team^.ExtDriven 
+    if (not (HH.Team^.ExtDriven
     or (HH.BotLevel > 0)))
     or (HH.Team^.Clan^.ClanIndex = LocalClan)
     or (GameType = gmtDemo)  then
@@ -643,7 +643,7 @@
        posCaseUtility,
        posCaseAmmo: begin
                     PlaySound(sndShotgunReload);
-                    if Gear^.AmmoType <> amNothing then 
+                    if Gear^.AmmoType <> amNothing then
                         begin
                         AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y));
                         end
@@ -651,7 +651,7 @@
                         begin
 // Add spawning here...
                         AddRandomness(GameTicks);
-                        
+
                         gi := GearsList;
                         while gi <> nil do
                             begin
@@ -766,7 +766,7 @@
     if (Gear^.Message and gmLeft  )<>0 then
         Gear^.dX:= -cLittle else
     if (Gear^.Message and gmRight )<>0 then
-        Gear^.dX:=  cLittle 
+        Gear^.dX:=  cLittle
         else exit;
 
     StepSoundTimer:= cHHStepTicks;
@@ -833,7 +833,7 @@
         Gear^.dY:= _0;
     Gear^.State:= Gear^.State or gstMoving;
     if (CurrentHedgehog^.Gear = Gear)
-        and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then 
+        and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
         begin
         // TODO: why so aggressive at setting FollowGear when falling?
         FollowGear:= Gear;
@@ -849,7 +849,7 @@
         or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then
             Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
         end
-    end 
+    end
 else
     begin
     land:= TestCollisionYwithGear(Gear, 1);
@@ -908,7 +908,7 @@
                         Gear^.X:= Gear^.X + Gear^.dX;
                         Gear^.dX:= Gear^.dX * _0_93;
                         Gear^.Y:= Gear^.Y - _2
-                        end 
+                        end
                     else
                     if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) or
                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
@@ -975,7 +975,7 @@
 // ARTILLERY but not being moved by explosions
     Gear^.X:= Gear^.X + Gear^.dX;
     Gear^.Y:= Gear^.Y + Gear^.dY;
-    if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) 
+    if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1))
     and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
         begin
         CheckHHDamage(Gear);
@@ -1068,7 +1068,7 @@
     or ((HHGear^.State and gstAttacking) <> 0)) then
         Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs
     else
-else 
+else
     with Hedgehog^ do
         if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
         and ((HHGear^.Message and gmLJump) <> 0)
@@ -1173,7 +1173,7 @@
                 begin
                 ResurrectHedgehog(Gear);
                 end
-            else 
+            else
                 begin
                 Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation);
                 Gear^.doStep:= @doStepHedgehogDead;
@@ -1217,9 +1217,9 @@
 procedure CheckIce(Gear: PGear); inline;
 (*
 var x,y,tx,ty: LongInt;
-    tdX, tdY, slope: hwFloat; 
+    tdX, tdY, slope: hwFloat;
     land: Word; *)
-var slope: hwFloat; 
+var slope: hwFloat;
 begin
     if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0)
     and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0)
@@ -1260,7 +1260,7 @@
     end;
 if GameTicks mod 100 = 0 then CheckIce(Gear);
 (*
-if Gear^.Hedgehog^.Effects[heFrozen] > 0 then 
+if Gear^.Hedgehog^.Effects[heFrozen] > 0 then
     begin
     if (Gear^.Hedgehog^.Effects[heFrozen] > 256) and (CurrentHedgehog^.Team^.Clan <> Gear^.Hedgehog^.Team^.Clan) then
         dec(Gear^.Hedgehog^.Effects[heFrozen])
@@ -1268,7 +1268,7 @@
         dec(Gear^.Hedgehog^.Effects[heFrozen])
     end;
 *)
-if (GameTicks mod 10 = 0) and (Gear^.Hedgehog^.Effects[heFrozen] > 0) and (Gear^.Hedgehog^.Effects[heFrozen] < 256) then 
+if (GameTicks mod 10 = 0) and (Gear^.Hedgehog^.Effects[heFrozen] > 0) and (Gear^.Hedgehog^.Effects[heFrozen] < 256) then
     dec(Gear^.Hedgehog^.Effects[heFrozen]);
 if (Gear^.State and gstHHDriven) = 0 then
     doStepHedgehogFree(Gear)
--- a/hedgewars/uGearsList.pas	Tue Mar 26 17:52:27 2013 -0400
+++ b/hedgewars/uGearsList.pas	Wed Mar 27 11:18:00 2013 +0100
@@ -36,7 +36,7 @@
     uGearsRender, uGearsUtils, uDebug;
 
 const
-    GearKindAmmoTypeMap : array [TGearType] of TAmmoType = (    
+    GearKindAmmoTypeMap : array [TGearType] of TAmmoType = (
 (*          gtFlame *)   amNothing
 (*       gtHedgehog *) , amNothing
 (*           gtMine *) , amMine
@@ -181,7 +181,7 @@
 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
 gear^.CollisionMask:= $FFFF;
 
-if CurrentHedgehog <> nil then 
+if CurrentHedgehog <> nil then
     begin
     gear^.Hedgehog:= CurrentHedgehog;
     if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
@@ -192,7 +192,7 @@
     gear^.Z:= cHHZ+1
 else gear^.Z:= cUsualZ;
 
-    
+
 case Kind of
      gtGrenade,
      gtClusterBomb,
@@ -648,7 +648,7 @@
         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
         //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
         (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
-            with CurrentHedgehog^ do 
+            with CurrentHedgehog^ do
                 begin
                 inc(Team^.stats.AIKills);
                 FreeTexture(Team^.AIKillsTex);
--- a/hedgewars/uLandGraphics.pas	Tue Mar 26 17:52:27 2013 -0400
+++ b/hedgewars/uLandGraphics.pas	Wed Mar 27 11:18:00 2013 +0100
@@ -22,10 +22,14 @@
 interface
 uses uFloat, uConsts, uTypes;
 
+type
+    fillType = (nullPixel, backgroundPixel, ebcPixel, icePixel, setNotCurrentMask, changePixelSetNotCurrent, setCurrentHog, changePixelNotSetNotCurrent);
+
 type TRangeArray = array[0..31] of record
                                    Left, Right: LongInt;
                                    end;
      PRangeArray = ^TRangeArray;
+TLandCircleProcedure = procedure (landX, landY, pixelX, pixelY: Longint);
 
 function  addBgColor(OldColor, NewColor: LongWord): LongWord;
 function  SweepDirty: boolean;
@@ -36,7 +40,7 @@
 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
-procedure FillRoundInLandWithIce(X, Y, Radius: LongInt);
+function FillRoundInLand(X, Y, Radius: LongInt; fill: fillType): LongWord;
 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
 function  LandBackPixel(x, y: LongInt): LongWord;
 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
@@ -48,6 +52,218 @@
 implementation
 uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
 
+
+procedure calculatePixelsCoordinates(landX, landY: Longint; var pixelX, pixelY: Longint); inline;
+begin
+if (cReducedQuality and rqBlurryLand) = 0 then
+    begin
+    pixelX := landX;
+    pixelY := landY;
+    end
+else
+    begin
+    pixelX := LandX div 2;
+    pixelY := LandY div 2;
+    end;
+end;
+
+function drawPixelBG(landX, landY, pixelX, pixelY: Longint): Longword; inline;
+begin
+drawPixelBG := 0;
+if (Land[LandY, landX] and lfIndestructible) = 0 then
+    begin
+        if ((Land[landY, landX] and lfBasic) <> 0) and (((LandPixels[pixelY, pixelX] and AMask) shr AShift) = 255) and (not disableLandBack) then
+        begin
+            LandPixels[pixelY, pixelX]:= LandBackPixel(landX, landY);
+            inc(drawPixelBG);
+        end
+        else if ((Land[landY, landX] and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then
+            LandPixels[pixelY, pixelX]:= 0
+    end;
+end;
+
+procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint); inline;
+begin
+if ((Land[landY, landX] and lfBasic) <> 0) or ((Land[landY, landX] and lfObject) <> 0) then
+    begin
+    LandPixels[pixelY, pixelX]:= ExplosionBorderColor;
+    Land[landY, landX]:= (Land[landY, landX] or lfDamaged) and not lfIce;
+    LandDirty[landY div 32, landX div 32]:= 1;
+    end;
+end;
+
+function isLandscapeEdge(weight:Longint):boolean; inline;
+begin
+result := (weight < 8) and (weight >= 2);
+end;
+
+function getPixelWeight(x, y:Longint): Longint;
+var
+    i, j:Longint;
+begin
+result := 0;
+for i := x - 1 to x + 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) then
+       begin
+       result := 9;
+       exit;
+       end;
+    if Land[j, i] and lfLandMask and not lfIce = 0 then
+       result := result + 1;
+    end;
+end;
+
+
+procedure fillPixelFromIceSprite(pixelX, pixelY:Longint); inline;
+var
+    iceSurface: PSDL_Surface;
+    icePixels: PLongwordArray;
+    w: LongWord;
+begin
+    // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness
+    iceSurface:= SpritesData[sprIceTexture].Surface;
+    icePixels := iceSurface^.pixels;
+    w:= LandPixels[pixelY, pixelX];
+    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[pixelY, pixelX] and AMask);
+        LandPixels[pixelY, pixelX]:= addBgColor(w, IceColor);
+        LandPixels[pixelY, pixelX]:= addBgColor(LandPixels[pixelY, pixelX], icePixels^[iceSurface^.w * (pixelY mod iceSurface^.h) + (pixelX mod iceSurface^.w)])
+        end
+    else
+        begin
+        LandPixels[pixelY, pixelX]:= IceColor and not AMask or $E8 shl AShift;
+        LandPixels[pixelY, pixelX]:= addBgColor(LandPixels[pixelY, pixelX], icePixels^[iceSurface^.w * (pixelY mod iceSurface^.h) + (pixelX mod iceSurface^.w)]);
+        // silly workaround to avoid having to make background erasure a tadb it smarter about sea ice
+        if LandPixels[pixelY, pixelX] and AMask shr AShift = 255 then
+            LandPixels[pixelY, pixelX]:= LandPixels[pixelY, pixelX] and not AMask or 254 shl AShift;
+        end;
+end;
+
+
+procedure DrawPixelIce(landX, landY, pixelX, pixelY: Longint); inline;
+begin
+if ((Land[landY, landX] and lfIce) <> 0) then exit;
+if isLandscapeEdge(getPixelWeight(landX, landY)) then
+    begin
+    if (LandPixels[pixelY, pixelX] and AMask < 255) and (LandPixels[pixelY, pixelX] and AMask > 0) then
+        LandPixels[pixelY, pixelX] := (IceEdgeColor and not AMask) or (LandPixels[pixelY, pixelX] and AMask)
+    else if (LandPixels[pixelY, pixelX] and AMask < 255) or (Land[landY, landX] > 255) then
+        LandPixels[pixelY, pixelX] := IceEdgeColor
+    end
+else if Land[landY, landX] > 255 then
+    begin
+        fillPixelFromIceSprite(pixelX, pixelY);
+    end;
+if Land[landY, landX] > 255 then Land[landY, landX] := Land[landY, landX] or lfIce and not lfDamaged;
+end;
+
+
+function FillLandCircleLine(y, fromPix, toPix: LongInt; fill : fillType): Longword;
+var px, py, i: LongInt;
+begin
+//get rid of compiler warning
+    px := 0;
+    py := 0;
+    FillLandCircleLine := 0;
+    case fill of
+    backgroundPixel:
+    for i:= fromPix to toPix do
+        begin
+        calculatePixelsCoordinates(i, y, px, py);
+        inc(FillLandCircleLine, drawPixelBG(i, y, px, py));
+        end;
+    ebcPixel:
+    for i:= fromPix to toPix do
+        begin
+        calculatePixelsCoordinates(i, y, px, py);
+        drawPixelEBC(i, y, px, py);
+        end;
+    nullPixel:
+    for i:= fromPix to toPix do
+        begin
+        calculatePixelsCoordinates(i, y, px, py);
+        if ((Land[y, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[y, i] > 255))  then
+            LandPixels[py, px]:= 0
+        end;
+    icePixel:
+    for i:= fromPix to toPix do
+        begin
+        calculatePixelsCoordinates(i, y, px, py);
+        DrawPixelIce(i, y, px, py);
+        end;
+    setNotCurrentMask:
+    for i:= fromPix to toPix do
+        begin
+        Land[y, i]:= Land[y, i] and lfNotCurrentMask;
+        end;
+    changePixelSetNotCurrent:
+    for i:= fromPix to toPix do
+        begin
+        if Land[y, i] and lfObjMask > 0 then
+            Land[y, i]:= (Land[y, i] and lfNotObjMask) or ((Land[y, i] and lfObjMask) - 1);
+        end;
+    setCurrentHog:
+    for i:= fromPix to toPix do
+        begin
+        Land[y, i]:= Land[y, i] or lfCurrentHog
+        end;
+    changePixelNotSetNotCurrent:
+    for i:= fromPix to toPix do
+        begin
+        if Land[y, i] and lfObjMask < lfObjMask then
+            Land[y, i]:= (Land[y, i] and lfNotObjMask) or ((Land[y, i] and lfObjMask) + 1)
+        end;
+    end;
+end;
+
+function FillLandCircleSegment(x, y, dx, dy: LongInt; fill : fillType): Longword; inline;
+begin
+    FillLandCircleSegment := 0;
+if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
+    inc(FillLandCircleSegment, FillLandCircleLine(y + dy, Max(x - dx, 0), Min(x + dx, LAND_WIDTH - 1), fill));
+if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
+    inc(FillLandCircleSegment, FillLandCircleLine(y - dy, Max(x - dx, 0), Min(x + dx, LAND_WIDTH - 1), fill));
+if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
+    inc(FillLandCircleSegment, FillLandCircleLine(y + dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
+if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
+    inc(FillLandCircleSegment, FillLandCircleLine(y - dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
+end;
+
+function FillRoundInLand(X, Y, Radius: LongInt; fill: fillType): Longword; inline;
+var dx, dy, d: LongInt;
+begin
+dx:= 0;
+dy:= Radius;
+d:= 3 - 2 * Radius;
+FillRoundInLand := 0;
+while (dx < dy) do
+    begin
+    inc(FillRoundInLand, FillLandCircleSegment(x, y, dx, dy, fill));
+    if (d < 0) then
+        d:= d + 4 * dx + 6
+    else
+        begin
+        d:= d + 4 * (dx - dy) + 10;
+        dec(dy)
+        end;
+    inc(dx)
+    end;
+if (dx = dy) then
+    inc (FillRoundInLand, FillLandCircleSegment(x, y, dx, dy, fill));
+end;
+
+
 function addBgColor(OldColor, NewColor: LongWord): LongWord;
 // Factor ranges from 0 to 100% NewColor
 var
@@ -100,67 +316,6 @@
             Land[y - dx, i]:= Value;
 end;
 
-procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet, isCurrent: boolean);
-var i: LongInt;
-begin
-if not doSet then
-    begin
-    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y + dy, i]:= Land[y + dy, i] and lfNotCurrentMask
-            else if Land[y + dy, i] and lfObjMask > 0 then
-                Land[y + dy, i]:= (Land[y + dy, i] and lfNotObjMask) or ((Land[y + dy, i] and lfObjMask) - 1);
-    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y - dy, i]:= Land[y - dy, i] and lfNotCurrentMask
-            else if Land[y - dy, i] and lfObjMask > 0 then
-                Land[y - dy, i]:= (Land[y - dy, i] and lfNotObjMask) or ((Land[y - dy, i] and lfObjMask) - 1);
-    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y + dx, i]:= Land[y + dx, i] and lfNotCurrentMask
-            else if Land[y + dx, i] and lfObjMask > 0 then
-                Land[y + dx, i]:= (Land[y + dx, i] and lfNotObjMask) or ((Land[y + dx, i] and lfObjMask) - 1);
-    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y - dx, i]:= Land[y - dx, i] and lfNotCurrentMask
-            else if Land[y - dx, i] and lfObjMask > 0 then
-                Land[y - dx, i]:= (Land[y - dx, i] and lfNotObjMask) or ((Land[y - dx, i] and lfObjMask) - 1)
-    end
-else
-    begin
-    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y + dy, i]:= Land[y + dy, i] or lfCurrentHog
-            else if Land[y + dy, i] and lfObjMask < lfObjMask then
-                Land[y + dy, i]:= (Land[y + dy, i] and lfNotObjMask) or ((Land[y + dy, i] and lfObjMask) + 1);
-    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y - dy, i]:= Land[y - dy, i] or lfCurrentHog
-            else if Land[y - dy, i] and lfObjMask < lfObjMask then
-                Land[y - dy, i]:= (Land[y - dy, i] and lfNotObjMask) or ((Land[y - dy, i] and lfObjMask) + 1);
-    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y + dx, i]:= Land[y + dx, i] or lfCurrentHog
-            else if Land[y + dx, i] and lfObjMask < lfObjMask then
-                Land[y + dx, i]:= (Land[y + dx, i] and lfNotObjMask) or ((Land[y + dx, i] and lfObjMask) + 1);
-    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
-        for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-            if isCurrent then
-                Land[y - dx, i]:= Land[y - dx, i] or lfCurrentHog
-            else if Land[y - dx, i] and lfObjMask < lfObjMask then
-                Land[y - dx, i]:= (Land[y - dx, i] and lfNotObjMask) or ((Land[y - dx, i] and lfObjMask) + 1)
-    end
-end;
-
-
-
 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
 var dx, dy, d: LongInt;
 begin
@@ -184,206 +339,17 @@
 end;
 
 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
-var dx, dy, d: LongInt;
 begin
-dx:= 0;
-dy:= Radius;
-d:= 3 - 2 * Radius;
-while (dx < dy) do
-    begin
-    ChangeCircleLines(x, y, dx, dy, doSet, isCurrent);
-    if (d < 0) then
-        d:= d + 4 * dx + 6
-    else
-        begin
-        d:= d + 4 * (dx - dy) + 10;
-        dec(dy)
-        end;
-    inc(dx)
-    end;
-if (dx = dy) then
-    ChangeCircleLines(x, y, dx, dy, doSet, isCurrent)
-end;
-
-procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
-var i, t: LongInt;
-begin
-t:= y + dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
-            else
-                LandPixels[t div 2, i div 2]:= 0;
-
-t:= y - dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
-            else
-                LandPixels[t div 2, i div 2]:= 0;
-
-t:= y + dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
-            else
-                LandPixels[t div 2, i div 2]:= 0;
-
-t:= y - dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
-            else
-                LandPixels[t div 2, i div 2]:= 0;
-
-end;
-
-
-function isLandscapeEdge(weight:Longint):boolean; inline;
-begin
-    result := (weight < 8) and (weight >= 2);
-end;
-
-function getPixelWeight(x, y:Longint): Longint;
-var
-    i, j:Longint;
-begin
-    result := 0;
-    for i := x - 1 to x + 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) then
-           begin               
-           result := 9;
-           exit;
-           end;
-
-        if Land[j, i] and lfLandMask and not lfIce = 0 then
-           result := result + 1;
-        end;
+if not doSet and isCurrent then
+    FillRoundInLand(X, Y, Radius, setNotCurrentMask)
+else if not doSet and not IsCurrent then
+    FillRoundInLand(X, Y, Radius, changePixelSetNotCurrent)
+else if doSet and IsCurrent then
+    FillRoundInLand(X, Y, Radius, setCurrentHog)
+else if doSet and not IsCurrent then
+    FillRoundInLand(X, Y, Radius, changePixelNotSetNotCurrent);
 end;
 
-procedure drawIcePixel(y, x:Longint);
-var
-    iceSurface: PSDL_Surface;
-    icePixels: PLongwordArray;
-    //pictureX, pictureY: LongInt;
-    w: LongWord;
-    //weight: Longint;
-begin
-    // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness
-    iceSurface:= SpritesData[sprIceTexture].Surface;
-    icePixels := iceSurface^.pixels;
-    w:= LandPixels[y, x];
-    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;
-const directionX : array [0..3] of Longint = (0, 0, 1, -1);
-const directionY : array [0..3] of Longint = (1, -1, 0, 0);
-begin
-    getIncrementInquarter := directionX[quarter] * dx + directionY[quarter] * dy;
-end;
-
-function getIncrementInquarter2(dx, dy, quarter: Longint): Longint; inline;
-const directionY : array [0..3] of Longint = (0, 0, 1, 1);
-const directionX : array [0..3] of Longint = (1, 1, 0, 0);
-begin
-    getIncrementInquarter2 := directionX[quarter] * dx + directionY[quarter] * dy;
-end;
-
-procedure FillLandCircleLinesIce(x, y, dx, dy: LongInt);
-var q, i, t, px, py: LongInt;
-begin
-for q := 0 to 3 do
-    begin
-    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 lfIce = 0 then
-                begin
-                if (cReducedQuality and rqBlurryLand) = 0 then
-                    begin
-                    px:= i; py:= t
-                    end
-                else
-                    begin
-                    px:= i div 2; py:= t div 2
-                    end;
-                if isLandscapeEdge(getPixelWeight(i, t)) then
-                    begin
-                    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
-                        LandPixels[py, px] := IceEdgeColor
-                    end
-                else if Land[t, i] > 255 then
-                    begin
-                    drawIcePixel(py, px)
-                    end;
-                if Land[t, i] > 255 then Land[t, i] := Land[t, i] or lfIce and not lfDamaged;
-                end;
-    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
-    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)
-    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;
-
-
 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
 var
     i, j: integer;
@@ -395,259 +361,32 @@
         begin
         if Land[j, i] = 0 then
             begin
-            Land[j, i] := lfIce;                
-            drawIcePixel(j, i);
+            Land[j, i] := lfIce;
+            fillPixelFromIceSprite(i, j);
             end;
-        end;        
+        end;
     end;
 landRect.x := min(max(x - iceRadius, 0), LAND_WIDTH - 1);
 landRect.y := min(max(y, 0), LAND_HEIGHT - 1);
 landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
 landRect.h := min(iceHeight, LAND_HEIGHT - landRect.y - 1);
-UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);        
-end;
-
-
-
-function FillLandCircleLinesBG(x, y, dx, dy: LongInt): Longword;
-var i, t, by, bx: LongInt;
-    cnt: Longword;
-begin
-cnt:= 0;
-t:= y + dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if (Land[t, i] and lfIndestructible) = 0 then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                begin
-                by:= t; bx:= i;
-                end
-            else
-                begin
-                by:= t div 2; bx:= i div 2;
-                end;
-            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
-                begin
-                inc(cnt);
-                LandPixels[by, bx]:= LandBackPixel(i, t)
-                end
-            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
-                LandPixels[by, bx]:= 0
-            end;
-
-t:= y - dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if (Land[t, i] and lfIndestructible) = 0 then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                begin
-                by:= t; bx:= i;
-                end
-            else
-                begin
-                by:= t div 2; bx:= i div 2;
-                end;
-            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
-                begin
-                inc(cnt);
-                LandPixels[by, bx]:= LandBackPixel(i, t)
-                end
-            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
-                LandPixels[by, bx]:= 0
-            end;
-
-t:= y + dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if (Land[t, i] and lfIndestructible) = 0 then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                begin
-                by:= t; bx:= i;
-                end
-            else
-                begin
-                by:= t div 2; bx:= i div 2;
-                end;
-            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
-                begin
-                inc(cnt);
-                LandPixels[by, bx]:= LandBackPixel(i, t)
-                end
-            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
-                LandPixels[by, bx]:= 0
-            end;
-t:= y - dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if (Land[t, i] and lfIndestructible) = 0 then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                begin
-                by:= t; bx:= i;
-                end
-            else
-                begin
-                by:= t div 2; bx:= i div 2;
-                end;
-            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
-                begin
-                inc(cnt);
-                LandPixels[by, bx]:= LandBackPixel(i, t)
-                end
-            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
-                LandPixels[by, bx]:= 0
-            end;
-FillLandCircleLinesBG:= cnt;
-end;
-
-procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
-var i, t: LongInt;
-begin
-t:= y + dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= ExplosionBorderColor
-            else
-                LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
-
-            Land[t, i]:= (Land[t, i] or lfDamaged) and not lfIce;
-            //Despeckle(i, t);
-            LandDirty[t div 32, i div 32]:= 1;
-            end;
-
-t:= y - dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= ExplosionBorderColor
-            else
-                LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
-            Land[t, i]:= (Land[t, i] or lfDamaged) and not lfIce;
-            //Despeckle(i, t);
-            LandDirty[t div 32, i div 32]:= 1;
-            end;
-
-t:= y + dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= ExplosionBorderColor
-            else
-               LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
-
-            Land[t, i]:= (Land[t, i] or lfDamaged) and not lfIce;
-            //Despeckle(i, t);
-            LandDirty[t div 32, i div 32]:= 1;
-            end;
-
-t:= y - dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
-    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
-            begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= ExplosionBorderColor
-            else
-                LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
-
-            Land[t, i]:= (Land[t, i] or lfDamaged) and not lfIce;
-            //Despeckle(i, y - dy);
-            LandDirty[t div 32, i div 32]:= 1;
-            end;
+UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
 end;
 
 function DrawExplosion(X, Y, Radius: LongInt): Longword;
-var dx, dy, ty, tx, d: LongInt;
-    cnt: Longword;
+var
+    tx, ty, dx, dy: Longint;
 begin
-
-// draw background land texture
-    begin
-    cnt:= 0;
-    dx:= 0;
-    dy:= Radius;
-    d:= 3 - 2 * Radius;
-
-    while (dx < dy) do
-        begin
-        inc(cnt, FillLandCircleLinesBG(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)
-        end;
-    if (dx = dy) then
-        inc(cnt, FillLandCircleLinesBG(x, y, dx, dy));
-    end;
-
-// draw a hole in land
-if Radius > 20 then
-    begin
-    dx:= 0;
-    dy:= Radius - 15;
-    d:= 3 - 2 * dy;
-
-    while (dx < dy) do
-        begin
-        FillLandCircleLines0(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)
-        end;
-    if (dx = dy) then
-        FillLandCircleLines0(x, y, dx, dy);
-    end;
-
-  // FillRoundInLand after erasing land pixels to allow Land 0 check for mask.png to function
+    DrawExplosion := FillRoundInLand(x, y, Radius, backgroundPixel);
+    if Radius > 20 then
+        FillRoundInLand(x, y, Radius - 15, nullPixel);
     FillRoundInLand(X, Y, Radius, 0);
-
-// draw explosion border
-    begin
-    inc(Radius, 4);
-    dx:= 0;
-    dy:= Radius;
-    d:= 3 - 2 * Radius;
-    while (dx < dy) do
-        begin
-        FillLandCircleLinesEBC(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)
-        end;
-    if (dx = dy) then
-        FillLandCircleLinesEBC(x, y, dx, dy);
-    end;
-
-tx:= Max(X - Radius - 1, 0);
-dx:= Min(X + Radius + 1, LAND_WIDTH) - tx;
-ty:= Max(Y - Radius - 1, 0);
-dy:= Min(Y + Radius + 1, LAND_HEIGHT) - ty;
-UpdateLandTexture(tx, dx, ty, dy, false);
-DrawExplosion:= cnt
+    FillRoundInLand(x, y, Radius + 4, ebcPixel);
+    tx:= Max(X - Radius - 1, 0);
+    dx:= Min(X + Radius + 1, LAND_WIDTH) - tx;
+    ty:= Max(Y - Radius - 1, 0);
+    dy:= Min(Y + Radius + 1, LAND_HEIGHT) - ty;
+    UpdateLandTexture(tx, dx, ty, dy, false);
 end;
 
 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
@@ -701,6 +440,33 @@
 UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false)
 end;
 
+
+
+procedure DrawExplosionBorder(X, Y, dx, dy:hwFloat;  despeckle : Boolean);
+var
+    t, tx, ty :Longint;
+begin
+for t:= 0 to 7 do
+    begin
+    X:= X + dX;
+    Y:= Y + dY;
+    tx:= hwRound(X);
+    ty:= hwRound(Y);
+    if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0)
+    or ((Land[ty, tx] and lfObject) <> 0)) then
+        begin
+        Land[ty, tx]:= (Land[ty, tx] or lfDamaged) and not lfIce;
+        if despeckle then
+            LandDirty[ty div 32, tx div 32]:= 1;
+        if (cReducedQuality and rqBlurryLand) = 0 then
+            LandPixels[ty, tx]:= ExplosionBorderColor
+        else
+            LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
+        end
+    end;
+end;
+
+
 //
 //  - (dX, dY) - direction, vector of length = 0.5
 //
@@ -753,24 +519,7 @@
     begin
     X:= nx - dX8;
     Y:= ny - dY8;
-    for t:= 0 to 7 do
-        begin
-        X:= X + dX;
-        Y:= Y + dY;
-        tx:= hwRound(X);
-        ty:= hwRound(Y);
-        if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0)
-        or ((Land[ty, tx] and lfObject) <> 0)) then
-            begin
-            Land[ty, tx]:= (Land[ty, tx] or lfDamaged) and not lfIce;
-            if despeckle then
-                LandDirty[ty div 32, tx div 32]:= 1;
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[ty, tx]:= ExplosionBorderColor
-            else
-                LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
-            end
-        end;
+    DrawExplosionBorder(X, Y, dx, dy, despeckle);
     X:= nx;
     Y:= ny;
     for t:= 0 to ticks do
@@ -796,24 +545,7 @@
             Land[ty, tx]:= 0;
             end
         end;
-    for t:= 0 to 7 do
-    begin
-    X:= X + dX;
-    Y:= Y + dY;
-    tx:= hwRound(X);
-    ty:= hwRound(Y);
-    if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0)
-    or ((Land[ty, tx] and lfObject) <> 0)) then
-        begin
-        Land[ty, tx]:=( Land[ty, tx] or lfDamaged) and not lfIce;
-        if despeckle then
-            LandDirty[ty div 32, tx div 32]:= 1;
-        if (cReducedQuality and rqBlurryLand) = 0 then
-            LandPixels[ty, tx]:= ExplosionBorderColor
-        else
-            LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
-        end
-        end;
+    DrawExplosionBorder(X, Y, dx, dy, despeckle);
     nx:= nx - dY;
     ny:= ny + dX;
     end;
--- a/hedgewars/uTypes.pas	Tue Mar 26 17:52:27 2013 -0400
+++ b/hedgewars/uTypes.pas	Wed Mar 27 11:18:00 2013 +0100
@@ -437,7 +437,7 @@
 
     TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
             sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync,
-            sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady, 
+            sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady,
             sidBounce1, sidBounce2, sidBounce3, sidBounce4, sidBounce5, sidBounce,
             sidMute);
 
@@ -448,8 +448,8 @@
 
     TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable,
             gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery,
-            gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, 
-            gidRandomMineTimer, gidDamageModifier, gidResetHealth, gidAISurvival, 
+            gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer,
+            gidRandomMineTimer, gidDamageModifier, gidResetHealth, gidAISurvival,
             gidInfAttack, gidResetWeps, gidPerHogAmmo, gidTagTeam);
 
     TLandArray = packed array of array of LongWord;