# HG changeset patch # User sheepluva # Date 1417742370 -3600 # Node ID 2562797ab3cf98785151d2e4d26d820238503adf # Parent 125e120165aaae49d2e934ac7db56df00fde3ada adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier) diff -r 125e120165aa -r 2562797ab3cf hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Thu Dec 04 20:15:03 2014 +0100 +++ b/hedgewars/uConsts.pas Fri Dec 05 02:19:30 2014 +0100 @@ -319,6 +319,7 @@ kSystemSoundID_Vibrate = $00000FFF; cMinPlayWidth = 200; + cWorldEdgeDist = 150; implementation diff -r 125e120165aa -r 2562797ab3cf hedgewars/uLand.pas --- a/hedgewars/uLand.pas Thu Dec 04 20:15:03 2014 +0100 +++ b/hedgewars/uLand.pas Fri Dec 05 02:19:30 2014 +0100 @@ -665,6 +665,9 @@ end; PrettifyLandAlpha(); + +InitWorldEdges(); + end; procedure GenPreview(out Preview: TPreview); diff -r 125e120165aa -r 2562797ab3cf hedgewars/uLandUtils.pas --- a/hedgewars/uLandUtils.pas Thu Dec 04 20:15:03 2014 +0100 +++ b/hedgewars/uLandUtils.pas Fri Dec 05 02:19:30 2014 +0100 @@ -2,9 +2,10 @@ interface procedure ResizeLand(width, height: LongWord); +procedure InitWorldEdges(); implementation -uses uUtils, uConsts, uVariables; +uses uUtils, uConsts, uVariables, uTypes; procedure ResizeLand(width, height: LongWord); var potW, potH: LongInt; @@ -31,4 +32,56 @@ end; end; +procedure InitWorldEdges(); +var cy, cx, lx, ly: LongInt; + found: boolean; +begin +playHeight:= LAND_HEIGHT; +topY:= 0; + +lx:= LongInt(LAND_WIDTH) - 1; + +if WorldEdge = weNone then + begin + playWidth:= LAND_WIDTH; + leftX := 0; + rightX:= lx; + EXIT; + end; + +ly:= LongInt(LAND_HEIGHT) - 1; + +// find most left land pixels and set leftX accordingly +found:= false; +for cx:= 0 to lx do + begin + for cy:= ly downto 0 do + if Land[cy, cx] <> 0 then + begin + leftX:= max(0, cx - cWorldEdgeDist); + // break out of both loops + found:= true; + break; + end; + if found then break; + end; + +// find most right land pixels and set rightX accordingly +found:= false; +for cx:= lx downto 0 do + begin + for cy:= ly downto 0 do + if Land[cy, cx] <> 0 then + begin + rightX:= min(lx, cx + cWorldEdgeDist); + // break out of both loops + found:= true; + break; + end; + if found then break; + end; + +playWidth := rightX + 1 - leftX; +end; + end. diff -r 125e120165aa -r 2562797ab3cf hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Dec 04 20:15:03 2014 +0100 +++ b/hedgewars/uStore.pas Fri Dec 05 02:19:30 2014 +0100 @@ -97,7 +97,6 @@ procedure InitZoom(zoom: real); begin SetScale(zoom); - UpdateViewLimits(); end; function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: PChar): TSDL_Rect;