hedgewars/GSHandlers.inc
changeset 3468 c7b80bdbc384
parent 3462 4b36933dce1d
child 3471 e1f1ab5dfd8f
--- a/hedgewars/GSHandlers.inc	Sun May 16 23:18:23 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sun May 16 23:43:45 2010 +0000
@@ -3300,10 +3300,16 @@
                 // make the ball visible
             end;
 
-    if destroyGear then deleteGear(oldPortal);
+    if destroyGear then oldPortal^.Timer:= 0;
 end;
 
 begin
+    if (Gear^.Timer < 1) then
+    begin
+        deleteGear(Gear);
+        EXIT;
+    end;
+    
     doPortalColorSwitch();
 
     Gear^.X := Gear^.X + Gear^.dX;
@@ -3378,13 +3384,11 @@
             while iterator <> nil do
             begin
                 if (iterator^.Kind = gtPortal) then
-                    if (iterator <> newPortal) then
+                    if (iterator <> newPortal) and (iterator^.Timer > 0) then
                     begin
                         if (iterator^.Tag and 2) = (newPortal^.Tag and 2) then
                         begin
-                            iterator := iterator^.PrevGear;
-                            deleteGear(iterator^.NextGear);
-                            continue;
+                            iterator^.Timer:= 0;
                         end
                         else
                         begin