Fix TARDIS, make switcher work w/ the new more stringent check.
authornemo
Thu, 19 Jul 2012 17:34:18 -0400
changeset 7400 09427dbec1d8
parent 7399 e7ce559d8c94
child 7401 4c3ec3dca0c7
Fix TARDIS, make switcher work w/ the new more stringent check.
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Thu Jul 19 17:14:02 2012 -0400
+++ b/hedgewars/GSHandlers.inc	Thu Jul 19 17:34:18 2012 -0400
@@ -116,12 +116,12 @@
         
     if lastGearByUID = HH^.Gear then
         lastGearByUID := nil;
-        
-    RemoveGearFromList(HH^.Gear);
+    
+    HH^.Gear^.Message:= HH^.Gear^.Message or gmRemoveFromList;
     with HH^.Gear^ do
         begin
         Z := cHHZ;
-        Active := false;
+        HH^.Gear^.Active:= false;
         State:= State and (not (gstHHDriven or gstAttacking or gstAttacked));
         Message := Message and (not gmAttack);
     end;
@@ -2794,10 +2794,9 @@
         Gear^.Message := Gear^.Message and (not gmSwitch);
         State := HHGear^.State;
         HHGear^.State := 0;
+        HHGear^.Z := cHHZ;
         HHGear^.Active := false;
-        HHGear^.Z := cHHZ;
-        RemoveGearFromList(HHGear);
-        InsertGearToList(HHGear);
+        HHGear^.Message:= HHGear^.Message or gmRemoveFromList or gmAddToList;
 
         PlaySound(sndSwitchHog);
 
@@ -2813,8 +2812,7 @@
         HHGear^.Active := true;
         FollowGear := HHGear;
         HHGear^.Z := cCurrHHZ;
-        RemoveGearFromList(HHGear);
-        InsertGearToList(HHGear);
+        HHGear^.Message:= HHGear^.Message or gmRemoveFromList or gmAddToList;
         Gear^.X := HHGear^.X;
         Gear^.Y := HHGear^.Y
         end;
--- a/hedgewars/uConsts.pas	Thu Jul 19 17:14:02 2012 -0400
+++ b/hedgewars/uConsts.pas	Thu Jul 19 17:34:18 2012 -0400
@@ -227,20 +227,23 @@
     gstHHGone         = $00100000;
     gstInvisible      = $00200000;
 
-    gmLeft   = $00000001;
-    gmRight  = $00000002;
-    gmUp     = $00000004;
-    gmDown   = $00000008;
-    gmSwitch = $00000010;
-    gmAttack = $00000020;
-    gmLJump  = $00000040;
-    gmHJump  = $00000080;
-    gmDestroy= $00000100;
-    gmSlot   = $00000200; // with param
-    gmWeapon = $00000400; // with param
-    gmTimer  = $00000800; // with param
-    gmAnimate= $00001000; // with param
-    gmPrecise= $00002000;
+    gmLeft           = $00000001;
+    gmRight          = $00000002;
+    gmUp             = $00000004;
+    gmDown           = $00000008;
+    gmSwitch         = $00000010;
+    gmAttack         = $00000020;
+    gmLJump          = $00000040;
+    gmHJump          = $00000080;
+    gmDestroy        = $00000100;
+    gmSlot           = $00000200; // with param
+    gmWeapon         = $00000400; // with param
+    gmTimer          = $00000800; // with param
+    gmAnimate        = $00001000; // with param
+    gmPrecise        = $00002000;
+
+    gmRemoveFromList = $00004000;
+    gmAddToList      = $00008000;
     gmAllStoppable = gmLeft or gmRight or gmUp or gmDown or gmAttack or gmPrecise;
 
     cMaxSlotIndex       = 9;
--- a/hedgewars/uGears.pas	Thu Jul 19 17:14:02 2012 -0400
+++ b/hedgewars/uGears.pas	Thu Jul 19 17:34:18 2012 -0400
@@ -206,6 +206,13 @@
     curHandledGear:= t;
     t:= curHandledGear^.NextGear;
 
+    if curHandledGear^.Message and gmRemoveFromList <> 0 then 
+        begin
+        RemoveGearFromList(curHandledGear);
+        // since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block
+        if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear);
+        curHandledGear^.Message:= curHandledGear^.Message and not (gmRemoveFromList or gmAddToList)
+        end;
     if curHandledGear^.Active then
         begin
         if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then