author | Wuzzy <Wuzzy2@mail.ru> |
Sun, 15 Sep 2019 16:04:11 +0200 | |
changeset 15425 | 0e3bf53dfe47 |
parent 15200 | cd38295cac16 |
child 15929 | 128ace913837 |
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 |
|
11826
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11746
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, |
11649
1fd1525653d8
SDL blit wraps at 16,384 - not the first time that routine has disappointed us.
nemo
parents:
11539
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; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
52 |
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
|
53 |
targetMask: Word; |
4 | 54 |
begin |
12592 | 55 |
tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifColorKey); |
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
|
56 |
|
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 |
// 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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
63 |
for x:= 0 to LAND_WIDTH - 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
64 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
65 |
yd:= LAND_HEIGHT - 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
66 |
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
|
67 |
while (yd > 0) and ((Land[yd, x] and targetMask) = 0) do dec(yd); |
2376 | 68 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
69 |
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
|
70 |
yd:= 0; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
71 |
|
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
|
72 |
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
|
73 |
inc(yd); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
74 |
dec(yd); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
75 |
yu:= yd; |
2376 | 76 |
|
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
|
77 |
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
|
78 |
while (yu < yd ) and ((Land[yu, x] and targetMask) = 0) do inc(yu); |
2376 | 79 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
80 |
if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
11650 | 81 |
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
|
82 |
if (yu > 0) then |
11650 | 83 |
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
|
84 |
yd:= yu - 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
85 |
until yd < 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
86 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
87 |
SDL_FreeSurface(tmpsurf); |
4 | 88 |
end; |
89 |
||
9387 | 90 |
|
91 |
procedure DrawShoppaBorder; |
|
92 |
var x, y, s, i: Longword; |
|
93 |
c1, c2, c: Longword; |
|
94 |
begin |
|
95 |
c1:= AMask; |
|
96 |
c2:= AMask or RMask or GMask; |
|
97 |
||
98 |
// vertical |
|
99 |
s:= LAND_HEIGHT; |
|
10017 | 100 |
|
9387 | 101 |
for x:= 0 to LAND_WIDTH - 1 do |
102 |
for y:= 0 to LAND_HEIGHT - 1 do |
|
9864 | 103 |
if Land[y, x] = 0 then |
9387 | 104 |
if s < y then |
105 |
begin |
|
106 |
for i:= max(s, y - 8) to y - 1 do |
|
107 |
begin |
|
108 |
if ((x + i) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 109 |
|
9387 | 110 |
if (cReducedQuality and rqBlurryLand) = 0 then |
111 |
LandPixels[i, x]:= c |
|
112 |
else |
|
113 |
LandPixels[i div 2, x div 2]:= c |
|
114 |
end; |
|
115 |
s:= LAND_HEIGHT |
|
116 |
end |
|
117 |
else |
|
118 |
else |
|
119 |
begin |
|
120 |
if s > y then s:= y; |
|
121 |
if s + 8 > y then |
|
122 |
begin |
|
123 |
if ((x + y) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 124 |
|
9387 | 125 |
if (cReducedQuality and rqBlurryLand) = 0 then |
126 |
LandPixels[y, x]:= c |
|
127 |
else |
|
128 |
LandPixels[y div 2, x div 2]:= c |
|
10017 | 129 |
end; |
9387 | 130 |
end; |
10017 | 131 |
|
9387 | 132 |
// horizontal |
133 |
s:= LAND_WIDTH; |
|
10017 | 134 |
|
9387 | 135 |
for y:= 0 to LAND_HEIGHT - 1 do |
136 |
for x:= 0 to LAND_WIDTH - 1 do |
|
9864 | 137 |
if Land[y, x] = 0 then |
9387 | 138 |
if s < x then |
139 |
begin |
|
140 |
for i:= max(s, x - 8) to x - 1 do |
|
141 |
begin |
|
142 |
if ((y + i) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 143 |
|
9387 | 144 |
if (cReducedQuality and rqBlurryLand) = 0 then |
145 |
LandPixels[y, i]:= c |
|
146 |
else |
|
147 |
LandPixels[y div 2, i div 2]:= c |
|
148 |
end; |
|
149 |
s:= LAND_WIDTH |
|
150 |
end |
|
151 |
else |
|
152 |
else |
|
153 |
begin |
|
154 |
if s > x then s:= x; |
|
155 |
if s + 8 > x then |
|
156 |
begin |
|
157 |
if ((x + y) and 16) = 0 then c:= c1 else c:= c2; |
|
10017 | 158 |
|
9387 | 159 |
if (cReducedQuality and rqBlurryLand) = 0 then |
160 |
LandPixels[y, x]:= c |
|
161 |
else |
|
162 |
LandPixels[y div 2, x div 2]:= c |
|
10017 | 163 |
end; |
9387 | 164 |
end |
165 |
end; |
|
166 |
||
12104 | 167 |
procedure ColorizeLandFast(mapsurf: PSDL_Surface); |
168 |
var ltexsurf: PSDL_Surface; |
|
169 |
i: LongInt; |
|
170 |
ltlnp, srcp, dstp, stopp: Pointer; |
|
171 |
c: SizeInt; |
|
12100 | 172 |
begin |
12104 | 173 |
ltexsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps); |
12100 | 174 |
|
12104 | 175 |
// pointer to current line of ltexsurf pixels. will be moved from line to line |
176 |
ltlnp:= ltexsurf^.pixels; |
|
177 |
// pointer to mapsurf pixels. will jump forward after every move() |
|
178 |
dstp:= mapsurf^.pixels; |
|
179 |
||
180 |
// time to get serious |
|
181 |
SDL_LockSurface(mapsurf); |
|
182 |
SDL_LockSurface(ltexsurf); |
|
183 |
||
184 |
// for now only fill a row with the height of landtex. do vertical copies within mapsurf after |
|
12100 | 185 |
|
12104 | 186 |
// do this loop for each line of ltexsurf (unless we run out of map height first) |
187 |
for i:= 1 to min(ltexsurf^.h, mapsurf^.h) do |
|
188 |
begin |
|
189 |
// amount of pixels to write in first move() |
|
190 |
c:= ltexsurf^.pitch; |
|
12100 | 191 |
|
12104 | 192 |
// protect from odd cases where landtex wider than map |
193 |
if c > mapsurf^.pitch then |
|
194 |
c:= mapsurf^.pitch; |
|
195 |
||
196 |
// write line of landtex to mapsurf |
|
197 |
move(ltlnp^, dstp^, c); |
|
12100 | 198 |
|
12104 | 199 |
// fill the rest of the line by copying left-to-right until full |
200 |
||
201 |
// new src is start of line that we've just written to |
|
202 |
srcp:= dstp; |
|
203 |
// set stop pointer to start of next pixel line of mapsurf |
|
204 |
stopp:= dstp + mapsurf^.pitch; |
|
205 |
// move dst pointer to after what we've just written |
|
206 |
inc(dstp, c); |
|
207 |
||
208 |
// loop until dstp went past end of line |
|
209 |
while dstp < stopp do |
|
12100 | 210 |
begin |
12104 | 211 |
// copy all from left of dstp to right of it (or just fill the gap if smaller) |
212 |
c:= min(dstp-srcp, stopp-dstp); |
|
12100 | 213 |
move(srcp^, dstp^, c); |
214 |
inc(dstp, c); |
|
215 |
end; |
|
216 |
||
12104 | 217 |
// move to next line in ltexsurf |
218 |
inc(ltlnp, ltexsurf^.pitch); |
|
12100 | 219 |
end; |
220 |
||
12104 | 221 |
// we don't need ltexsurf itself anymore -> cleanup |
222 |
ltlnp:= nil; |
|
223 |
SDL_UnlockSurface(ltexsurf); |
|
224 |
SDL_FreeSurface(ltexsurf); |
|
225 |
ltexsurf:= nil; |
|
12100 | 226 |
|
12104 | 227 |
// from now on only copy pixels within mapsurf |
12100 | 228 |
|
229 |
// copy all the already written lines at once for that get number of written bytes so far |
|
12104 | 230 |
// already written pixels are between start and current dstp |
231 |
srcp:= mapsurf^.pixels; |
|
12100 | 232 |
|
12104 | 233 |
// first byte after end of pixels |
234 |
stopp:= srcp + (mapsurf^.pitch * mapsurf^.h); |
|
12100 | 235 |
|
12104 | 236 |
while dstp < stopp do |
12100 | 237 |
begin |
12104 | 238 |
// copy all from before dstp to after (or just fill the gap if smaller) |
239 |
c:= min(dstp-srcp, stopp-dstp); |
|
240 |
// worried about size of c with humongous maps? don't be: |
|
241 |
// the OS wouldn't have allowed allocation of object with size > max of SizeInt anyway |
|
12100 | 242 |
move(srcp^, dstp^, c); |
243 |
inc(dstp, c); |
|
244 |
end; |
|
245 |
||
12104 | 246 |
// cleanup |
247 |
srcp:= nil; |
|
248 |
dstp:= nil; |
|
249 |
stopp:= nil; |
|
250 |
SDL_UnlockSurface(mapsurf); |
|
12100 | 251 |
|
252 |
// freed in freeModule() below |
|
12592 | 253 |
LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifColorKey); |
12100 | 254 |
if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface); |
255 |
end; |
|
256 |
||
9387 | 257 |
procedure ColorizeLand(Surface: PSDL_Surface); |
258 |
var tmpsurf: PSDL_Surface; |
|
259 |
r: TSDL_Rect; |
|
10197 | 260 |
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 | 261 |
begin |
262 |
tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps); |
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
begin |
9387 | 267 |
r.x:= 0; |
268 |
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
|
269 |
begin |
11649
1fd1525653d8
SDL blit wraps at 16,384 - not the first time that routine has disappointed us.
nemo
parents:
11539
diff
changeset
|
270 |
copyToXY(tmpsurf, Surface, r.x, r.y); |
9387 | 271 |
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
|
272 |
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
|
273 |
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
|
274 |
r.y:= y |
9387 | 275 |
end; |
276 |
SDL_FreeSurface(tmpsurf); |
|
277 |
||
278 |
// freed in freeModule() below |
|
12592 | 279 |
LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifColorKey); |
9387 | 280 |
if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface); |
281 |
end; |
|
282 |
||
23 | 283 |
|
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
284 |
procedure GenDrawnMap; |
15200 | 285 |
var lowerX, upperX, lowerY, upperY, lowerFS, upperFS: LongInt; |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
286 |
begin |
15192
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
287 |
if (cFeatureSize <= 6) then |
15031
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
288 |
MaxHedgehogs:= 6 + (cFeatureSize-1) * 2 |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
289 |
else if (cFeatureSize < 11) then |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
290 |
MaxHedgehogs:= 16 + (cFeatureSize-6) * 4 |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
291 |
else if (cFeatureSize = 11) then |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
292 |
MaxHedgehogs:= 48 |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
293 |
else if (cFeatureSize = 12) then |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
294 |
MaxHedgehogs:= 64 |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
295 |
else |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
296 |
MaxHedgehogs:= cMaxHHs; |
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
297 |
|
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
298 |
if GameType = gmtLandPreview then |
15192
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
299 |
cFeatureSize:= 1; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
300 |
|
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
301 |
// Calculate map size for drawn map, use cFeatureSize to scale. |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
302 |
|
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
303 |
// We have pre-determined map size for cFeatureSize 1, 6, 12 and 25. |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
304 |
// The other values will be interpolated. |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
305 |
if cFeatureSize < 6 then |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
306 |
begin |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
307 |
// reference size for cFeatureSize 1 |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
308 |
lowerFS:= 1; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
309 |
lowerX:= 1024; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
310 |
lowerY:= 512; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
311 |
upperFS:= 6; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
312 |
end |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
313 |
else if cFeatureSize < 12 then |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
314 |
begin |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
315 |
// reference size for cFeatureSize 6 |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
316 |
lowerFS:= 6; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
317 |
lowerX:= 2048; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
318 |
lowerY:= 1024; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
319 |
upperFS:= 12; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
320 |
end |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
321 |
else |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
322 |
begin |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
323 |
// reference size for cFeatureSize 12, size of drawn maps in pre-1.0.0 versions |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
324 |
lowerFS:= 12; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
325 |
lowerX:= 4096; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
326 |
lowerY:= 2048; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
327 |
upperFS:= 25; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
328 |
end; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
329 |
|
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
330 |
upperX:= lowerX * 2; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
331 |
upperY:= lowerY * 2; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
332 |
|
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
333 |
if cFeatureSize = 25 then |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
334 |
begin |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
335 |
// hardcoded size for size level 25 |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
336 |
playWidth:= 8192; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
337 |
playHeight:= 4096; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
338 |
end |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
339 |
else |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
340 |
begin |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
341 |
// Interpolation formula |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
342 |
playWidth:= lowerX + ((upperX-lowerX) div (upperFS-lowerFS))*(cFeatureSize-lowerFS); |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
343 |
playHeight:= lowerY + ((upperY-lowerY) div (upperFS-lowerFS))*(cFeatureSize-lowerFS); |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
344 |
end; |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
345 |
|
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
346 |
if GameType <> gmtLandPreview then |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
347 |
WriteLnToConsole('Drawn map size: cFeatureSize='+IntToStr(cFeatureSize)+' playWidth='+IntToStr(playWidth)+' playHeight='+IntToStr(playHeight)); |
2765731b378b
New formula to calculate drawn map sizes, now every FeatureSize leads to an unique size
Wuzzy <Wuzzy2@mail.ru>
parents:
15179
diff
changeset
|
348 |
|
15162
af14c418c92f
Drawn maps: Erase land outside of land bounds
Wuzzy <Wuzzy2@mail.ru>
parents:
15160
diff
changeset
|
349 |
ResizeLand(playWidth, playHeight); |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
350 |
|
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
351 |
hasGirders:= true; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
352 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
353 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
354 |
topY:= LAND_HEIGHT - playHeight; |
15162
af14c418c92f
Drawn maps: Erase land outside of land bounds
Wuzzy <Wuzzy2@mail.ru>
parents:
15160
diff
changeset
|
355 |
|
af14c418c92f
Drawn maps: Erase land outside of land bounds
Wuzzy <Wuzzy2@mail.ru>
parents:
15160
diff
changeset
|
356 |
uLandPainted.Draw; |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
357 |
end; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
358 |
|
371 | 359 |
function SelectTemplate: LongInt; |
9243
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
360 |
var l: LongInt; |
161 | 361 |
begin |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
362 |
SelectTemplate:= 0; |
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
|
363 |
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
|
364 |
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
|
365 |
else |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
366 |
begin |
9243
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
367 |
if cTemplateFilter = 0 then |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
368 |
begin |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
369 |
l:= getRandom(GroupedTemplatesCount); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
370 |
repeat |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
371 |
inc(cTemplateFilter); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
372 |
dec(l, TemplateCounts[cTemplateFilter]); |
d8f6a396d98e
First select group of templates, then pick template from selected group
unc0rr
parents:
9080
diff
changeset
|
373 |
until l < 0; |
14305 | 374 |
end |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
375 |
else getRandom(1); |
10017 | 376 |
|
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
377 |
case cTemplateFilter of |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
378 |
0: OutError('Error selecting TemplateFilter. Ask unC0Rr about what you did wrong', true); |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
379 |
1: SelectTemplate:= SmallTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
380 |
2: SelectTemplate:= MediumTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
381 |
3: SelectTemplate:= LargeTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
382 |
4: SelectTemplate:= CavernTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
383 |
5: SelectTemplate:= WackyTemplates[getrandom(TemplateCounts[cTemplateFilter])]; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
384 |
// For lua only! |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
385 |
6: begin |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
386 |
SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates)); |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
387 |
GetRandom(2) // burn 1 |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
388 |
end |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
389 |
end |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
390 |
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
|
391 |
|
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
|
392 |
WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); |
161 | 393 |
end; |
394 |
||
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
395 |
procedure LandSurface2LandPixels(Surface: PSDL_Surface); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
396 |
var x, y: LongInt; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
397 |
p: PLongwordArray; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
398 |
begin |
11532 | 399 |
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
|
400 |
|
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
401 |
if SDL_MustLock(Surface) then |
11507 | 402 |
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
|
403 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
404 |
p:= Surface^.pixels; |
1760 | 405 |
for y:= 0 to LAND_HEIGHT - 1 do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
406 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
407 |
for x:= 0 to LAND_WIDTH - 1 do |
3598 | 408 |
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
|
409 |
if (cReducedQuality and rqBlurryLand) = 0 then |
11473
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:
11362
diff
changeset
|
410 |
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
|
411 |
else |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
412 |
LandPixels[y div 2, x div 2]:= p^[x]; |
2376 | 413 |
|
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10108
diff
changeset
|
414 |
p:= PLongwordArray(@(p^[Surface^.pitch div 4])); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
415 |
end; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
416 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
417 |
if SDL_MustLock(Surface) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
418 |
SDL_UnlockSurface(Surface); |
1754 | 419 |
end; |
420 |
||
3133 | 421 |
|
1754 | 422 |
procedure GenLandSurface; |
423 |
var tmpsurf: PSDL_Surface; |
|
5225 | 424 |
x,y: Longword; |
1754 | 425 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
426 |
AddProgress(); |
1754 | 427 |
|
11473
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:
11362
diff
changeset
|
428 |
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, AMask); |
1754 | 429 |
|
11532 | 430 |
if checkFails(tmpsurf <> nil, 'Error creating pre-land surface', true) then exit; |
12100 | 431 |
ColorizeLandFast(tmpsurf); |
9387 | 432 |
if gameFlags and gfShoppaBorder = 0 then DrawBorderFromImage(tmpsurf); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
433 |
AddOnLandObjects(tmpsurf); |
1754 | 434 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
435 |
LandSurface2LandPixels(tmpsurf); |
5227 | 436 |
SDL_FreeSurface(tmpsurf); |
10017 | 437 |
|
9387 | 438 |
if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder; |
10017 | 439 |
|
14303
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
13822
diff
changeset
|
440 |
for x:= LongWord(leftX+2) to LongWord(rightX-2) do |
14307 | 441 |
for y:= LongWord(topY+2) to LAND_HEIGHT-3 do |
10017 | 442 |
if (Land[y, x] = 0) and |
5274 | 443 |
(((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
444 |
((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |
|
445 |
begin |
|
446 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
447 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
448 |
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
|
449 |
LandPixels[y, x]:= LandPixels[y, x-1] |
10017 | 450 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
451 |
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
|
452 |
LandPixels[y, x]:= LandPixels[y, x+1] |
10017 | 453 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
454 |
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
|
455 |
LandPixels[y, x]:= LandPixels[y-1, x] |
10017 | 456 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
457 |
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
|
458 |
LandPixels[y, x]:= LandPixels[y+1, x]; |
10017 | 459 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
460 |
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
|
461 |
LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
5274 | 462 |
end; |
463 |
Land[y,x]:= lfObject |
|
464 |
end |
|
465 |
else if (Land[y, x] = 0) and |
|
466 |
(((Land[y, x-1] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
|
467 |
((Land[y, x-1] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
|
468 |
((Land[y, x+1] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
|
469 |
((Land[y, x+1] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
|
470 |
((Land[y+1, x] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
|
471 |
((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
|
472 |
((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or |
|
473 |
((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then |
|
10017 | 474 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
475 |
begin |
10017 | 476 |
|
5274 | 477 |
if (cReducedQuality and rqBlurryLand) = 0 then |
10017 | 478 |
|
5274 | 479 |
begin |
10017 | 480 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
481 |
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
|
482 |
LandPixels[y, x]:= LandPixels[y, x-1] |
10017 | 483 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
484 |
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
|
485 |
LandPixels[y, x]:= LandPixels[y, x+1] |
10017 | 486 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
487 |
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
|
488 |
LandPixels[y, x]:= LandPixels[y+1, x] |
10017 | 489 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
490 |
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
|
491 |
LandPixels[y, x]:= LandPixels[y-1, x]; |
10017 | 492 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
493 |
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
|
494 |
LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
5274 | 495 |
end; |
496 |
Land[y,x]:= lfObject |
|
497 |
end; |
|
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
498 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
499 |
AddProgress(); |
1754 | 500 |
end; |
501 |
||
11744
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:
11734
diff
changeset
|
502 |
procedure MakeFortsPreview; |
11745 | 503 |
var gap: LongInt; |
504 |
h1, h2, w1, w2, x, y, lastX, wbm, bmref: LongWord; |
|
11744
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:
11734
diff
changeset
|
505 |
const fortHeight = 960; |
11745 | 506 |
fortWidth = 704; |
507 |
bmHeight = 53; |
|
508 |
bmWidth = 64; |
|
11744
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:
11734
diff
changeset
|
509 |
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:
11734
diff
changeset
|
510 |
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:
11734
diff
changeset
|
511 |
|
11745 | 512 |
lastX:= LAND_WIDTH-1; |
513 |
||
11744
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:
11734
diff
changeset
|
514 |
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:
11734
diff
changeset
|
515 |
|
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:
11734
diff
changeset
|
516 |
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:
11734
diff
changeset
|
517 |
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:
11734
diff
changeset
|
518 |
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:
11734
diff
changeset
|
519 |
w1:= w2 - fortWidth; |
11745 | 520 |
wbm:= h1 + bmHeight; |
11744
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:
11734
diff
changeset
|
521 |
|
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:
11734
diff
changeset
|
522 |
// 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:
11734
diff
changeset
|
523 |
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:
11734
diff
changeset
|
524 |
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:
11734
diff
changeset
|
525 |
begin |
11746 | 526 |
if x mod 4 <> 0 then |
527 |
begin |
|
528 |
if (y <= wbm) and ((x - w1) mod (bmWidth * 2) >= bmWidth) then |
|
529 |
continue; |
|
530 |
Land[y,x]:= lfBasic; |
|
531 |
Land[y,lastX-x]:= lfBasic; |
|
532 |
end; |
|
11744
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:
11734
diff
changeset
|
533 |
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:
11734
diff
changeset
|
534 |
|
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:
11734
diff
changeset
|
535 |
w2:= w1 - gap; |
11745 | 536 |
w1:= max(0, w2 - fortWidth); |
537 |
wbm:= h1 + bmHeight; |
|
538 |
bmref:= w2 + bmWidth; |
|
11744
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:
11734
diff
changeset
|
539 |
|
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:
11734
diff
changeset
|
540 |
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:
11734
diff
changeset
|
541 |
for x:= w1 to w2 do |
11745 | 542 |
begin |
11746 | 543 |
if ((y - x) mod 2) = 0 then |
11744
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:
11734
diff
changeset
|
544 |
begin |
11745 | 545 |
// align battlement on inner edge, because real outer edge could be offscreen |
546 |
if (y <= wbm) and ((LAND_WIDTH + x - bmref) mod (bmWidth * 2) >= bmWidth) then |
|
547 |
continue; |
|
11744
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:
11734
diff
changeset
|
548 |
Land[y,x]:= lfBasic; |
11745 | 549 |
Land[y,lastX-x]:= lfBasic; |
11744
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:
11734
diff
changeset
|
550 |
end; |
11745 | 551 |
end; |
11744
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:
11734
diff
changeset
|
552 |
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:
11734
diff
changeset
|
553 |
|
1754 | 554 |
procedure MakeFortsMap; |
555 |
var tmpsurf: PSDL_Surface; |
|
11744
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:
11734
diff
changeset
|
556 |
sectionWidth, i, t, p: integer; |
11705 | 557 |
mirror: boolean; |
11734 | 558 |
pc: PClan; |
1754 | 559 |
begin |
11734 | 560 |
|
11744
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:
11734
diff
changeset
|
561 |
// 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:
11734
diff
changeset
|
562 |
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:
11734
diff
changeset
|
563 |
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:
11734
diff
changeset
|
564 |
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:
11734
diff
changeset
|
565 |
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:
11734
diff
changeset
|
566 |
|
11734 | 567 |
// mix up spawn/fort order of clans |
11744
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:
11734
diff
changeset
|
568 |
for i:= 0 to ClansCount - 1 do |
11734 | 569 |
begin |
11744
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:
11734
diff
changeset
|
570 |
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:
11734
diff
changeset
|
571 |
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:
11734
diff
changeset
|
572 |
if t <> p then |
11734 | 573 |
begin |
11744
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:
11734
diff
changeset
|
574 |
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:
11734
diff
changeset
|
575 |
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:
11734
diff
changeset
|
576 |
SpawnClansArray[p]:= pc; |
11734 | 577 |
end; |
578 |
end; |
|
579 |
||
11705 | 580 |
// figure out how much space we need |
581 |
playWidth:= sectionWidth * ClansCount; |
|
582 |
||
583 |
// note: LAND_WIDTH might be bigger than specified below (rounded to next power of 2) |
|
584 |
ResizeLand(playWidth, 2048); |
|
585 |
||
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
|
586 |
// 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 | 587 |
playHeight:= 1200; |
11705 | 588 |
|
589 |
// center playable area in land array |
|
590 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
|
1776 | 591 |
rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1); |
592 |
topY:= LAND_HEIGHT - playHeight; |
|
593 |
||
1754 | 594 |
WriteLnToConsole('Generating forts land...'); |
595 |
||
11705 | 596 |
for i := 0 to ClansCount - 1 do |
597 |
begin |
|
598 |
||
599 |
// face in random direction |
|
600 |
mirror:= (GetRandom(2) = 0); |
|
601 |
// make first/last fort face inwards |
|
11707
ecbf5e6c2c37
also make forts face inwards in wrap mode, if there are only 2 teams
sheepluva
parents:
11706
diff
changeset
|
602 |
if (WorldEdge <> weWrap) or (ClansCount = 2) then |
11706 | 603 |
mirror:= (i <> 0) and (mirror or (i = ClansCount - 1)); |
1754 | 604 |
|
11705 | 605 |
if mirror then |
606 |
begin |
|
607 |
// not critical because if no R we can fallback to mirrored L |
|
12592 | 608 |
tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifColorKey or ifIgnoreCaps); |
11705 | 609 |
// fallback |
610 |
if tmpsurf = nil then |
|
611 |
begin |
|
12592 | 612 |
tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifColorKey or ifIgnoreCaps); |
11705 | 613 |
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true); |
614 |
end |
|
615 |
else |
|
616 |
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
|
617 |
SDL_FreeSurface(tmpsurf); |
|
618 |
end |
|
619 |
else |
|
620 |
begin |
|
12592 | 621 |
tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifColorKey or ifIgnoreCaps); |
11705 | 622 |
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
623 |
SDL_FreeSurface(tmpsurf); |
|
624 |
end; |
|
625 |
||
626 |
end; |
|
1754 | 627 |
end; |
628 |
||
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
629 |
procedure LoadMapConfig; |
8060 | 630 |
var f: PFSFile; |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
631 |
s: shortstring; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
632 |
begin |
8025 | 633 |
s:= cPathz[ptMapCurrent] + '/map.cfg'; |
634 |
||
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
635 |
WriteLnToConsole('Fetching map HH limit'); |
8060 | 636 |
|
637 |
f:= pfsOpenRead(s); |
|
638 |
if f <> nil then |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
639 |
begin |
8060 | 640 |
pfsReadLn(f, s); |
641 |
if not pfsEof(f) then |
|
642 |
begin |
|
643 |
pfsReadLn(f, s); |
|
644 |
val(s, MaxHedgehogs) |
|
645 |
end; |
|
646 |
||
647 |
pfsClose(f) |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
648 |
end; |
8060 | 649 |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
650 |
if (MaxHedgehogs = 0) then |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
651 |
MaxHedgehogs:= 18; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
652 |
end; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
653 |
|
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
|
654 |
// 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
|
655 |
procedure LoadMask; |
1792 | 656 |
var tmpsurf: PSDL_Surface; |
657 |
p: PLongwordArray; |
|
658 |
x, y, cpX, cpY: Longword; |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
659 |
mapName: shortstring; |
1792 | 660 |
begin |
12592 | 661 |
tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifColorKey or ifIgnoreCaps); |
5770 | 662 |
if tmpsurf = nil then |
663 |
begin |
|
8025 | 664 |
mapName:= ExtractFileName(cPathz[ptMapCurrent]); |
12592 | 665 |
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifColorKey or ifIgnoreCaps); |
5770 | 666 |
end; |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
667 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
668 |
|
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
669 |
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
|
670 |
begin |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
671 |
if LAND_WIDTH = 0 then |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
672 |
begin |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
673 |
LoadMapConfig; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
674 |
ResizeLand(tmpsurf^.w, tmpsurf^.h); |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
675 |
playHeight:= tmpsurf^.h; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
676 |
playWidth:= tmpsurf^.w; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
677 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
678 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
679 |
topY:= LAND_HEIGHT - playHeight; |
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
680 |
end; |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
681 |
disableLandBack:= true; |
2376 | 682 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
683 |
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
|
684 |
cpY:= LAND_HEIGHT - tmpsurf^.h; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
685 |
if SDL_MustLock(tmpsurf) then |
11507 | 686 |
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
|
687 |
|
11507 | 688 |
if allOK then |
689 |
begin |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
690 |
p:= tmpsurf^.pixels; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
691 |
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
|
692 |
begin |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
693 |
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
|
694 |
SetLand(Land[cpY + y, cpX + x], p^[x]); |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10108
diff
changeset
|
695 |
p:= PLongwordArray(@(p^[tmpsurf^.pitch div 4])); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
696 |
end; |
2243
b4764993f833
additional touch support and nemo's reduced land array size
koda
parents:
2240
diff
changeset
|
697 |
|
11507 | 698 |
if SDL_MustLock(tmpsurf) then |
699 |
SDL_UnlockSurface(tmpsurf); |
|
700 |
if not disableLandBack then |
|
701 |
begin |
|
702 |
// freed in freeModule() below |
|
12592 | 703 |
LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifColorKey); |
11507 | 704 |
if (LandBackSurface <> nil) and GrayScale then |
705 |
Surface2GrayScale(LandBackSurface) |
|
706 |
end; |
|
707 |
end; |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
708 |
end; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
709 |
if (tmpsurf <> nil) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
710 |
SDL_FreeSurface(tmpsurf); |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
711 |
tmpsurf:= nil; |
1792 | 712 |
end; |
713 |
||
1754 | 714 |
procedure LoadMap; |
715 |
var tmpsurf: PSDL_Surface; |
|
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
716 |
mapName: shortstring = ''; |
1754 | 717 |
begin |
718 |
WriteLnToConsole('Loading land from file...'); |
|
719 |
AddProgress; |
|
12592 | 720 |
tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifColorKey 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
|
721 |
if tmpsurf = nil then |
5770 | 722 |
begin |
8025 | 723 |
mapName:= ExtractFileName(cPathz[ptMapCurrent]); |
12592 | 724 |
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifColorKey or ifIgnoreCaps); |
11532 | 725 |
if not allOK then exit; |
5770 | 726 |
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
|
727 |
// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take |
11532 | 728 |
if checkFails((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true) |
729 |
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
|
730 |
|
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
|
731 |
ResizeLand(tmpsurf^.w, tmpsurf^.h); |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
732 |
LoadMapConfig; |
1792 | 733 |
|
1776 | 734 |
playHeight:= tmpsurf^.h; |
735 |
playWidth:= tmpsurf^.w; |
|
736 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
|
737 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
738 |
topY:= LAND_HEIGHT - playHeight; |
|
739 |
||
11532 | 740 |
if not checkFails(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true) then |
741 |
BlitImageAndGenerateCollisionInfo( |
|
742 |
(LAND_WIDTH - tmpsurf^.w) div 2, |
|
743 |
LAND_HEIGHT - tmpsurf^.h, |
|
744 |
tmpsurf^.w, |
|
745 |
tmpsurf); |
|
1754 | 746 |
|
747 |
SDL_FreeSurface(tmpsurf); |
|
1792 | 748 |
|
11532 | 749 |
if allOK then LoadMask; |
1754 | 750 |
end; |
751 |
||
5717 | 752 |
procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD |
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
753 |
var x, w, c, y: Longword; |
5717 | 754 |
begin |
5718
e74de0528ef4
Let's draw the bottom border thicker, so it is more visible
nemo
parents:
5717
diff
changeset
|
755 |
for w:= 0 to 23 do |
14303
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
13822
diff
changeset
|
756 |
for x:= LongWord(leftX) to LongWord(rightX) do |
5717 | 757 |
begin |
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
758 |
y:= Longword(cWaterLine) - 1 - w; |
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
759 |
Land[y, x]:= lfIndestructible; |
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
760 |
if (x + y) mod 32 < 16 then |
5717 | 761 |
c:= AMask |
762 |
else |
|
763 |
c:= AMask or RMask or GMask; // FF00FFFF |
|
764 |
||
765 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
766 |
LandPixels[y, x]:= c |
5717 | 767 |
else |
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
768 |
LandPixels[y 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
|
769 |
end |
5717 | 770 |
end; |
771 |
||
1754 | 772 |
procedure GenMap; |
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
773 |
var x, y, w, c, c2: Longword; |
8025 | 774 |
map, mask: shortstring; |
1754 | 775 |
begin |
3463 | 776 |
hasBorder:= false; |
8011 | 777 |
maskOnly:= false; |
2891
e1f902eb0cfe
Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents:
2866
diff
changeset
|
778 |
|
3463 | 779 |
LoadThemeConfig; |
3697 | 780 |
|
11881
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
781 |
if cPathz[ptMapCurrent] <> '' then |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
782 |
begin |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
783 |
map:= cPathz[ptMapCurrent] + '/map.png'; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
784 |
mask:= cPathz[ptMapCurrent] + '/mask.png'; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
785 |
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
|
786 |
begin |
11881
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
787 |
maskOnly:= true; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
788 |
LoadMask; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
789 |
GenLandSurface |
8010
195677b0d06b
something bender asked for. allow a mask without a map
nemo
parents:
8003
diff
changeset
|
790 |
end |
11881
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
791 |
else LoadMap; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
792 |
end |
3463 | 793 |
else |
11881
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
794 |
begin |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
795 |
WriteLnToConsole('Generating land...'); |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
796 |
case cMapGen of |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
797 |
mgRandom: GenTemplated(EdgeTemplates[SelectTemplate]); |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
798 |
mgMaze : begin ResizeLand(4096,2048); GenMaze; end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
799 |
mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
800 |
mgDrawn : GenDrawnMap; |
13272
5984e8c6cbeb
Add new game flag gfSwitchHog, enable hog switching at turn start
Wuzzy <Wuzzy2@mail.ru>
parents:
12758
diff
changeset
|
801 |
mgForts : begin GameFlags:= (GameFlags or gfDivideTeams); MakeFortsMap(); end; |
11881
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
802 |
else |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
803 |
OutError('Unknown mapgen', true); |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
804 |
end; |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
805 |
if cMapGen <> mgForts then |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
806 |
GenLandSurface |
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11826
diff
changeset
|
807 |
end; |
3463 | 808 |
|
809 |
AddProgress; |
|
1760 | 810 |
|
1768 | 811 |
// check for land near top |
1784 | 812 |
c:= 0; |
813 |
if (GameFlags and gfBorder) <> 0 then |
|
814 |
hasBorder:= true |
|
815 |
else |
|
14307 | 816 |
for y:= LongWord(topY) to LongWord(topY + 5) do |
14303
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
13822
diff
changeset
|
817 |
for x:= LongWord(leftX) to LongWord(rightX) do |
1784 | 818 |
if Land[y, x] <> 0 then |
819 |
begin |
|
820 |
inc(c); |
|
8370 | 821 |
if c > LongWord((LAND_WIDTH div 2)) then // avoid accidental triggering |
1784 | 822 |
begin |
823 |
hasBorder:= true; |
|
824 |
break; |
|
825 |
end; |
|
826 |
end; |
|
1768 | 827 |
|
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
828 |
// Indestructible map border (top, left, right) |
1776 | 829 |
if hasBorder then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
830 |
begin |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
831 |
// Make land beyond the border indestructible |
10661 | 832 |
if WorldEdge = weNone then |
833 |
begin |
|
834 |
for y:= 0 to LAND_HEIGHT - 1 do |
|
835 |
for x:= 0 to LAND_WIDTH - 1 do |
|
14307 | 836 |
if (y < LongWord(topY)) or (x < LongWord(leftX)) or (x > LongWord(rightX)) then |
10661 | 837 |
Land[y, x]:= lfIndestructible; |
838 |
end |
|
839 |
else if topY > 0 then |
|
840 |
begin |
|
14307 | 841 |
for y:= 0 to LongWord(topY - 1) do |
10661 | 842 |
for x:= 0 to LAND_WIDTH - 1 do |
3519 | 843 |
Land[y, x]:= lfIndestructible; |
10661 | 844 |
end; |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
845 |
// Render map border |
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
846 |
for w:= 0 to (cBorderWidth-1) do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
847 |
begin |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
848 |
// Left and right border |
9524 | 849 |
if (WorldEdge <> weBounce) and (WorldEdge <> weWrap) then |
14307 | 850 |
for y:= LongWord(topY) to LAND_HEIGHT - 1 do |
9524 | 851 |
begin |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
852 |
// set land flags |
9524 | 853 |
Land[y, leftX + w]:= lfIndestructible; |
854 |
Land[y, rightX - w]:= lfIndestructible; |
|
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
855 |
|
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
856 |
// paint black and yellow stripes |
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
857 |
if (y + leftX + w) mod 32 < 16 then |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
858 |
c:= AMask // black |
9524 | 859 |
else |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
860 |
c:= AMask or RMask or GMask; // yellow |
12087
78e9fbd52ffc
simplify code of previous commit ( ba1807589eaa )
sheepluva
parents:
12086
diff
changeset
|
861 |
if (y + rightX - w) mod 32 < 16 then |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
862 |
c2:= AMask // black |
12086
ba1807589eaa
OCD-compatibility-patch: make border stripes consistent in direction and offset, seamless.
sheepluva
parents:
11881
diff
changeset
|
863 |
else |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
864 |
c2:= AMask or RMask or GMask; // yellow |
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
|
865 |
|
9524 | 866 |
if (cReducedQuality and rqBlurryLand) = 0 then |
867 |
begin |
|
868 |
LandPixels[y, leftX + w]:= c; |
|
12087
78e9fbd52ffc
simplify code of previous commit ( ba1807589eaa )
sheepluva
parents:
12086
diff
changeset
|
869 |
LandPixels[y, rightX - w]:= c2; |
9524 | 870 |
end |
871 |
else |
|
872 |
begin |
|
873 |
LandPixels[y div 2, (leftX + w) div 2]:= c; |
|
12087
78e9fbd52ffc
simplify code of previous commit ( ba1807589eaa )
sheepluva
parents:
12086
diff
changeset
|
874 |
LandPixels[y div 2, (rightX - w) div 2]:= c2; |
9524 | 875 |
end; |
5717 | 876 |
end; |
1768 | 877 |
|
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
878 |
// Top border |
14303
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
13822
diff
changeset
|
879 |
for x:= LongWord(leftX) to LongWord(rightX) do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
880 |
begin |
5717 | 881 |
Land[topY + w, x]:= lfIndestructible; |
15160
adf6f9be8113
Fix coloring of map border at top left/right corner being wrong sometimes
Wuzzy <Wuzzy2@mail.ru>
parents:
15031
diff
changeset
|
882 |
if (topY + x + w) mod 32 < 16 then |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
883 |
c:= AMask // black |
5717 | 884 |
else |
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
885 |
c:= AMask or RMask or GMask; // yellow |
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
|
886 |
|
5717 | 887 |
if (cReducedQuality and rqBlurryLand) = 0 then |
888 |
LandPixels[topY + w, x]:= c |
|
889 |
else |
|
890 |
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
|
891 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
892 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
893 |
end; |
1768 | 894 |
|
15179
4744d7b78c75
Refactor uLand.pas a bit and add constant for border width
Wuzzy <Wuzzy2@mail.ru>
parents:
15165
diff
changeset
|
895 |
// Bottom border |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
896 |
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
|
897 |
DrawBottomBorder; |
5717 | 898 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
899 |
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
|
900 |
hasGirders:= false; |
2891
e1f902eb0cfe
Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents:
2866
diff
changeset
|
901 |
|
13272
5984e8c6cbeb
Add new game flag gfSwitchHog, enable hog switching at turn start
Wuzzy <Wuzzy2@mail.ru>
parents:
12758
diff
changeset
|
902 |
if (cMapGen <> mgForts) 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
|
903 |
AddObjects |
10017 | 904 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
905 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
906 |
AddProgress(); |
1776 | 907 |
|
3058 | 908 |
FreeLandObjects; |
909 |
||
11539 | 910 |
if not allOK then exit; |
911 |
||
6982 | 912 |
if GrayScale then |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
913 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
914 |
if (cReducedQuality and rqBlurryLand) = 0 then |
14303
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
13822
diff
changeset
|
915 |
for x:= LongWord(leftX) to LongWord(rightX) do |
14307 | 916 |
for y:= LongWord(topY) to LAND_HEIGHT-1 do |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
917 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
918 |
w:= LandPixels[y,x]; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
919 |
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
|
920 |
(w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
921 |
(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
|
922 |
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
|
923 |
w:= 255; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
924 |
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
|
925 |
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
|
926 |
end |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
927 |
else |
14303
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
13822
diff
changeset
|
928 |
for x:= LongWord(leftX div 2) to LongWord(rightX div 2) do |
14307 | 929 |
for y:= LongWord(topY div 2) to LAND_HEIGHT-1 div 2 do |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
930 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
931 |
w:= LandPixels[y div 2,x div 2]; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
932 |
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
|
933 |
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
|
934 |
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
|
935 |
end |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
936 |
end; |
10016
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
937 |
|
59a6d65fcb60
(experimental) make the mysterious borders around land/hats/etc that appear on zoom vanish
sheepluva
parents:
9998
diff
changeset
|
938 |
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
|
939 |
|
10661 | 940 |
// adjust world edges for borderless maps |
941 |
if (WorldEdge <> weNone) and (not hasBorder) then |
|
942 |
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
|
943 |
|
13754
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13506
diff
changeset
|
944 |
ScriptSetMapGlobals; |
37 | 945 |
end; |
946 |
||
7079 | 947 |
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
|
948 |
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
|
949 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
950 |
WriteLnToConsole('Generating preview...'); |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
951 |
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
|
952 |
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
|
953 |
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
|
954 |
mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end; |
15031
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
955 |
mgDrawn: begin GenDrawnMap; end; |
11744
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:
11734
diff
changeset
|
956 |
mgForts: MakeFortsPreview(); |
4562 | 957 |
else |
958 |
OutError('Unknown mapgen', true); |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
959 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
960 |
|
13754
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13506
diff
changeset
|
961 |
ScriptSetMapGlobals; |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13506
diff
changeset
|
962 |
|
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
|
963 |
// strict scaling needed here since preview assumes a rectangle |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
964 |
if (cMapGen <> mgDrawn) then |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
965 |
begin |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
966 |
rh:= max(LAND_HEIGHT, 2048); |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
967 |
rw:= max(LAND_WIDTH, 4096); |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
968 |
end |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
969 |
else |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
970 |
begin |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
971 |
rh:= LAND_HEIGHT; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
972 |
rw:= LAND_WIDTH |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
973 |
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
|
974 |
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
|
975 |
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
|
976 |
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
|
977 |
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
|
978 |
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
|
979 |
if rh < rw div 2 then rh:= rw * 2; |
10017 | 980 |
|
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
|
981 |
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
|
982 |
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
|
983 |
|
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
|
984 |
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
|
985 |
lw:= rw div 32; |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
986 |
for y:= 0 to 127 do |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
987 |
for x:= 0 to 31 do |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
988 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
989 |
Preview[y, x]:= 0; |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
990 |
for bit:= 0 to 7 do |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
991 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
992 |
t:= 0; |
3617 | 993 |
cbit:= bit * 8; |
994 |
for yy:= y * lh to y * lh + 7 do |
|
995 |
for xx:= x * lw + cbit to x * lw + cbit + 7 do |
|
10017 | 996 |
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
|
997 |
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
|
998 |
inc(t); |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
999 |
if t > 8 then |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
1000 |
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
|
1001 |
end; |
566 | 1002 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
1003 |
end; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
1004 |
|
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
|
1005 |
|
10162 | 1006 |
procedure GenPreviewAlpha(out Preview: TPreviewAlpha); |
1007 |
var rh, rw, ox, oy, x, y, xx, yy, t, lh, lw: LongInt; |
|
1008 |
begin |
|
1009 |
WriteLnToConsole('Generating preview...'); |
|
1010 |
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
|
1011 |
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
|
1012 |
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
|
1013 |
mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end; |
15031
5d8068ee16fc
Give a more accurate hedgehog limit estimate for small drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
14439
diff
changeset
|
1014 |
mgDrawn: begin GenDrawnMap; end; |
11744
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:
11734
diff
changeset
|
1015 |
mgForts: MakeFortsPreview; |
10162 | 1016 |
else |
1017 |
OutError('Unknown mapgen', true); |
|
1018 |
end; |
|
1019 |
||
13754
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13506
diff
changeset
|
1020 |
ScriptSetMapGlobals; |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13506
diff
changeset
|
1021 |
|
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1022 |
|
10162 | 1023 |
// strict scaling needed here since preview assumes a rectangle |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1024 |
if (cMapGen <> mgDrawn) then |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1025 |
begin |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1026 |
rh:= max(LAND_HEIGHT, 2048); |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1027 |
rw:= max(LAND_WIDTH, 4096); |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1028 |
end |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1029 |
else |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1030 |
begin |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1031 |
rh:= LAND_HEIGHT; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1032 |
rw:= LAND_WIDTH |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1033 |
end; |
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1034 |
|
10162 | 1035 |
ox:= 0; |
1036 |
if rw < rh*2 then |
|
1037 |
begin |
|
1038 |
rw:= rh*2; |
|
1039 |
end; |
|
1040 |
if rh < rw div 2 then rh:= rw * 2; |
|
1041 |
||
1042 |
ox:= (rw-LAND_WIDTH) div 2; |
|
1043 |
oy:= rh-LAND_HEIGHT; |
|
1044 |
||
1045 |
lh:= rh div 128; |
|
1046 |
lw:= rw div 256; |
|
1047 |
for y:= 0 to 127 do |
|
1048 |
for x:= 0 to 255 do |
|
1049 |
begin |
|
1050 |
t:= 0; |
|
1051 |
||
10165 | 1052 |
for yy:= y * lh - oy to y * lh + lh - 1 - oy do |
1053 |
for xx:= x * lw - ox to x * lw + lw - 1 - ox do |
|
10162 | 1054 |
if (yy and LAND_HEIGHT_MASK = 0) and (xx and LAND_WIDTH_MASK = 0) |
1055 |
and (Land[yy, xx] <> 0) then |
|
1056 |
inc(t); |
|
1057 |
||
10165 | 1058 |
Preview[y, x]:= t * 255 div (lh * lw); |
10162 | 1059 |
end; |
1060 |
end; |
|
1061 |
||
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
|
1062 |
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
|
1063 |
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
|
1064 |
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
|
1065 |
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
|
1066 |
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
|
1067 |
else |
13504
c41b16ac2e05
Clarify the wording of a few checkFails messages
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
1068 |
checkFails(s = digest, 'Loaded map or other critical resource does not match across all players', 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
|
1069 |
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
|
1070 |
|
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
|
1071 |
procedure chSendLandDigest(var s: shortstring); |
12711
20dbb3a03e61
extend land digest to all surfaces that could possibly be loaded into Land[] - i.e. ones that impact sync
nemo
parents:
12592
diff
changeset
|
1072 |
var i: LongInt; |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1073 |
landPixelDigest : LongInt; |
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
|
1074 |
begin |
14439
0281b80d366c
might as well render preview using smallest size to speed it up
nemo
parents:
14437
diff
changeset
|
1075 |
landPixelDigest:= 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
|
1076 |
for i:= 0 to LAND_HEIGHT-1 do |
13822
381e37c6d5d9
Separate synced pixels from land digests - this is mostly to allow the official racer digests to remain unchanged.
nemo
parents:
13754
diff
changeset
|
1077 |
landPixelDigest:= Adler32Update(landPixelDigest, @Land[i,0], LAND_WIDTH*2); |
381e37c6d5d9
Separate synced pixels from land digests - this is mostly to allow the official racer digests to remain unchanged.
nemo
parents:
13754
diff
changeset
|
1078 |
s:= 'M' + IntToStr(syncedPixelDigest)+'|'+IntToStr(landPixelDigest); |
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
|
1079 |
|
13822
381e37c6d5d9
Separate synced pixels from land digests - this is mostly to allow the official racer digests to remain unchanged.
nemo
parents:
13754
diff
changeset
|
1080 |
ScriptSetString('LandDigest',IntToStr(landPixelDigest)); |
10022 | 1081 |
|
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
|
1082 |
chLandCheck(s); |
11532 | 1083 |
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
|
1084 |
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
|
1085 |
|
3038 | 1086 |
procedure initModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
1087 |
begin |
6898 | 1088 |
RegisterVariable('landcheck', @chLandCheck, false); |
1089 |
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
|
1090 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
1091 |
LandBackSurface:= nil; |
3369
c7289e42f0ee
add other controls for map preview, also fix a bug in digest
koda
parents:
3365
diff
changeset
|
1092 |
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
|
1093 |
maskOnly:= false; |
7549 | 1094 |
LAND_WIDTH:= 0; |
1095 |
LAND_HEIGHT:= 0; |
|
1096 |
(* |
|
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
|
1097 |
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
|
1098 |
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
|
1099 |
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
|
1100 |
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
|
1101 |
|
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
|
1102 |
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
|
1103 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
7549 | 1104 |
*) |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
1105 |
end; |
51 | 1106 |
|
3038 | 1107 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
1108 |
begin |
7151 | 1109 |
SetLength(Land, 0, 0); |
1110 |
SetLength(LandPixels, 0, 0); |
|
1111 |
SetLength(LandDirty, 0, 0); |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
1112 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
1113 |
|
4 | 1114 |
end. |