diff -r 9dd3a44805a1 -r f04fdb35fc33 hedgewars/uLandGenTemplateBased.pas --- a/hedgewars/uLandGenTemplateBased.pas Thu Mar 20 00:59:15 2014 +0400 +++ b/hedgewars/uLandGenTemplateBased.pas Thu Mar 20 17:04:49 2014 +0400 @@ -95,7 +95,7 @@ end; procedure FindPoint(si, fillPointsCount: LongInt; var newPoint: TPoint; var pa: TPixAr); -const mapBorderMargin = 30; +const mapBorderMargin = 40; minDistance = 32; // adjust/parametrize this for different details size var p1, p2, p4, fp, mp: TPoint; i, t1, t2, a, b, p, q, iy, ix, aqpb: LongInt; @@ -126,9 +126,9 @@ // don't process too short segments or those which are too close to map borders if (p1.x = NTPX) or (dab < minDistance * 3) - or (mp.x < mapBorderMargin) - or (mp.x > LAND_WIDTH - mapBorderMargin) - or (mp.y < mapBorderMargin) + or (mp.x < leftX + mapBorderMargin) + or (mp.x > rightX - mapBorderMargin) + or (mp.y < topY + mapBorderMargin) or (mp.y > LAND_HEIGHT - mapBorderMargin) then begin @@ -140,22 +140,22 @@ if a <> 0 then begin // left border - iy:= (mapBorderMargin - mp.x) * b div a + mp.y; - d:= DistanceI(mp.x - mapBorderMargin, mp.y - iy).Round; + iy:= (leftX + mapBorderMargin - mp.x) * b div a + mp.y; + d:= DistanceI(mp.x - leftX - mapBorderMargin, mp.y - iy).Round; t1:= a * (mp.x - mapBorderMargin) + b * (mp.y - iy); if t1 > 0 then distL:= d else distR:= d; // right border - iy:= (LAND_WIDTH - mapBorderMargin - mp.x) * b div a + mp.y; - d:= DistanceI(mp.x - LAND_WIDTH + mapBorderMargin, mp.y - iy).Round; + iy:= (rightX - mapBorderMargin - mp.x) * b div a + mp.y; + d:= DistanceI(mp.x - rightX + mapBorderMargin, mp.y - iy).Round; if t1 > 0 then distR:= d else distL:= d; end; if b <> 0 then begin // top border - ix:= (mapBorderMargin - mp.y) * a div b + mp.x; - d:= DistanceI(mp.y - mapBorderMargin, mp.x - ix).Round; + ix:= (topY + mapBorderMargin - mp.y) * a div b + mp.x; + d:= DistanceI(mp.y - topY - mapBorderMargin, mp.x - ix).Round; t2:= b * (mp.y - mapBorderMargin) + a * (mp.x - ix); if t2 > 0 then distL:= min(d, distL) else distR:= min(d, distR); @@ -331,6 +331,15 @@ for y:= 0 to LAND_HEIGHT - 1 do for x:= 0 to LAND_WIDTH - 1 do Land[y, x]:= lfBasic; + + MaxHedgehogs:= Template.MaxHedgehogs; + hasGirders:= Template.hasGirders; + playHeight:= Template.TemplateHeight; + playWidth:= Template.TemplateWidth; + leftX:= (LAND_WIDTH - playWidth) div 2; + rightX:= leftX + playWidth - 1; + topY:= LAND_HEIGHT - playHeight; + {$HINTS OFF} SetPoints(Template, pa, @fps); {$HINTS ON} @@ -346,14 +355,6 @@ DrawEdge(pa, lfBasic); - MaxHedgehogs:= Template.MaxHedgehogs; - hasGirders:= Template.hasGirders; - playHeight:= Template.TemplateHeight; - playWidth:= Template.TemplateWidth; - leftX:= ((LAND_WIDTH - playWidth) div 2); - rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; - topY:= LAND_HEIGHT - playHeight; - // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? if (cTemplateFilter = 4) or (Template.canInvert and (getrandom(2) = 0))