# HG changeset patch
# User nemo
# Date 1413747969 14400
# Node ID 4c8fc3aa9432b97ce8ecf12c3e8bd484bf4fc75c
# Parent  27d34e33dabce2f51870a13179c778b2aa3b11a5
allow hogs to repeatedly enter portals placed on the ground

diff -r 27d34e33dabc -r 4c8fc3aa9432 hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas	Thu Oct 09 22:14:55 2014 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Sun Oct 19 15:46:09 2014 -0400
@@ -750,6 +750,7 @@
 procedure HedgehogStep(Gear: PGear);
 var PrevdX: LongInt;
     CurWeapon: PAmmo;
+    portals: PGearArrayS;
 begin
 CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
 if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
@@ -812,6 +813,12 @@
         exit
         end;
 
+    if (Gear^.Message and (gmLeft or gmRight) <> 0) and (Gear^.State and gstMoving = 0) then
+        begin
+        // slightly inefficient since it doesn't halt after one portal, maybe could add a param to GearsNear for number desired.
+        portals:= GearsNear(Gear^.X, Gear^.Y, gtPortal, 26);
+        if portals.size = 0 then Gear^.PortalCounter:= 0
+        end;
     PrevdX:= hwSign(Gear^.dX);
     if (Gear^.Message and gmLeft  )<>0 then
         Gear^.dX:= -cLittle else