TimeBox: Fix buggy behaviour if hog took damage or died before time box arrived
authorWuzzy <Wuzzy2@mail.ru>
Tue, 09 Jul 2019 12:55:58 +0200
changeset 15243 deaa316af414
parent 15242 bf11546c1920
child 15244 32678e65b25e
TimeBox: Fix buggy behaviour if hog took damage or died before time box arrived
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
--- a/ChangeLog.txt	Mon Jul 08 22:29:20 2019 +0200
+++ b/ChangeLog.txt	Tue Jul 09 12:55:58 2019 +0200
@@ -27,6 +27,7 @@
  * Fix hedgehogs being pushed around (and other collision bugs) when they overlap
  * Fix homing bee flying weird if passing wrap world edge or target was placed beyond it
  * Fix air mine not colliding with crates initially
+ * Fix buggy behaviour of time box if hog took damage or died before it arrived
  * Fix poison damage not working in first round
  * Use player-chosen team identity in campaigns and singleplayer missions
  * Fix player-chosen teams ignoring custom team controls in campaigns
--- a/hedgewars/uGearsHandlersMess.pas	Mon Jul 08 22:29:20 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Jul 09 12:55:58 2019 +0200
@@ -6233,6 +6233,20 @@
     s: ansistring;
 begin
 HH:= Gear^.Hedgehog;
+if Gear^.Tag = 0 then
+    begin
+    if HH^.Gear <> nil then
+        begin
+        if (HH^.Gear^.Damage <> 0) or (HH^.Gear^.Health = 0) or
+        ((HH^.Gear^.State and (gstMoving or gstHHDeath or gstHHGone or gstDrowning)) <> 0) then
+            Gear^.Tag:= 1;
+        end
+    else if HH^.GearHidden = nil then
+        Gear^.Tag:= 1;
+    if (Gear^.Tag = 1) and (Gear = CurAmmoGear) then
+        CurAmmoGear:= nil;
+    end;
+
 if Gear^.Pos = 2 then
     begin
     StopSoundChan(Gear^.SoundChannel);
@@ -6241,11 +6255,12 @@
         begin
         if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible = 0) then
             begin
-            AfterAttack;
-            if Gear = CurAmmoGear then CurAmmoGear := nil;
-            if (HH^.Gear^.Damage = 0) and  (HH^.Gear^.Health > 0) and
-            ((Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then
-                HideHog(HH)
+            if Gear^.Tag = 0 then
+                AfterAttack;
+            if Gear = CurAmmoGear then
+                CurAmmoGear:= nil;
+            if Gear^.Tag = 0 then
+                HideHog(HH);
             end
         else if (HH^.GearHidden <> nil) then
             begin
@@ -6267,8 +6282,7 @@
     begin
     inc(Gear^.Power);
     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
+        (Gear^.Tag = 0) then
             with HH^.Gear^ do
                 begin
                 State:= State or gstAnimation;
--- a/hedgewars/uGearsList.pas	Mon Jul 08 22:29:20 2019 +0200
+++ b/hedgewars/uGearsList.pas	Tue Jul 09 12:55:58 2019 +0200
@@ -582,7 +582,8 @@
                 gear^.Elasticity:= _0_3;
                 end;
       gtTardis: begin
-                gear^.Pos:= 1;
+                gear^.Pos:= 1; // tardis phase
+                gear^.Tag:= 0; // 1 = hedgehog died, disappeared, took damage or moved
                 gear^.Z:= cCurrHHZ+1;
                 end;
       gtMortar: begin