diff -r 352393fc75be -r 98024c99e58d hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Thu Nov 07 21:15:36 2013 +0400 +++ b/hedgewars/uLandObjects.pas Thu Nov 07 22:51:34 2013 +0400 @@ -197,8 +197,8 @@ procedure InitRects; begin -RectCount:= 0; -New(Rects) + RectCount:= 0; + New(Rects) end; procedure FreeRects; @@ -353,7 +353,7 @@ CheckCanPlace:= bRes; end; -function TryPut(var Obj: TThemeObject): boolean; overload; +function TryPut(var Obj: TThemeObject): boolean; const MaxPointsIndex = 2047; var x, y: Longword; ar: array[0..MaxPointsIndex] of TPoint; @@ -374,12 +374,12 @@ begin ar[cnt].x:= x; ar[cnt].y:= y; - inc(cnt); - if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + if cnt >= MaxPointsIndex then // buffer is full, do not check the rest land begin - y:= 5000; - x:= 5000; + y:= $FF000000; + x:= $FF000000; end + else inc(cnt); end; inc(y, 3); until y >= LAND_HEIGHT - Height; @@ -400,7 +400,7 @@ TryPut:= bRes; end; -function TryPut(var Obj: TSprayObject; Surface: PSDL_Surface): boolean; overload; +function TryPut2(var Obj: TSprayObject; Surface: PSDL_Surface): boolean; const MaxPointsIndex = 8095; var x, y: Longword; ar: array[0..MaxPointsIndex] of TPoint; @@ -408,7 +408,7 @@ r: TSDL_Rect; bRes: boolean; begin -TryPut:= false; +TryPut2:= false; cnt:= 0; with Obj do begin @@ -427,18 +427,19 @@ begin ar[cnt].x:= x; ar[cnt].y:= y; - inc(cnt); - if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + if cnt >= MaxPointsIndex then // buffer is full, do not check the rest land begin - y:= 5000; - x:= 5000; + y:= $FF000000; + x:= $FF000000; end + else inc(cnt); end; inc(y, 12); until y >= LAND_HEIGHT - Height - 8; inc(x, getrandom(12) + 12) until x >= LAND_WIDTH - Width; bRes:= cnt <> 0; +AddFileLog('CHECKPOINT 004'); if bRes then begin i:= getrandom(cnt); @@ -452,7 +453,7 @@ end else Maxcnt:= 0 end; -TryPut:= bRes; +TryPut2:= bRes; end; @@ -814,13 +815,13 @@ exit; WriteLnToConsole('Adding theme objects...'); - for i:=0 to ThemeObjects.Count do + for i:=0 to Pred(ThemeObjects.Count) do ThemeObjects.objs[i].Maxcnt := max(1, (ThemeObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map repeat t := getrandom(ThemeObjects.Count); b := false; - for i:=0 to ThemeObjects.Count do + for i:= 0 to Pred(ThemeObjects.Count) do begin ii := (i+t) mod ThemeObjects.Count; @@ -838,18 +839,18 @@ exit; WriteLnToConsole('Adding spray objects...'); - for i:=0 to SprayObjects.Count do + for i:= 0 to Pred(SprayObjects.Count) do SprayObjects.objs[i].Maxcnt := max(1, (SprayObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map repeat t := getrandom(SprayObjects.Count); b := false; - for i:=0 to SprayObjects.Count do + for i:= 0 to Pred(SprayObjects.Count) do begin ii := (i+t) mod SprayObjects.Count; if SprayObjects.objs[ii].Maxcnt <> 0 then - b := b or TryPut(SprayObjects.objs[ii], Surface) + b := b or TryPut2(SprayObjects.objs[ii], Surface) end; until not b; end; @@ -876,7 +877,6 @@ procedure AddOnLandObjects(Surface: PSDL_Surface); begin InitRects; -//AddSprayObjects(Surface, SprayObjects, 12); AddSprayObjects(Surface, SprayObjects); FreeRects end;