deletegear rearrangement applied to branch too. if this causes desyncs you're probably in a crashy state already 0.9.25
authornemo
Fri, 11 Jan 2019 08:42:15 -0500
branch0.9.25
changeset 14560 945bf1d4d1a4
parent 14513 666b31c58de8
child 14561 5e4df5413e1e
deletegear rearrangement applied to branch too. if this causes desyncs you're probably in a crashy state already
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Tue Jan 01 11:17:28 2019 -0500
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Jan 11 08:42:15 2019 -0500
@@ -1188,9 +1188,7 @@
             end
         end
     else
-        begin
-        DeleteGear(Gear);
-        end
+		DeleteGear(Gear);
 end;
 
 procedure CreateShellForGear(Gear: PGear; startFrame: Longword);
@@ -2038,7 +2036,8 @@
                 or (getRandom(100) > cMineDudPercent) then
                     begin
                     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
-                    DeleteGear(Gear)
+                    DeleteGear(Gear);
+					exit   // redundant but we've had too many delete gear bugs
                     end
                 else
                     begin
@@ -2081,7 +2080,8 @@
                     hwRound(Gear^.X) - SpritesData[sprFrozenAirMine].Width div 2,
                     hwRound(Gear^.Y) - SpritesData[sprFrozenAirMine].Height div 2,
                     sprFrozenAirMine, 0, 0, false, false, false, false);
-            DeleteGear(Gear)
+            DeleteGear(Gear);
+			exit
             end;
         doStepFallingGear(Gear);
         exit
@@ -2461,9 +2461,6 @@
         y := hwRound(Gear^.Y);
         hog:= Gear^.Hedgehog;
 
-        DeleteGear(Gear);
-        // <-- delete gear!
-
         if k = gtCase then
             begin
             doMakeExplosion(x, y, Gear^.Boom, hog, EXPLAutoSound);
@@ -2473,17 +2470,18 @@
         else if k = gtTarget then
             uStats.TargetHit()
         else if k = gtExplosives then
-                begin
-                doMakeExplosion(x, y, Gear^.Boom, hog, EXPLAutoSound);
-                for i:= 0 to 31 do
-                    begin
-                    dX := AngleCos(i * 64) * _0_5 * (getrandomf + _1);
-                    dY := AngleSin(i * 64) * _0_5 * (getrandomf + _1);
-                    AddGear(x, y, gtFlame, 0, dX, dY, 0);
-                    AddGear(x, y, gtFlame, gstTmpFlag, -dX, -dY, 0);
-                    end
-                end;
-            exit
+			begin
+			doMakeExplosion(x, y, Gear^.Boom, hog, EXPLAutoSound);
+			for i:= 0 to 31 do
+				begin
+				dX := AngleCos(i * 64) * _0_5 * (getrandomf + _1);
+				dY := AngleSin(i * 64) * _0_5 * (getrandomf + _1);
+				AddGear(x, y, gtFlame, 0, dX, dY, 0);
+				AddGear(x, y, gtFlame, gstTmpFlag, -dX, -dY, 0);
+				end
+			end;
+        DeleteGear(Gear);
+		exit
         end;
 
     if k = gtExplosives then
@@ -2862,7 +2860,7 @@
                 AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke);
 
         DeleteGear(Gear)
-        end;
+        end
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2955,11 +2953,11 @@
             dY := _0;
             State := State or gstMoving;
             end;
-        DeleteGear(Gear);
         if (GetAmmoEntry(HHGear^.Hedgehog^, amParachute)^.Count >= 1) and ((Ammoz[HHGear^.Hedgehog^.CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and (HHGear^.Hedgehog^.MultiShootAttacks = 0) then
             HHGear^.Hedgehog^.CurAmmoType:= amParachute;
         isCursorVisible := false;
         ApplyAmmoChanges(HHGear^.Hedgehog^);
+        DeleteGear(Gear);
         exit
         end;
 
@@ -3039,7 +3037,7 @@
         // avoid to play forever (is this necessary?)
         StopSoundChan(Gear^.SoundChannel);
         DeleteGear(Gear)
-        end;
+        end
 end;
 
 procedure doStepAirAttack(Gear: PGear);
@@ -3082,12 +3080,12 @@
     if (Gear^.State and gstCollision) <> 0 then
         begin
         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
-        DeleteGear(Gear);
         {$IFNDEF PAS2C}
         with mobileRecord do
             if (performRumble <> nil) and (not fastUntilLag) then
                 performRumble(kSystemSoundID_Vibrate);
         {$ENDIF}
+        DeleteGear(Gear);
         exit
         end;
     if (GameTicks and $3F) = 0 then
@@ -3143,7 +3141,7 @@
         begin
         PlaySound(sndPlaced);
         DeleteGear(Gear);
-        AfterAttack;
+        AfterAttack
         end;
 
     HHGear^.State := HHGear^.State and (not (gstAttacking or gstAttacked));
@@ -3175,6 +3173,7 @@
         begin
         DeleteGear(Gear);
         AfterAttack;
+		exit
         end;
     inc(Gear^.Timer);
     if Gear^.Timer = 65 then
@@ -3278,12 +3277,12 @@
         begin
         hedgehog := Gear^.Hedgehog;
         //Msg := Gear^.Message and (not gmSwitch);
-        DeleteGear(Gear);
         ApplyAmmoChanges(hedgehog^);
 
         HHGear := CurrentHedgehog^.Gear;
         ApplyAmmoChanges(HHGear^.Hedgehog^);
         //HHGear^.Message := Msg;
+        DeleteGear(Gear);
         exit
         end;
 
@@ -4487,7 +4486,6 @@
                 Active := true;
                 State := State or gstMoving
                 end;
-            DeleteGear(Gear);
             if (GetAmmoEntry(HHGear^.Hedgehog^, amJetpack)^.Count >= 1) and ((Ammoz[HHGear^.Hedgehog^.CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and (HHGear^.Hedgehog^.MultiShootAttacks = 0) then
                 HHGear^.Hedgehog^.CurAmmoType:= amJetpack;
             isCursorVisible := false;
@@ -4497,6 +4495,7 @@
 //    Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', cWhiteColor, fntSmall)
 
 //AddCaption(trmsg[sidFuel]+': '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate);
+            DeleteGear(Gear);
             end
 end;
 
@@ -4534,9 +4533,7 @@
     if Gear^.Timer < 2000 then
         inc(Gear^.Timer, 1)
     else
-        begin
-        DeleteGear(Gear);
-        end;
+        DeleteGear(Gear)
 end;
 
 procedure doStepBirdyFly(Gear: PGear);