Make a few more gears honour world edge checks
authornemo
Sun, 29 Sep 2013 19:03:15 -0400
changeset 9477 0463f747e839
parent 9475 619920c6aea0
child 9479 167dea42d7d7
Make a few more gears honour world edge checks
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsHandlersMess.pas	Mon Sep 30 00:21:28 2013 +0400
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Sep 29 19:03:15 2013 -0400
@@ -1124,6 +1124,13 @@
     oX, oY: hwFloat;
     VGear: PVisualGear;
 begin
+    if WorldWrap(Gear) then
+        begin
+        SpawnBulletTrail(Gear);
+        inc(Gear^.PortalCounter);
+        Gear^.Elasticity:= Gear^.X;
+        Gear^.Friction:= Gear^.Y
+        end;
     AllInactive := false;
     inc(Gear^.Timer);
     i := 80;
@@ -2014,6 +2021,7 @@
     tdX,tdY: HWFloat;
     landPixel: Word;
 begin
+    WorldWrap(Gear);
     sticky:= (Gear^.State and gsttmpFlag) <> 0;
     if not sticky then AllInactive := false;
 
@@ -3188,11 +3196,27 @@
 var
     HHGear: PGear;
     i: LongInt;
-    dX, dY: hwFloat;
+    dX, dY, X, Y : hwFloat;
     fChanged: boolean;
     trueAngle: Longword;
     t: PGear;
 begin
+    if WorldWrap(Gear) then
+        begin
+        // recycling as temp vars
+        Y.isNegative:= false;
+        Y.QWordValue:= 4294967296 * 112;
+        X.isNegative:= false;
+        X.QWordValue:= 4294967296 * 35;
+        dX.isNegative:= false;
+        dX.QWordValue:= 4294967296 * 1152;
+
+        dY:=hwAbs(Gear^.dX*4);
+        dY:= dY + hwPow(dY,3)/_6 + _3 * hwPow(dY,5) / _40 + _5 * hwPow(dY,7) / Y + X * hwPow(dY,9) / dX;
+        Gear^.Angle:= hwRound(dY*_2048 / _PI);
+        if not Gear^.dY.isNegative then Gear^.Angle:= 2048-Gear^.Angle;
+        if Gear^.dX.isNegative then Gear^.Angle:= 4096-Gear^.Angle;
+        end;
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
@@ -4098,6 +4122,7 @@
     x, y, tx, ty: LongInt;
     s: hwFloat;
 begin
+    WorldWrap(Gear);
     x := hwRound(Gear^.X);
     y := hwRound(Gear^.Y);
     tx := 0;
--- a/hedgewars/uGearsHedgehog.pas	Mon Sep 30 00:21:28 2013 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Sun Sep 29 19:03:15 2013 -0400
@@ -828,7 +828,6 @@
 var isFalling, isUnderwater: boolean;
     land: Word;
 begin
-WorldWrap(Gear);
 land:= 0;
 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
 if Gear^.dX.QWordValue > 8160437862 then
@@ -1275,6 +1274,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepHedgehog(Gear: PGear);
 begin
+WorldWrap(Gear);
 CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel;
 if (Gear^.Message and gmDestroy) <> 0 then
     begin
--- a/hedgewars/uGearsUtils.pas	Mon Sep 30 00:21:28 2013 +0400
+++ b/hedgewars/uGearsUtils.pas	Sun Sep 29 19:03:15 2013 -0400
@@ -594,6 +594,11 @@
 ignoreNearObjects:= false; // try not skipping proximity at first
 ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates).  Saving it for a 3rd pass.  With this active, winning AI Survival goes back to virtual impossibility
 tryAgain:= true;
+if WorldEdge <> weNone then 
+    begin
+    Left:= max(Left,leftX+Gear^.Radius);
+    Right:= min(Right,rightX-Gear^.Radius)
+    end;
 while tryAgain do
     begin
     delta:= LAND_WIDTH div 16;