Make FindPlace more flexible on large maps.
authornemo
Wed, 07 Nov 2012 15:37:02 -0500
changeset 8007 b07ce9dfc6bb
parent 8005 6d47a4f47e10
child 8009 22d3f053dd9b
Make FindPlace more flexible on large maps.
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsUtils.pas	Wed Nov 07 23:08:02 2012 +0400
+++ b/hedgewars/uGearsUtils.pas	Wed Nov 07 15:37:02 2012 -0500
@@ -555,8 +555,8 @@
 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean);
 var x: LongInt;
     y, sy: LongInt;
-    ar: array[0..511] of TPoint;
-    ar2: array[0..1023] of TPoint;
+    ar: array[0..1023] of TPoint;
+    ar2: array[0..2047] of TPoint;
     cnt, cnt2: Longword;
     delta: LongInt;
     ignoreNearObjects, ignoreOverlap, tryAgain: boolean;
@@ -566,10 +566,10 @@
 tryAgain:= true;
 while tryAgain do
     begin
-    delta:= 250;
+    delta:= LAND_WIDTH div 16;
     cnt2:= 0;
     repeat
-        x:= Left + LongInt(GetRandom(Delta));
+        x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta)));
         repeat
             inc(x, Delta);
             cnt:= 0;