Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
authornemo
Sat, 03 Sep 2011 18:04:19 -0400
changeset 5750 6bbf7aee2cdf
parent 5749 134d57761f3d
child 5751 f8f7e61d090d
child 5752 ea95ee97c805
Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
hedgewars/GSHandlers.inc
hedgewars/uCollisions.pas
--- a/hedgewars/GSHandlers.inc	Sat Sep 03 20:36:08 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Sat Sep 03 18:04:19 2011 -0400
@@ -2900,7 +2900,7 @@
 
     dec(Gear^.Health);
     Gear^.Timer := Gear^.Health*10;
-    Gear^.PortalCounter:= 0;
+    if Gear^.Health mod 100 = 0 then Gear^.PortalCounter:= 0;
     // This is not seconds, but at least it is *some* feedback
     if (Gear^.Health = 0) or ((Gear^.Message and gmAttack) <> 0) then
     begin
@@ -3941,8 +3941,7 @@
 
         // inverse cake's normal movement direction,
         // as if it just walked through a hole
-        if iscake then
-            nspeed.isNegative:= not nspeed.isNegative;
+        //if iscake then nspeed.isNegative:= not nspeed.isNegative;
 
 //AddFileLog('poffs:'+cstr(poffs)+' noffs:'+cstr(noffs)+' pspeed:'+cstr(pspeed)+' nspeed:'+cstr(nspeed));
         iterator^.dX := -pspeed * conPortal^.dX + nspeed * nx;
@@ -3993,8 +3992,8 @@
                 iterator^.Radius := iterator^.Radius - 1;
 
             // check front
-            isCollision := TestCollisionYwithGear(iterator, sy)
-                        or TestCollisionXwithGear(iterator, sx);
+            isCollision := TestCollisionY(iterator, sy)
+                        or TestCollisionX(iterator, sx);
 
             if not isCollision then
             begin
@@ -4002,8 +4001,8 @@
                 // the square check won't check more pixels than we want to)
                 iterator^.Radius := 1 + resetr div 2;
                 rh := resetr div 4;
-                isCollision := TestCollisionYwithXYShift(iterator,       0, -sy * rh, sy)
-                            or TestCollisionXwithXYShift(iterator, ox * rh,        0, sx);
+                isCollision := TestCollisionYwithXYShift(iterator,       0, -sy * rh, sy, false)
+                            or TestCollisionXwithXYShift(iterator, ox * rh,        0, sx, false);
             end;
 
             iterator^.Radius := resetr;
@@ -4024,7 +4023,8 @@
         //
 
         // Until loops are reliably broken
-        inc(iterator^.PortalCounter);
+        if iscake then iterator^.PortalCounter:= 33
+        else inc(iterator^.PortalCounter);
 
         if not isbullet and (iterator^.Kind <> gtFlake) then
             FollowGear := iterator;
--- a/hedgewars/uCollisions.pas	Sat Sep 03 20:36:08 2011 +0200
+++ b/hedgewars/uCollisions.pas	Sat Sep 03 18:04:19 2011 -0400
@@ -47,8 +47,8 @@
 function  TestCollisionX(Gear: PGear; Dir: LongInt): boolean;
 function  TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
 
-function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
-function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
+function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
+function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
 
 function  calcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean;
 
@@ -291,11 +291,13 @@
    end
 end;
 
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
 begin
 Gear^.X:= Gear^.X + ShiftX;
 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
-TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir);
+if withGear then 
+    TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir)
+else TestCollisionXwithXYShift:= TestCollisionX(Gear, Dir);
 Gear^.X:= Gear^.X - ShiftX;
 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
 end;
@@ -337,11 +339,12 @@
 TestCollisionY:= false
 end;
 
-function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
+function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
 begin
 Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
-TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir);
+if withGear then TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir)
+else TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir);
 Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
 end;