fix some old code that assumes that a bullet under water is always outside land array - which is wrong (e.g. during sudden-death in previous releases, also weSea now)
authorsheepluva
Thu, 11 Dec 2014 01:24:27 +0100
changeset 10650 7f23971bd9db
parent 10649 d83897fed816
child 10651 7a8e321be3bd
fix some old code that assumes that a bullet under water is always outside land array - which is wrong (e.g. during sudden-death in previous releases, also weSea now) also removed usage of Gear^.Damage after "if Gear^.Damage > 0 then Gear^.Damage:= 0;"
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Wed Dec 10 22:33:09 2014 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Dec 11 01:24:27 2014 +0100
@@ -1267,15 +1267,22 @@
         dec(Gear^.Health, Gear^.Damage);
         Gear^.Damage := 0
         end;
-    if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Damage < Gear^.Health) and ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
-        begin
-        for i:=(Gear^.Health - Gear^.Damage) * 4 downto 0 do
+
+    if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Health > 0) then
+        begin
+        // draw bubbles
+        if (not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF)) then
             begin
-            if Random(6) = 0 then
-                AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble);
-            Gear^.X := Gear^.X + Gear^.dX;
-            Gear^.Y := Gear^.Y + Gear^.dY;
+            for i:=(Gear^.Health * 4) downto 0 do
+                begin
+                if Random(6) = 0 then
+                    AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble);
+                Gear^.X := Gear^.X + Gear^.dX;
+                Gear^.Y := Gear^.Y + Gear^.dY;
+                end;
             end;
+        // bullet dies underwater
+        Gear^.Health:= 0;
         end;
 
     if (Gear^.Health <= 0)
@@ -1288,7 +1295,7 @@
                 cArtillery := false;
 
         // Bullet Hit
-            if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then
+            if ((Gear^.State and gstDrowning) = 0) and (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then
                 begin
                 VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit);
                 if VGear <> nil then