Disable a bit of code from revision 4 that I'm pretty sure is not hit anymore, or we'd end up with plenty of doubled graves at a minimum. Also, clear gstWinner/gstLoser along with gstWait - still need to figure out why exactly those aren't rendering anymore though.
authornemo
Tue, 20 Sep 2011 20:52:04 -0400
changeset 5977 0b1bfdd95310
parent 5976 306cedbeb213
child 5978 bc70c6c94912
Disable a bit of code from revision 4 that I'm pretty sure is not hit anymore, or we'd end up with plenty of doubled graves at a minimum. Also, clear gstWinner/gstLoser along with gstWait - still need to figure out why exactly those aren't rendering anymore though.
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Wed Sep 21 02:05:42 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Sep 20 20:52:04 2011 -0400
@@ -118,7 +118,7 @@
     Message := Message and not gmAttack;
     end;
 HH^.GearHidden:= HH^.Gear;
-HH^.Gear:= nil;
+HH^.Gear:= nil
 end;
 
 procedure RestoreHog(HH: PHedgehog);
@@ -5097,7 +5097,6 @@
 var HH: PHedgehog;
     i,j,cnt: LongWord;
 begin
-
 HH:= Gear^.Hedgehog;
 if Gear^.Pos = 2 then
     begin
@@ -5108,7 +5107,9 @@
             begin
             AfterAttack;
             if Gear = CurAmmoGear then CurAmmoGear := nil;
-            HideHog(HH)
+            if (HH^.Gear^.Damage = 0) and  (HH^.Gear^.Health > 0) and 
+            ((Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then
+                HideHog(HH)
             end
         //else if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible <> 0) then
         else if (HH^.GearHidden <> nil) then// and (HH^.Gear^.State and gstInvisible <> 0) then
@@ -5126,8 +5127,10 @@
 if (Gear^.Pos = 1) and (GameTicks and $1F = 0) and (Gear^.Power < 255) then 
     begin
     inc(Gear^.Power);
-    if (Gear^.Power = 172) and (Gear^.Hedgehog^.Gear <> nil) then
-        with Gear^.Hedgehog^.Gear^ do
+    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
             begin
 	        State:= State or gstAnimation;
 	        Tag:= 2;
@@ -5191,13 +5194,14 @@
     3. Hog is a king
 *)
     HH:= Gear^.Hedgehog;
+    if HH^.Gear <> nil then 
     if (HH^.Gear = nil) or (HH^.King) or (SuddenDeathDmg) then
         begin
-	if HH^.Gear <> nil then 
-	    begin
-	    HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
-	    HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
-	    end;
+        if HH^.Gear <> nil then 
+            begin
+            HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
+            HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
+            end;
         PlaySound(sndDenied);
         DeleteGear(gear);
         exit
@@ -5211,14 +5215,14 @@
                 HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then inc(cnt);
     if cnt < 2 then
         begin
-	if HH^.Gear <> nil then 
-	    begin
-	    HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
-	    HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
-	    end;
-        PlaySound(sndDenied);
-        DeleteGear(gear);
-        exit
+        if HH^.Gear <> nil then 
+            begin
+            HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
+            HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
+            end;
+            PlaySound(sndDenied);
+            DeleteGear(gear);
+            exit
         end;
     Gear^.SoundChannel := LoopSound(sndTardis);
     Gear^.doStep:= @doStepTardisWarp
--- a/hedgewars/HHHandlers.inc	Wed Sep 21 02:05:42 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Tue Sep 20 20:52:04 2011 -0400
@@ -1047,7 +1047,6 @@
             end else 
                 begin
                 Gear^.State:= (Gear^.State or gstHHDeath) and not gstAnimation;
-                Gear^.Timer:= 0;
                 Gear^.doStep:= @doStepHedgehogDead;
                 // Death message
                 AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
@@ -1055,7 +1054,7 @@
             end
         else
             begin
-            Gear^.State:= Gear^.State or gstHHGone;
+            Gear^.State:= (Gear^.State or gstHHGone) and not gstAnimation;
             Gear^.doStep:= @doStepHedgehogGone;
 
             with Gear^.Hedgehog^.Team^ do
@@ -1086,7 +1085,7 @@
     begin
     if Gear^.Timer = 0 then
         begin
-        Gear^.State:= Gear^.State and not gstWait;
+        Gear^.State:= Gear^.State and not (gstWait or gstLoser or gstWinner);
         Gear^.Active:= false;
         AddGearCI(Gear);
         exit
--- a/hedgewars/uGears.pas	Wed Sep 21 02:05:42 2011 +0200
+++ b/hedgewars/uGears.pas	Tue Sep 20 20:52:04 2011 -0400
@@ -602,14 +602,16 @@
             Gear^.IntersectGear^.IntersectGear:= nil;
     end
 else if Gear^.Kind = gtHedgehog then
-    if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then
+    (*
+    This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS.  I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves.  I believe it should be removed
+     if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then
         begin
         AttackBar:= 0;
         Gear^.Message:= gmDestroy;
         CurAmmoGear^.Message:= gmDestroy;
         exit
         end
-    else
+    else*)
         begin
         if (hwRound(Gear^.Y) >= cWaterLine) then
             begin