author | Wuzzy <almikes@aol.com> |
Tue, 15 Nov 2016 02:30:35 +0100 | |
changeset 11891 | b27d2351ec16 |
parent 11886 | 34ede05e4d4f |
child 12091 | ba1807589eaa |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10040
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4 | 17 |
*) |
18 |
||
2599 | 19 |
{$INCLUDE "options.inc"} |
2587
0dfa56a8513c
fix a segfault in the iphone simulator by moving options.inc at the beginning of the file
koda
parents:
2376
diff
changeset
|
20 |
|
4 | 21 |
unit uLand; |
22 |
interface |
|
10249 | 23 |
uses SDLh, uLandTemplates, uConsts, uTypes, uAILandMarks; |
4 | 24 |
|
3038 | 25 |
procedure initModule; |
26 |
procedure freeModule; |
|
5717 | 27 |
procedure DrawBottomBorder; |
37 | 28 |
procedure GenMap; |
7079 | 29 |
procedure GenPreview(out Preview: TPreview); |
10162 | 30 |
procedure GenPreviewAlpha(out Preview: TPreviewAlpha); |
4 | 31 |
|
32 |
implementation |
|
11831
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11751
diff
changeset
|
33 |
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, |
6626
a447993f2ad7
Further work on propagating types. Now it hopefully works fully, just need to annotate namespace with types first.
unc0rr
parents:
6580
diff
changeset
|
34 |
uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures, |
10249 | 35 |
uLandGenMaze, uPhysFSLayer, uScript, uLandGenPerlin, |
11654
1fd1525653d8
SDL blit wraps at 16,384 - not the first time that routine has disappointed us.
nemo
parents:
11544
diff
changeset
|
36 |
uLandGenTemplateBased, uLandUtils, uRenderUtils; |
365 | 37 |
|
7028 | 38 |
var digest: shortstring; |
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
39 |
maskOnly: boolean; |
4 | 40 |
|
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
41 |
|
10016
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
42 |
procedure PrettifyLandAlpha(); |
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
43 |
begin |
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
44 |
if (cReducedQuality and rqBlurryLand) <> 0 then |
10018
bdf75f0350bd
(experimental) merging the new procedures for different pixel representations (1D/2D arrays) into a single procedure with the algorithm and two procedures for the different mapping. - because redundant code sucks (at least twice)
sheepluva
parents:
10016
diff
changeset
|
45 |
PrettifyAlpha2D(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2) |
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
46 |
else |
10018
bdf75f0350bd
(experimental) merging the new procedures for different pixel representations (1D/2D arrays) into a single procedure with the algorithm and two procedures for the different mapping. - because redundant code sucks (at least twice)
sheepluva
parents:
10016
diff
changeset
|
47 |
PrettifyAlpha2D(LandPixels, LAND_HEIGHT, LAND_WIDTH); |
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
48 |
end; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
49 |
|
9387 | 50 |
procedure DrawBorderFromImage(Surface: PSDL_Surface); |
4 | 51 |
var tmpsurf: PSDL_Surface; |
11655 | 52 |
//r, rr: TSDL_Rect; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
53 |
x, yd, yu: LongInt; |
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
54 |
targetMask: Word; |
4 | 55 |
begin |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7594
diff
changeset
|
56 |
tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent); |
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
57 |
|
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
58 |
// if mask only, all land gets filled with landtex and therefore needs borders |
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
59 |
if maskOnly then |
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
60 |
targetMask:= lfLandMask |
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
61 |
else |
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
62 |
targetMask:= lfBasic; |
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
63 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
64 |
for x:= 0 to LAND_WIDTH - 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
65 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
66 |
yd:= LAND_HEIGHT - 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
67 |
repeat |
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
68 |
while (yd > 0) and ((Land[yd, x] and targetMask) = 0) do dec(yd); |
2376 | 69 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
70 |
if (yd < 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
71 |
yd:= 0; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
72 |
|
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
73 |
while (yd < LAND_HEIGHT) and ((Land[yd, x] and targetMask) <> 0) do |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
74 |
inc(yd); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
75 |
dec(yd); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
76 |
yu:= yd; |
2376 | 77 |
|
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
78 |
while (yu > 0 ) and ((Land[yu, x] and targetMask) <> 0) do dec(yu); |
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
79 |
while (yu < yd ) and ((Land[yu, x] and targetMask) = 0) do inc(yu); |
2376 | 80 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
81 |
if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
11655 | 82 |
copyToXYFromRect(tmpsurf, Surface, x mod tmpsurf^.w, 16, 1, 16, x, yd - 15); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
83 |
if (yu > 0) then |
11655 | 84 |
copyToXYFromRect(tmpsurf, Surface, x mod tmpsurf^.w, 0, 1, Min(16, yd - yu + 1), x, yu); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
85 |
yd:= yu - 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
86 |
until yd < 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
87 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
88 |
SDL_FreeSurface(tmpsurf); |
4 | 89 |
end; |
90 |
||
9387 | 91 |
|
92 |
procedure DrawShoppaBorder; |
|
93 |
var x, y, s, i: Longword; |
|
94 |
c1, c2, c: Longword; |
|
95 |
begin |
|
96 |
c1:= AMask; |
|
97 |
c2:= AMask or RMask or GMask; |
|
98 |
||
99 |
// vertical |
|
100 |
s:= LAND_HEIGHT; |
|
10017 | 101 |
|
9387 | 102 |
for x:= 0 to LAND_WIDTH - 1 do |
103 |
for y:= 0 to LAND_HEIGHT - 1 do |
|
9864 | 104 |
if Land[y, x] = 0 then |
9387 | 105 |
if s < y then |
106 |
begin |
|
107 |
for i:= max(s, y - 8) to y - 1 do |
|
108 |
begin |
|
109 |
if ((x + i) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 110 |
|
9387 | 111 |
if (cReducedQuality and rqBlurryLand) = 0 then |
112 |
LandPixels[i, x]:= c |
|
113 |
else |
|
114 |
LandPixels[i div 2, x div 2]:= c |
|
115 |
end; |
|
116 |
s:= LAND_HEIGHT |
|
117 |
end |
|
118 |
else |
|
119 |
else |
|
120 |
begin |
|
121 |
if s > y then s:= y; |
|
122 |
if s + 8 > y then |
|
123 |
begin |
|
124 |
if ((x + y) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 125 |
|
9387 | 126 |
if (cReducedQuality and rqBlurryLand) = 0 then |
127 |
LandPixels[y, x]:= c |
|
128 |
else |
|
129 |
LandPixels[y div 2, x div 2]:= c |
|
10017 | 130 |
end; |
9387 | 131 |
end; |
10017 | 132 |
|
9387 | 133 |
// horizontal |
134 |
s:= LAND_WIDTH; |
|
10017 | 135 |
|
9387 | 136 |
for y:= 0 to LAND_HEIGHT - 1 do |
137 |
for x:= 0 to LAND_WIDTH - 1 do |
|
9864 | 138 |
if Land[y, x] = 0 then |
9387 | 139 |
if s < x then |
140 |
begin |
|
141 |
for i:= max(s, x - 8) to x - 1 do |
|
142 |
begin |
|
143 |
if ((y + i) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 144 |
|
9387 | 145 |
if (cReducedQuality and rqBlurryLand) = 0 then |
146 |
LandPixels[y, i]:= c |
|
147 |
else |
|
148 |
LandPixels[y div 2, i div 2]:= c |
|
149 |
end; |
|
150 |
s:= LAND_WIDTH |
|
151 |
end |
|
152 |
else |
|
153 |
else |
|
154 |
begin |
|
155 |
if s > x then s:= x; |
|
156 |
if s + 8 > x then |
|
157 |
begin |
|
158 |
if ((x + y) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 159 |
|
9387 | 160 |
if (cReducedQuality and rqBlurryLand) = 0 then |
161 |
LandPixels[y, x]:= c |
|
162 |
else |
|
163 |
LandPixels[y div 2, x div 2]:= c |
|
10017 | 164 |
end; |
9387 | 165 |
end |
166 |
end; |
|
167 |
||
168 |
procedure ColorizeLand(Surface: PSDL_Surface); |
|
169 |
var tmpsurf: PSDL_Surface; |
|
170 |
r: TSDL_Rect; |
|
10197 | 171 |
y: LongInt; // stupid SDL 1.2 uses stupid SmallInt for y which limits us to 32767. But is even worse if LandTex is large, can overflow on 32767 map. |
9387 | 172 |
begin |
173 |
tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps); |
|
174 |
r.y:= 0; |
|
9892
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
175 |
y:= 0; |
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
176 |
while y < LAND_HEIGHT do |
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
177 |
begin |
9387 | 178 |
r.x:= 0; |
179 |
while r.x < LAND_WIDTH do |
|
9892
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
180 |
begin |
11654
1fd1525653d8
SDL blit wraps at 16,384 - not the first time that routine has disappointed us.
nemo
parents:
11544
diff
changeset
|
181 |
copyToXY(tmpsurf, Surface, r.x, r.y); |
1fd1525653d8
SDL blit wraps at 16,384 - not the first time that routine has disappointed us.
nemo
parents:
11544
diff
changeset
|
182 |
//SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
9387 | 183 |
inc(r.x, tmpsurf^.w) |
9892
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
184 |
end; |
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
185 |
inc(y, tmpsurf^.h); |
5a0a7ef7af2d
allow SDL 1.2 to at least do a 32767 map. We probably should add a TryDo somewhere to assert that limit on SDL 1.2 to avoid overflows. Ditto int version for SDL 2
nemo
parents:
9864
diff
changeset
|
186 |
r.y:= y |
9387 | 187 |
end; |
188 |
SDL_FreeSurface(tmpsurf); |
|
189 |
||
190 |
// freed in freeModule() below |
|
191 |
LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); |
|
192 |
if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface); |
|
193 |
end; |
|
194 |
||
23 | 195 |
|
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
196 |
procedure GenDrawnMap; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
197 |
begin |
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
198 |
ResizeLand(4096, 2048); |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
199 |
uLandPainted.Draw; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
200 |
|
4559 | 201 |
MaxHedgehogs:= 48; |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
202 |
hasGirders:= true; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
203 |
playHeight:= 2048; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
204 |
playWidth:= 4096; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
205 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
206 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
207 |
topY:= LAND_HEIGHT - playHeight; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
208 |
end; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
209 |
|
371 | 210 |
function SelectTemplate: LongInt; |
9243
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
211 |
var l: LongInt; |
161 | 212 |
begin |
3612
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
213 |
if (cReducedQuality and rqLowRes) <> 0 then |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
214 |
SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))] |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
215 |
else |
9243
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
216 |
begin |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
217 |
if cTemplateFilter = 0 then |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
218 |
begin |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
219 |
l:= getRandom(GroupedTemplatesCount); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
220 |
repeat |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
221 |
inc(cTemplateFilter); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
222 |
dec(l, TemplateCounts[cTemplateFilter]); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
223 |
until l < 0; |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
224 |
end else getRandom(1); |
10017 | 225 |
|
3612
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
226 |
case cTemplateFilter of |
9243
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
227 |
0: OutError('Ask unC0Rr about what you did wrong', true); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
228 |
1: SelectTemplate:= SmallTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
229 |
2: SelectTemplate:= MediumTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
230 |
3: SelectTemplate:= LargeTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
231 |
4: SelectTemplate:= CavernTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
232 |
5: SelectTemplate:= WackyTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
7567 | 233 |
// For lua only! |
7575
f415b3e0f3b9
Burn a random number in the override. Make sure cirbuf is reset.
nemo
parents:
7571
diff
changeset
|
234 |
6: begin |
7594 | 235 |
SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates)); |
7575
f415b3e0f3b9
Burn a random number in the override. Make sure cirbuf is reset.
nemo
parents:
7571
diff
changeset
|
236 |
GetRandom(2) // burn 1 |
10142 | 237 |
end |
9243
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
238 |
end |
3612
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
239 |
end; |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
240 |
|
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
241 |
WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); |
161 | 242 |
end; |
243 |
||
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
244 |
procedure LandSurface2LandPixels(Surface: PSDL_Surface); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
245 |
var x, y: LongInt; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
246 |
p: PLongwordArray; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
247 |
begin |
11537 | 248 |
if checkFails(Surface <> nil, 'Assert (LandSurface <> nil) failed', true) then exit; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
249 |
|
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
250 |
if SDL_MustLock(Surface) then |
11512 | 251 |
if SDLCheck(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true) then exit; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
252 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
253 |
p:= Surface^.pixels; |
1760 | 254 |
for y:= 0 to LAND_HEIGHT - 1 do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
255 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
256 |
for x:= 0 to LAND_WIDTH - 1 do |
3598 | 257 |
if Land[y, x] <> 0 then |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3551
diff
changeset
|
258 |
if (cReducedQuality and rqBlurryLand) = 0 then |
11478
023db094b22d
Some themers expressed desire to have translucent themes. While the current AA stuff in uLandGraphics won't really allow this to work with LandBackTex properly, seems to me it should be safe to allow alpha for LandTex. Our LandTex should all have alpha of 255 on the existing themes.
nemo
parents:
11342
diff
changeset
|
259 |
LandPixels[y, x]:= p^[x]// or AMask |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3551
diff
changeset
|
260 |
else |
11478
023db094b22d
Some themers expressed desire to have translucent themes. While the current AA stuff in uLandGraphics won't really allow this to work with LandBackTex properly, seems to me it should be safe to allow alpha for LandTex. Our LandTex should all have alpha of 255 on the existing themes.
nemo
parents:
11342
diff
changeset
|
261 |
LandPixels[y div 2, x div 2]:= p^[x];// or AMask; |
2376 | 262 |
|
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10108
diff
changeset
|
263 |
p:= PLongwordArray(@(p^[Surface^.pitch div 4])); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
264 |
end; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
265 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
266 |
if SDL_MustLock(Surface) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
267 |
SDL_UnlockSurface(Surface); |
1754 | 268 |
end; |
269 |
||
3133 | 270 |
|
1754 | 271 |
procedure GenLandSurface; |
272 |
var tmpsurf: PSDL_Surface; |
|
5225 | 273 |
x,y: Longword; |
1754 | 274 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
275 |
AddProgress(); |
1754 | 276 |
|
11478
023db094b22d
Some themers expressed desire to have translucent themes. While the current AA stuff in uLandGraphics won't really allow this to work with LandBackTex properly, seems to me it should be safe to allow alpha for LandTex. Our LandTex should all have alpha of 255 on the existing themes.
nemo
parents:
11342
diff
changeset
|
277 |
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, AMask); |
1754 | 278 |
|
11537 | 279 |
if checkFails(tmpsurf <> nil, 'Error creating pre-land surface', true) then exit; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
280 |
ColorizeLand(tmpsurf); |
9387 | 281 |
if gameFlags and gfShoppaBorder = 0 then DrawBorderFromImage(tmpsurf); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
282 |
AddOnLandObjects(tmpsurf); |
1754 | 283 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
284 |
LandSurface2LandPixels(tmpsurf); |
5227 | 285 |
SDL_FreeSurface(tmpsurf); |
10017 | 286 |
|
9387 | 287 |
if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder; |
10017 | 288 |
|
5274 | 289 |
for x:= leftX+2 to rightX-2 do |
290 |
for y:= topY+2 to LAND_HEIGHT-3 do |
|
10017 | 291 |
if (Land[y, x] = 0) and |
5274 | 292 |
(((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
293 |
((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |
|
294 |
begin |
|
295 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
296 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
297 |
if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
298 |
LandPixels[y, x]:= LandPixels[y, x-1] |
10017 | 299 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
300 |
else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
301 |
LandPixels[y, x]:= LandPixels[y, x+1] |
10017 | 302 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
303 |
else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
304 |
LandPixels[y, x]:= LandPixels[y-1, x] |
10017 | 305 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
306 |
else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
307 |
LandPixels[y, x]:= LandPixels[y+1, x]; |
10017 | 308 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
309 |
if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
310 |
LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
5274 | 311 |
end; |
312 |
Land[y,x]:= lfObject |
|
313 |
end |
|
314 |
else if (Land[y, x] = 0) and |
|
315 |
(((Land[y, x-1] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
|
316 |
((Land[y, x-1] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
|
317 |
((Land[y, x+1] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
|
318 |
((Land[y, x+1] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
|
319 |
((Land[y+1, x] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
|
320 |
((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
|
321 |
((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or |
|
322 |
((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then |
|
10017 | 323 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
324 |
begin |
10017 | 325 |
|
5274 | 326 |
if (cReducedQuality and rqBlurryLand) = 0 then |
10017 | 327 |
|
5274 | 328 |
begin |
10017 | 329 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
330 |
if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
331 |
LandPixels[y, x]:= LandPixels[y, x-1] |
10017 | 332 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
333 |
else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
334 |
LandPixels[y, x]:= LandPixels[y, x+1] |
10017 | 335 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
336 |
else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
337 |
LandPixels[y, x]:= LandPixels[y+1, x] |
10017 | 338 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
339 |
else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
340 |
LandPixels[y, x]:= LandPixels[y-1, x]; |
10017 | 341 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
342 |
if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
343 |
LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
5274 | 344 |
end; |
345 |
Land[y,x]:= lfObject |
|
346 |
end; |
|
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
347 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
348 |
AddProgress(); |
1754 | 349 |
end; |
350 |
||
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
351 |
procedure MakeFortsPreview; |
11750 | 352 |
var gap: LongInt; |
353 |
h1, h2, w1, w2, x, y, lastX, wbm, bmref: LongWord; |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
354 |
const fortHeight = 960; |
11750 | 355 |
fortWidth = 704; |
356 |
bmHeight = 53; |
|
357 |
bmWidth = 64; |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
358 |
begin |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
359 |
ResizeLand(4096,2048); |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
360 |
|
11750 | 361 |
lastX:= LAND_WIDTH-1; |
362 |
||
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
363 |
gap:= (1024 - fortWidth) + 60 + 20 * cFeatureSize; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
364 |
|
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
365 |
h2:= LAND_HEIGHT-1; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
366 |
h1:= h2 - fortHeight; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
367 |
w2:= (LAND_WIDTH - gap) div 2; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
368 |
w1:= w2 - fortWidth; |
11750 | 369 |
wbm:= h1 + bmHeight; |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
370 |
|
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
371 |
// generate 2 forts in center |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
372 |
for y:= h1 to h2 do |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
373 |
for x:= w1 to w2 do |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
374 |
begin |
11751 | 375 |
if x mod 4 <> 0 then |
376 |
begin |
|
377 |
if (y <= wbm) and ((x - w1) mod (bmWidth * 2) >= bmWidth) then |
|
378 |
continue; |
|
379 |
Land[y,x]:= lfBasic; |
|
380 |
Land[y,lastX-x]:= lfBasic; |
|
381 |
end; |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
382 |
end; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
383 |
|
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
384 |
w2:= w1 - gap; |
11750 | 385 |
w1:= max(0, w2 - fortWidth); |
386 |
wbm:= h1 + bmHeight; |
|
387 |
bmref:= w2 + bmWidth; |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
388 |
|
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
389 |
for y:= h1 to h2 do |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
390 |
for x:= w1 to w2 do |
11750 | 391 |
begin |
11751 | 392 |
if ((y - x) mod 2) = 0 then |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
393 |
begin |
11750 | 394 |
// align battlement on inner edge, because real outer edge could be offscreen |
395 |
if (y <= wbm) and ((LAND_WIDTH + x - bmref) mod (bmWidth * 2) >= bmWidth) then |
|
396 |
continue; |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
397 |
Land[y,x]:= lfBasic; |
11750 | 398 |
Land[y,lastX-x]:= lfBasic; |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
399 |
end; |
11750 | 400 |
end; |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
401 |
end; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
402 |
|
1754 | 403 |
procedure MakeFortsMap; |
404 |
var tmpsurf: PSDL_Surface; |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
405 |
sectionWidth, i, t, p: integer; |
11710 | 406 |
mirror: boolean; |
11739 | 407 |
pc: PClan; |
1754 | 408 |
begin |
11739 | 409 |
|
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
410 |
// make the gaps between forts adjustable if fort map was selected |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
411 |
if cMapGen = mgForts then |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
412 |
sectionWidth:= 1024 + 60 + 20 * cFeatureSize |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
413 |
else |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
414 |
sectionWidth:= 1024 * 300; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
415 |
|
11739 | 416 |
// mix up spawn/fort order of clans |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
417 |
for i:= 0 to ClansCount - 1 do |
11739 | 418 |
begin |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
419 |
t:= GetRandom(ClansCount); |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
420 |
p:= GetRandom(ClansCount); |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
421 |
if t <> p then |
11739 | 422 |
begin |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
423 |
pc:= SpawnClansArray[t]; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
424 |
SpawnClansArray[t]:= SpawnClansArray[p]; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
425 |
SpawnClansArray[p]:= pc; |
11739 | 426 |
end; |
427 |
end; |
|
428 |
||
11710 | 429 |
// figure out how much space we need |
430 |
playWidth:= sectionWidth * ClansCount; |
|
431 |
||
432 |
// note: LAND_WIDTH might be bigger than specified below (rounded to next power of 2) |
|
433 |
ResizeLand(playWidth, 2048); |
|
434 |
||
2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2163
diff
changeset
|
435 |
// For now, defining a fort is playable area as 3072x1200 - there are no tall forts. The extra height is to avoid triggering border with current code, also if user turns on a border, it will give a bit more maneuvering room. |
1784 | 436 |
playHeight:= 1200; |
11710 | 437 |
|
438 |
// center playable area in land array |
|
439 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
|
1776 | 440 |
rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1); |
441 |
topY:= LAND_HEIGHT - playHeight; |
|
442 |
||
1754 | 443 |
WriteLnToConsole('Generating forts land...'); |
444 |
||
11710 | 445 |
for i := 0 to ClansCount - 1 do |
446 |
begin |
|
447 |
||
448 |
// face in random direction |
|
449 |
mirror:= (GetRandom(2) = 0); |
|
450 |
// make first/last fort face inwards |
|
11712
ecbf5e6c2c37
also make forts face inwards in wrap mode, if there are only 2 teams
sheepluva
parents:
11711
diff
changeset
|
451 |
if (WorldEdge <> weWrap) or (ClansCount = 2) then |
11711 | 452 |
mirror:= (i <> 0) and (mirror or (i = ClansCount - 1)); |
1754 | 453 |
|
11710 | 454 |
if mirror then |
455 |
begin |
|
456 |
// not critical because if no R we can fallback to mirrored L |
|
11739 | 457 |
tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps); |
11710 | 458 |
// fallback |
459 |
if tmpsurf = nil then |
|
460 |
begin |
|
11739 | 461 |
tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
11710 | 462 |
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true); |
463 |
end |
|
464 |
else |
|
465 |
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
|
466 |
SDL_FreeSurface(tmpsurf); |
|
467 |
end |
|
468 |
else |
|
469 |
begin |
|
11739 | 470 |
tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
11710 | 471 |
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
472 |
SDL_FreeSurface(tmpsurf); |
|
473 |
end; |
|
474 |
||
475 |
end; |
|
1754 | 476 |
end; |
477 |
||
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
478 |
procedure LoadMapConfig; |
8060 | 479 |
var f: PFSFile; |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
480 |
s: shortstring; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
481 |
begin |
8025 | 482 |
s:= cPathz[ptMapCurrent] + '/map.cfg'; |
483 |
||
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
484 |
WriteLnToConsole('Fetching map HH limit'); |
8060 | 485 |
|
486 |
f:= pfsOpenRead(s); |
|
487 |
if f <> nil then |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
488 |
begin |
8060 | 489 |
pfsReadLn(f, s); |
490 |
if not pfsEof(f) then |
|
491 |
begin |
|
492 |
pfsReadLn(f, s); |
|
493 |
val(s, MaxHedgehogs) |
|
494 |
end; |
|
495 |
||
496 |
pfsClose(f) |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
497 |
end; |
8060 | 498 |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
499 |
if (MaxHedgehogs = 0) then |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
500 |
MaxHedgehogs:= 18; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
501 |
end; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
502 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5231
diff
changeset
|
503 |
// Loads Land[] from an image, allowing overriding standard collision |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
504 |
procedure LoadMask; |
1792 | 505 |
var tmpsurf: PSDL_Surface; |
506 |
p: PLongwordArray; |
|
507 |
x, y, cpX, cpY: Longword; |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
508 |
mapName: shortstring; |
1792 | 509 |
begin |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7594
diff
changeset
|
510 |
tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
5770 | 511 |
if tmpsurf = nil then |
512 |
begin |
|
8025 | 513 |
mapName:= ExtractFileName(cPathz[ptMapCurrent]); |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7594
diff
changeset
|
514 |
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
5770 | 515 |
end; |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
516 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
517 |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
518 |
if (tmpsurf <> nil) and (tmpsurf^.format^.BytesPerPixel = 4) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
519 |
begin |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
520 |
if LAND_WIDTH = 0 then |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
521 |
begin |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
522 |
LoadMapConfig; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
523 |
ResizeLand(tmpsurf^.w, tmpsurf^.h); |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
524 |
playHeight:= tmpsurf^.h; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
525 |
playWidth:= tmpsurf^.w; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
526 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
527 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
528 |
topY:= LAND_HEIGHT - playHeight; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
529 |
end; |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
530 |
disableLandBack:= true; |
2376 | 531 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
532 |
cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
533 |
cpY:= LAND_HEIGHT - tmpsurf^.h; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
534 |
if SDL_MustLock(tmpsurf) then |
11512 | 535 |
SDLCheck(SDL_LockSurface(tmpsurf) >= 0, 'SDL_LockSurface', true); |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
536 |
|
11512 | 537 |
if allOK then |
538 |
begin |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
539 |
p:= tmpsurf^.pixels; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
540 |
for y:= 0 to Pred(tmpsurf^.h) do |
8848
e9ebd63f8a03
So. Some themes have objects that seem to be large natural extensions of the landscape. Masks allow maintaining that. Lemme know if it doesn't look good. If it doesn't, can still use for ice/bounce/indestructible. Indestructible bunker object for example.
nemo
parents:
8370
diff
changeset
|
541 |
begin |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
542 |
for x:= 0 to Pred(tmpsurf^.w) do |
8848
e9ebd63f8a03
So. Some themes have objects that seem to be large natural extensions of the landscape. Masks allow maintaining that. Lemme know if it doesn't look good. If it doesn't, can still use for ice/bounce/indestructible. Indestructible bunker object for example.
nemo
parents:
8370
diff
changeset
|
543 |
SetLand(Land[cpY + y, cpX + x], p^[x]); |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10108
diff
changeset
|
544 |
p:= PLongwordArray(@(p^[tmpsurf^.pitch div 4])); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
545 |
end; |
2243
b4764993f833
additional touch support and nemo's reduced land array size
koda
parents:
2240
diff
changeset
|
546 |
|
11512 | 547 |
if SDL_MustLock(tmpsurf) then |
548 |
SDL_UnlockSurface(tmpsurf); |
|
549 |
if not disableLandBack then |
|
550 |
begin |
|
551 |
// freed in freeModule() below |
|
552 |
LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); |
|
553 |
if (LandBackSurface <> nil) and GrayScale then |
|
554 |
Surface2GrayScale(LandBackSurface) |
|
555 |
end; |
|
556 |
end; |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
557 |
end; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
558 |
if (tmpsurf <> nil) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
559 |
SDL_FreeSurface(tmpsurf); |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
560 |
tmpsurf:= nil; |
1792 | 561 |
end; |
562 |
||
1754 | 563 |
procedure LoadMap; |
564 |
var tmpsurf: PSDL_Surface; |
|
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
565 |
mapName: shortstring = ''; |
1754 | 566 |
begin |
567 |
WriteLnToConsole('Loading land from file...'); |
|
568 |
AddProgress; |
|
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7594
diff
changeset
|
569 |
tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifTransparent or ifIgnoreCaps); |
3912
e11df2de6af2
have engine try for a second position when map loading fails (in this way it's possible to move Missions data to any path)
koda
parents:
3836
diff
changeset
|
570 |
if tmpsurf = nil then |
5770 | 571 |
begin |
8025 | 572 |
mapName:= ExtractFileName(cPathz[ptMapCurrent]); |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7594
diff
changeset
|
573 |
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
11537 | 574 |
if not allOK then exit; |
5770 | 575 |
end; |
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
576 |
// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take |
11537 | 577 |
if checkFails((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true) |
578 |
then exit; |
|
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
579 |
|
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
580 |
ResizeLand(tmpsurf^.w, tmpsurf^.h); |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
581 |
LoadMapConfig; |
1792 | 582 |
|
1776 | 583 |
playHeight:= tmpsurf^.h; |
584 |
playWidth:= tmpsurf^.w; |
|
585 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
|
586 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
587 |
topY:= LAND_HEIGHT - playHeight; |
|
588 |
||
11537 | 589 |
if not checkFails(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true) then |
590 |
BlitImageAndGenerateCollisionInfo( |
|
591 |
(LAND_WIDTH - tmpsurf^.w) div 2, |
|
592 |
LAND_HEIGHT - tmpsurf^.h, |
|
593 |
tmpsurf^.w, |
|
594 |
tmpsurf); |
|
1754 | 595 |
|
596 |
SDL_FreeSurface(tmpsurf); |
|
1792 | 597 |
|
11537 | 598 |
if allOK then LoadMask; |
1754 | 599 |
end; |
600 |
||
5717 | 601 |
procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD |
5832
f730c8a9777b
Remove some unused variables and options.inc which uFloat doesn't use, probably should never use, and was getting in the way of my testcase - but most importantly, remove the inline on hwSqrt which was causing very bad math on my compiler/machine. We may have to remove more inlining. A pity.
nemo
parents:
5775
diff
changeset
|
602 |
var x, w, c: Longword; |
5717 | 603 |
begin |
5718
e74de0528ef4
Let's draw the bottom border thicker, so it is more visible
nemo
parents:
5717
diff
changeset
|
604 |
for w:= 0 to 23 do |
5717 | 605 |
for x:= leftX to rightX do |
606 |
begin |
|
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
5832
diff
changeset
|
607 |
Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible; |
5717 | 608 |
if (x + w) mod 32 < 16 then |
609 |
c:= AMask |
|
610 |
else |
|
611 |
c:= AMask or RMask or GMask; // FF00FFFF |
|
612 |
||
613 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
5832
diff
changeset
|
614 |
LandPixels[Longword(cWaterLine) - 1 - w, x]:= c |
5717 | 615 |
else |
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
5832
diff
changeset
|
616 |
LandPixels[(Longword(cWaterLine) - 1 - w) div 2, x div 2]:= c |
5718
e74de0528ef4
Let's draw the bottom border thicker, so it is more visible
nemo
parents:
5717
diff
changeset
|
617 |
end |
5717 | 618 |
end; |
619 |
||
1754 | 620 |
procedure GenMap; |
1784 | 621 |
var x, y, w, c: Longword; |
8025 | 622 |
map, mask: shortstring; |
1754 | 623 |
begin |
3463 | 624 |
hasBorder:= false; |
8011 | 625 |
maskOnly:= false; |
2891
e1f902eb0cfe
Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents:
2866
diff
changeset
|
626 |
|
3463 | 627 |
LoadThemeConfig; |
3697 | 628 |
|
4900 | 629 |
// is this not needed any more? lets hope setlength sets also 0s |
3630 | 630 |
//if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then |
631 |
// FillChar(Land,SizeOf(TCollisionArray),0);*) |
|
3697 | 632 |
|
11886
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
633 |
if cPathz[ptMapCurrent] <> '' then |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
634 |
begin |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
635 |
map:= cPathz[ptMapCurrent] + '/map.png'; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
636 |
mask:= cPathz[ptMapCurrent] + '/mask.png'; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
637 |
if (not(pfsExists(map)) and pfsExists(mask)) then |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
638 |
begin |
11886
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
639 |
maskOnly:= true; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
640 |
LoadMask; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
641 |
GenLandSurface |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
642 |
end |
11886
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
643 |
else LoadMap; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
644 |
end |
3463 | 645 |
else |
11886
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
646 |
begin |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
647 |
WriteLnToConsole('Generating land...'); |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
648 |
case cMapGen of |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
649 |
mgRandom: GenTemplated(EdgeTemplates[SelectTemplate]); |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
650 |
mgMaze : begin ResizeLand(4096,2048); GenMaze; end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
651 |
mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
652 |
mgDrawn : GenDrawnMap; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
653 |
mgForts : begin GameFlags:= (GameFlags or gfForts or gfDivideTeams); MakeFortsMap(); end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
654 |
else |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
655 |
OutError('Unknown mapgen', true); |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
656 |
end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
657 |
if cMapGen <> mgForts then |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
658 |
GenLandSurface |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
659 |
end; |
3463 | 660 |
|
661 |
AddProgress; |
|
1760 | 662 |
|
1768 | 663 |
// check for land near top |
1784 | 664 |
c:= 0; |
665 |
if (GameFlags and gfBorder) <> 0 then |
|
666 |
hasBorder:= true |
|
667 |
else |
|
668 |
for y:= topY to topY + 5 do |
|
669 |
for x:= leftX to rightX do |
|
670 |
if Land[y, x] <> 0 then |
|
671 |
begin |
|
672 |
inc(c); |
|
8370 | 673 |
if c > LongWord((LAND_WIDTH div 2)) then // avoid accidental triggering |
1784 | 674 |
begin |
675 |
hasBorder:= true; |
|
676 |
break; |
|
677 |
end; |
|
678 |
end; |
|
1768 | 679 |
|
1776 | 680 |
if hasBorder then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
681 |
begin |
10661 | 682 |
if WorldEdge = weNone then |
683 |
begin |
|
684 |
for y:= 0 to LAND_HEIGHT - 1 do |
|
685 |
for x:= 0 to LAND_WIDTH - 1 do |
|
686 |
if (y < topY) or (x < leftX) or (x > rightX) then |
|
687 |
Land[y, x]:= lfIndestructible; |
|
688 |
end |
|
689 |
else if topY > 0 then |
|
690 |
begin |
|
691 |
for y:= 0 to LongInt(topY) - 1 do |
|
692 |
for x:= 0 to LAND_WIDTH - 1 do |
|
3519 | 693 |
Land[y, x]:= lfIndestructible; |
10661 | 694 |
end; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
695 |
// experiment hardcoding cave |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
696 |
// also try basing cave dimensions on map/template dimensions, if they exist |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
697 |
for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
698 |
begin |
9524 | 699 |
if (WorldEdge <> weBounce) and (WorldEdge <> weWrap) then |
700 |
for y:= topY to LAND_HEIGHT - 1 do |
|
701 |
begin |
|
702 |
Land[y, leftX + w]:= lfIndestructible; |
|
703 |
Land[y, rightX - w]:= lfIndestructible; |
|
704 |
if (y + w) mod 32 < 16 then |
|
705 |
c:= AMask |
|
706 |
else |
|
707 |
c:= AMask or RMask or GMask; // FF00FFFF |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3551
diff
changeset
|
708 |
|
9524 | 709 |
if (cReducedQuality and rqBlurryLand) = 0 then |
710 |
begin |
|
711 |
LandPixels[y, leftX + w]:= c; |
|
712 |
LandPixels[y, rightX - w]:= c; |
|
713 |
end |
|
714 |
else |
|
715 |
begin |
|
716 |
LandPixels[y div 2, (leftX + w) div 2]:= c; |
|
717 |
LandPixels[y div 2, (rightX - w) div 2]:= c; |
|
718 |
end; |
|
5717 | 719 |
end; |
1768 | 720 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
721 |
for x:= leftX to rightX do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
722 |
begin |
5717 | 723 |
Land[topY + w, x]:= lfIndestructible; |
724 |
if (x + w) mod 32 < 16 then |
|
725 |
c:= AMask |
|
726 |
else |
|
727 |
c:= AMask or RMask or GMask; // FF00FFFF |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3551
diff
changeset
|
728 |
|
5717 | 729 |
if (cReducedQuality and rqBlurryLand) = 0 then |
730 |
LandPixels[topY + w, x]:= c |
|
731 |
else |
|
732 |
LandPixels[(topY + w) div 2, x div 2]:= c; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
733 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
734 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
735 |
end; |
1768 | 736 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
737 |
if (GameFlags and gfBottomBorder) <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
738 |
DrawBottomBorder; |
5717 | 739 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
740 |
if (GameFlags and gfDisableGirders) <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
741 |
hasGirders:= false; |
2891
e1f902eb0cfe
Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents:
2866
diff
changeset
|
742 |
|
8025 | 743 |
if (GameFlags and gfForts = 0) and (maskOnly or (cPathz[ptMapCurrent] = '')) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
744 |
AddObjects |
10017 | 745 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
746 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
747 |
AddProgress(); |
1776 | 748 |
|
3058 | 749 |
FreeLandObjects; |
750 |
||
11544 | 751 |
if not allOK then exit; |
752 |
||
6982 | 753 |
if GrayScale then |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
754 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
755 |
if (cReducedQuality and rqBlurryLand) = 0 then |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
756 |
for x:= leftX to rightX do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
757 |
for y:= topY to LAND_HEIGHT-1 do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
758 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
759 |
w:= LandPixels[y,x]; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
760 |
w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
761 |
(w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
762 |
(w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
763 |
if w > 255 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
764 |
w:= 255; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
765 |
w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y,x] and AMask); |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
766 |
LandPixels[y,x]:= w or (LandPixels[y, x] and AMask) |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
767 |
end |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
768 |
else |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
769 |
for x:= leftX div 2 to rightX div 2 do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
770 |
for y:= topY div 2 to LAND_HEIGHT-1 div 2 do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
771 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
772 |
w:= LandPixels[y div 2,x div 2]; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
773 |
w:= ((w shr RShift and $FF) + (w shr BShift and $FF) + (w shr GShift and $FF)) div 3; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
774 |
w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y div 2,x div 2] and AMask); |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
775 |
LandPixels[y,x]:= w or (LandPixels[y div 2, x div 2] and AMask) |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
776 |
end |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
777 |
end; |
10016
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
778 |
|
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
779 |
PrettifyLandAlpha(); |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10603
diff
changeset
|
780 |
|
10661 | 781 |
// adjust world edges for borderless maps |
782 |
if (WorldEdge <> weNone) and (not hasBorder) then |
|
783 |
InitWorldEdges(); |
|
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10603
diff
changeset
|
784 |
|
37 | 785 |
end; |
786 |
||
7079 | 787 |
procedure GenPreview(out Preview: TPreview); |
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
788 |
var rh, rw, ox, oy, x, y, xx, yy, t, bit, cbit, lh, lw: LongInt; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
789 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
790 |
WriteLnToConsole('Generating preview...'); |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
791 |
case cMapGen of |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
792 |
mgRandom: GenTemplated(EdgeTemplates[SelectTemplate]); |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
793 |
mgMaze: begin ResizeLand(4096,2048); GenMaze; end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
794 |
mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
795 |
mgDrawn: GenDrawnMap; |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
796 |
mgForts: MakeFortsPreview(); |
4562 | 797 |
else |
798 |
OutError('Unknown mapgen', true); |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
799 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
800 |
|
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
801 |
// strict scaling needed here since preview assumes a rectangle |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
802 |
rh:= max(LAND_HEIGHT,2048); |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
803 |
rw:= max(LAND_WIDTH,4096); |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
804 |
ox:= 0; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
805 |
if rw < rh*2 then |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
806 |
begin |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
807 |
rw:= rh*2; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
808 |
end; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
809 |
if rh < rw div 2 then rh:= rw * 2; |
10017 | 810 |
|
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
811 |
ox:= (rw-LAND_WIDTH) div 2; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
812 |
oy:= rh-LAND_HEIGHT; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
813 |
|
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
814 |
lh:= rh div 128; |
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
815 |
lw:= rw div 32; |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
816 |
for y:= 0 to 127 do |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
817 |
for x:= 0 to 31 do |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
818 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
819 |
Preview[y, x]:= 0; |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
820 |
for bit:= 0 to 7 do |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
821 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
822 |
t:= 0; |
3617 | 823 |
cbit:= bit * 8; |
824 |
for yy:= y * lh to y * lh + 7 do |
|
825 |
for xx:= x * lw + cbit to x * lw + cbit + 7 do |
|
10017 | 826 |
if ((yy-oy) and LAND_HEIGHT_MASK = 0) and ((xx-ox) and LAND_WIDTH_MASK = 0) |
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7293
diff
changeset
|
827 |
and (Land[yy-oy, xx-ox] <> 0) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
828 |
inc(t); |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
829 |
if t > 8 then |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
830 |
Preview[y, x]:= Preview[y, x] or ($80 shr bit); |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
831 |
end; |
566 | 832 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
833 |
end; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
834 |
|
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
835 |
|
10162 | 836 |
procedure GenPreviewAlpha(out Preview: TPreviewAlpha); |
837 |
var rh, rw, ox, oy, x, y, xx, yy, t, lh, lw: LongInt; |
|
838 |
begin |
|
839 |
WriteLnToConsole('Generating preview...'); |
|
840 |
case cMapGen of |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
841 |
mgRandom: GenTemplated(EdgeTemplates[SelectTemplate]); |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
842 |
mgMaze: begin ResizeLand(4096,2048); GenMaze; end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
843 |
mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10490
diff
changeset
|
844 |
mgDrawn: GenDrawnMap; |
11749
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
11739
diff
changeset
|
845 |
mgForts: MakeFortsPreview; |
10162 | 846 |
else |
847 |
OutError('Unknown mapgen', true); |
|
848 |
end; |
|
849 |
||
850 |
// strict scaling needed here since preview assumes a rectangle |
|
851 |
rh:= max(LAND_HEIGHT, 2048); |
|
852 |
rw:= max(LAND_WIDTH, 4096); |
|
853 |
ox:= 0; |
|
854 |
if rw < rh*2 then |
|
855 |
begin |
|
856 |
rw:= rh*2; |
|
857 |
end; |
|
858 |
if rh < rw div 2 then rh:= rw * 2; |
|
859 |
||
860 |
ox:= (rw-LAND_WIDTH) div 2; |
|
861 |
oy:= rh-LAND_HEIGHT; |
|
862 |
||
863 |
lh:= rh div 128; |
|
864 |
lw:= rw div 256; |
|
865 |
for y:= 0 to 127 do |
|
866 |
for x:= 0 to 255 do |
|
867 |
begin |
|
868 |
t:= 0; |
|
869 |
||
10165 | 870 |
for yy:= y * lh - oy to y * lh + lh - 1 - oy do |
871 |
for xx:= x * lw - ox to x * lw + lw - 1 - ox do |
|
10162 | 872 |
if (yy and LAND_HEIGHT_MASK = 0) and (xx and LAND_WIDTH_MASK = 0) |
873 |
and (Land[yy, xx] <> 0) then |
|
874 |
inc(t); |
|
875 |
||
10165 | 876 |
Preview[y, x]:= t * 255 div (lh * lw); |
10162 | 877 |
end; |
878 |
end; |
|
879 |
||
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
880 |
procedure chLandCheck(var s: shortstring); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
881 |
begin |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
882 |
AddFileLog('CheckLandDigest: ' + s + ' digest : ' + digest); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
883 |
if digest = '' then |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
884 |
digest:= s |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
885 |
else |
11537 | 886 |
checkFails(s = digest, 'Different maps generated, sorry', true); |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
887 |
end; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
888 |
|
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
889 |
procedure chSendLandDigest(var s: shortstring); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
890 |
var adler, i: LongInt; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
891 |
begin |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
892 |
adler:= 1; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
893 |
for i:= 0 to LAND_HEIGHT-1 do |
6927
ee000959d645
Oh, and I guess this is needed as well, although if many other places in the code do this, pas2c will need
nemo
parents:
6898
diff
changeset
|
894 |
adler:= Adler32Update(adler, @Land[i,0], LAND_WIDTH); |
6254
e90fb60cb46d
Force a desync if there is a script name mismatch. This avoids playing until the game desyncs due to script differences.
nemo
parents:
6096
diff
changeset
|
895 |
s:= 'M' + IntToStr(adler) + cScriptName; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
896 |
|
10022 | 897 |
ScriptSetString('LandDigest', s); |
898 |
||
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
899 |
chLandCheck(s); |
11537 | 900 |
if allOK then SendIPCRaw(@s[0], Length(s) + 1) |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
901 |
end; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
902 |
|
3038 | 903 |
procedure initModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
904 |
begin |
6898 | 905 |
RegisterVariable('landcheck', @chLandCheck, false); |
906 |
RegisterVariable('sendlanddigest', @chSendLandDigest, false); |
|
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
907 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
908 |
LandBackSurface:= nil; |
3369
c7289e42f0ee
add other controls for map preview, also fix a bug in digest
koda
parents:
3365
diff
changeset
|
909 |
digest:= ''; |
11019
67ef02300508
always draw border on terrain if there is only a map mask and no map image. this is a workaround for the fact that space campaign masks use white (lfObject) color instead of black (lfBasic)
sheepluva
parents:
11006
diff
changeset
|
910 |
maskOnly:= false; |
7549 | 911 |
LAND_WIDTH:= 0; |
912 |
LAND_HEIGHT:= 0; |
|
913 |
(* |
|
3612
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
914 |
if (cReducedQuality and rqBlurryLand) = 0 then |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
915 |
SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
916 |
else |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
917 |
SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2); |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
918 |
|
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
919 |
SetLength(Land, LAND_HEIGHT, LAND_WIDTH); |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
920 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
7549 | 921 |
*) |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
922 |
end; |
51 | 923 |
|
3038 | 924 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
925 |
begin |
7151 | 926 |
SetLength(Land, 0, 0); |
927 |
SetLength(LandPixels, 0, 0); |
|
928 |
SetLength(LandDirty, 0, 0); |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
929 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
930 |
|
4 | 931 |
end. |