Try to use TestCollExcludingMe a bit less - the flag bit is a bit (heh) more accurate.
authornemo
Sat, 23 Jun 2012 23:04:06 -0400
changeset 7274 a07777b818f1
parent 7272 71df899c4163
child 7276 e570bc0df33c
Try to use TestCollExcludingMe a bit less - the flag bit is a bit (heh) more accurate.
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
--- a/hedgewars/uAIAmmoTests.pas	Sat Jun 23 22:39:00 2012 -0400
+++ b/hedgewars/uAIAmmoTests.pas	Sat Jun 23 23:04:06 2012 -0400
@@ -161,7 +161,8 @@
             dX:= dX + windSpeed;
             dY:= dY + cGravityf;
             dec(t)
-        until TestCollExcludingMe(Me, trunc(x), trunc(y), 5) or (t <= 0);
+        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
+               ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0);
         
         EX:= trunc(x);
         EY:= trunc(y);
@@ -219,7 +220,8 @@
             dX:= dX + windSpeed;
             dY:= dY + cGravityf;
             dec(t)
-        until TestCollExcludingMe(Me, trunc(x), trunc(y), 5) or (t <= 0);
+        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
+               ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0);
         EX:= trunc(x);
         EY:= trunc(y);
 
@@ -269,7 +271,8 @@
             y:= y + dY;
             dY:= dY + cGravityf;
             dec(t)
-        until TestCollExcludingMe(Me, trunc(x), trunc(y), 7) or (t = 0);
+        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or 
+               ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 6))) or (t = 0);
         EX:= trunc(x);
         EY:= trunc(y);
         if t < 50 then
@@ -321,7 +324,8 @@
             y:= y + dY;
             dY:= dY + cGravityf;
             dec(t)
-        until TestCollExcludingMe(Me, trunc(x), trunc(y), 5) or (t = 0);
+        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
+               ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0);
     EX:= trunc(x);
     EY:= trunc(y);
     if t < 50 then 
@@ -380,7 +384,8 @@
         y:= y + dY;
         dY:= dY + cGravityf;
         dec(t)
-    until TestCollExcludingMe(Me, trunc(x), trunc(y), 5) or (t = 0);
+    until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
+           ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0);
     EX:= trunc(x);
     EY:= trunc(y);
     if t < 50 then 
@@ -432,7 +437,8 @@
             y:= y + dY;
             dY:= dY + cGravityf;
             dec(t)
-        until TestCollExcludingMe(Me, trunc(x), trunc(y), 7) or (t = 0);
+       until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or 
+               ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 6))) or (t = 0);
         
         EX:= trunc(x);
         EY:= trunc(y);
@@ -511,7 +517,8 @@
         dY:= dY + cGravityf;
         EX:= trunc(x);
         EY:= trunc(y);
-    until TestCollExcludingMe(Me, EX, EY, 5) or (EY > cWaterLine);
+    until (((Me = CurrentHedgehog^.Gear) and TestColl(EX, EY, 4)) or 
+           ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, EX, EY, 4))) or (EY > cWaterLine);
 
     if (EY < cWaterLine) and (dY >= 0) then
         begin
@@ -564,7 +571,8 @@
     y:= y + vY;
     rx:= trunc(x);
     ry:= trunc(y);
-    if TestCollExcludingMe(Me, rx, ry, 2) then
+    if ((Me = CurrentHedgehog^.Gear) and TestColl(rx, ry, 2)) or 
+        ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, rx, ry, 2)) then
     begin
         x:= x + vX * 8;
         y:= y + vY * 8;
--- a/hedgewars/uAIMisc.pas	Sat Jun 23 22:39:00 2012 -0400
+++ b/hedgewars/uAIMisc.pas	Sat Jun 23 23:04:06 2012 -0400
@@ -262,19 +262,19 @@
 function TestColl(x, y, r: LongInt): boolean; inline;
 var b: boolean;
 begin
-    b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] <> 0);
+    b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] and $FF7F <> 0);
     if b then
         exit(true);
     
-    b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] <> 0);
+    b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] and $FF7F <> 0);
     if b then
         exit(true);
     
-    b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] <> 0);
+    b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] and $FF7F <> 0);
     if b then
         exit(true);
     
-    b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] <> 0);
+    b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] and $FF7F <> 0);
     if b then
         exit(true);