--- a/hedgewars/uAIMisc.pas Wed Nov 11 19:48:16 2009 +0000
+++ b/hedgewars/uAIMisc.pas Wed Nov 11 21:54:28 2009 +0000
@@ -41,6 +41,7 @@
procedure FillBonuses(isAfterAttack: boolean);
procedure AwareOfExplosion(x, y, r: LongInt);
function RatePlace(Gear: PGear): LongInt;
+function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean;
function TestColl(x, y, r: LongInt): boolean;
function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
@@ -174,6 +175,22 @@
RatePlace:= Result
end;
+// Wrapper to test various approaches. If it works reasonably, will just replace.
+// Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with...
+function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean;
+var MeX, MeY: LongInt;
+begin
+ if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then
+ begin
+ MeX:= hwRound(Me^.X);
+ MeY:= hwRound(Me^.Y);
+ // We are still inside the hog. Skip radius test
+ if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and
+ ((Land[y, x] and $FF00) = 0) then exit(false);
+ end;
+ exit(TestColl(x, y, r))
+end;
+
function TestColl(x, y, r: LongInt): boolean;
var b: boolean;
begin