author | alfadur |
Mon, 12 Aug 2019 14:56:27 +0300 | |
changeset 15313 | 01bd0a087163 |
parent 15148 | 794dc7237ca1 |
permissions | -rw-r--r-- |
10198 | 1 |
unit uLandUtils; |
2 |
interface |
|
3 |
||
4 |
procedure ResizeLand(width, height: LongWord); |
|
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
5 |
procedure InitWorldEdges(); |
10198 | 6 |
|
7 |
implementation |
|
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
8 |
uses uUtils, uConsts, uVariables, uTypes; |
10198 | 9 |
|
10 |
procedure ResizeLand(width, height: LongWord); |
|
11 |
var potW, potH: LongInt; |
|
12 |
begin |
|
13 |
potW:= toPowerOf2(width); |
|
14 |
potH:= toPowerOf2(height); |
|
15 |
if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then |
|
16 |
begin |
|
17 |
LAND_WIDTH:= potW; |
|
18 |
LAND_HEIGHT:= potH; |
|
19 |
LAND_WIDTH_MASK:= not(LAND_WIDTH-1); |
|
20 |
LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); |
|
21 |
cWaterLine:= LAND_HEIGHT; |
|
22 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
23 |
SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |
|
24 |
else |
|
25 |
SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2); |
|
26 |
||
27 |
SetLength(Land, LAND_HEIGHT, LAND_WIDTH); |
|
28 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
|
29 |
// 0.5 is already approaching on unplayable |
|
10994 | 30 |
if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= cMaxZoomLevel/2; |
10198 | 31 |
cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
32 |
end; |
|
11709
1694b379c83f
fix clouds/flakes area not being adjusted after ResizeLand()
sheepluva
parents:
10994
diff
changeset
|
33 |
initScreenSpaceVars(); |
10198 | 34 |
end; |
35 |
||
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
36 |
procedure InitWorldEdges(); |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
37 |
var cy, cx, lx, ly: LongInt; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
38 |
found: boolean; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
39 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
40 |
playHeight:= LAND_HEIGHT; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
41 |
topY:= 0; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
42 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
43 |
lx:= LongInt(LAND_WIDTH) - 1; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
44 |
|
15148
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12316
diff
changeset
|
45 |
// don't change world edges for drawn maps |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12316
diff
changeset
|
46 |
if (cMapGen = mgDrawn) then |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12316
diff
changeset
|
47 |
// edges were adjusted already in GenDrawnMap() in uLand |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12316
diff
changeset
|
48 |
EXIT; |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12316
diff
changeset
|
49 |
|
12316
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
50 |
// use maximum available map width if there is no special world edge |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
51 |
if WorldEdge = weNone then |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
52 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
53 |
playWidth:= LAND_WIDTH; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
54 |
leftX := 0; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
55 |
rightX:= lx; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
56 |
EXIT; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
57 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
58 |
|
12316
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
59 |
// keep fort distance consistent if we're in wrap mode on fort map |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
60 |
if (cMapGen = mgForts) and (WorldEdge = weWrap) then |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
61 |
begin |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
62 |
// edges were adjusted already in MakeFortsMap() in uLand |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
63 |
EXIT; |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
64 |
end; |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11709
diff
changeset
|
65 |
|
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
66 |
ly:= LongInt(LAND_HEIGHT) - 1; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
67 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
68 |
// find most left land pixels and set leftX accordingly |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
69 |
found:= false; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
70 |
for cx:= 0 to lx do |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
71 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
72 |
for cy:= ly downto 0 do |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
73 |
if Land[cy, cx] <> 0 then |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
74 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
75 |
leftX:= max(0, cx - cWorldEdgeDist); |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
76 |
// break out of both loops |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
77 |
found:= true; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
78 |
break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
79 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
80 |
if found then break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
81 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
82 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
83 |
// find most right land pixels and set rightX accordingly |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
84 |
found:= false; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
85 |
for cx:= lx downto 0 do |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
86 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
87 |
for cy:= ly downto 0 do |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
88 |
if Land[cy, cx] <> 0 then |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
89 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
90 |
rightX:= min(lx, cx + cWorldEdgeDist); |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
91 |
// break out of both loops |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
92 |
found:= true; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
93 |
break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
94 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
95 |
if found then break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
96 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
97 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
98 |
playWidth := rightX + 1 - leftX; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
99 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
100 |
|
10198 | 101 |
end. |