author | nemo |
Fri, 05 Feb 2010 13:32:57 +0000 | |
changeset 2760 | 420fe0344e5f |
parent 2747 | 7889a3a9724f |
child 2866 | 450ca0afcd58 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2005-2008 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
23 |
uses SDLh, uLandTemplates, uFloat, uConsts, |
2152 | 24 |
{$IFDEF GLES11} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
25 |
gles11; |
1906 | 26 |
{$ELSE} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
27 |
GL; |
1906 | 28 |
{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
29 |
|
1760 | 30 |
type TLandArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of LongWord; |
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2665
diff
changeset
|
31 |
TCollisionArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of Word; |
1760 | 32 |
TPreview = packed array[0..127, 0..31] of byte; |
33 |
TDirtyTag = packed array[0 .. LAND_HEIGHT div 32 - 1, 0 .. LAND_WIDTH div 32 - 1] of byte; |
|
4 | 34 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
35 |
var Land: TCollisionArray; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
36 |
LandPixels: TLandArray; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
37 |
LandDirty: TDirtyTag; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
38 |
hasBorder: boolean; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
39 |
hasGirders: boolean; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
40 |
playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword; // idea is that a template can specify height/width. Or, a map, a height/width by the dimensions of the image. If the map has pixels near top of image, it triggers border. |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
41 |
LandBackSurface: PSDL_Surface; |
4 | 42 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
43 |
procedure init_uLand; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
44 |
procedure free_uLand; |
37 | 45 |
procedure GenMap; |
766 | 46 |
function GenPreview: TPreview; |
367 | 47 |
procedure CheckLandDigest(s: shortstring); |
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2665
diff
changeset
|
48 |
function LandBackPixel(x, y: LongInt): LongWord; |
4 | 49 |
|
50 |
implementation |
|
1806 | 51 |
uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO, uAmmos, uLandTexture; |
4 | 52 |
|
53 |
type TPixAr = record |
|
54 |
Count: Longword; |
|
22 | 55 |
ar: array[0..Pred(cMaxEdgePoints)] of TPoint; |
4 | 56 |
end; |
57 |
||
37 | 58 |
procedure LogLandDigest; |
316 | 59 |
var ctx: TSHA1Context; |
60 |
dig: TSHA1Digest; |
|
61 |
s: shortstring; |
|
37 | 62 |
begin |
316 | 63 |
SHA1Init(ctx); |
2157 | 64 |
SHA1UpdateLongwords(ctx, @Land, sizeof(Land) div 4); |
316 | 65 |
dig:= SHA1Final(ctx); |
367 | 66 |
s:='M{'+inttostr(dig[0])+':' |
316 | 67 |
+inttostr(dig[1])+':' |
68 |
+inttostr(dig[2])+':' |
|
69 |
+inttostr(dig[3])+':' |
|
70 |
+inttostr(dig[4])+'}'; |
|
699 | 71 |
CheckLandDigest(s); |
367 | 72 |
SendIPCRaw(@s[0], Length(s) + 1) |
73 |
end; |
|
74 |
||
75 |
procedure CheckLandDigest(s: shortstring); |
|
76 |
const digest: shortstring = ''; |
|
77 |
begin |
|
368 | 78 |
{$IFDEF DEBUGFILE} |
79 |
AddFileLog('CheckLandDigest: ' + s); |
|
80 |
{$ENDIF} |
|
367 | 81 |
if digest = '' then |
82 |
digest:= s |
|
83 |
else |
|
700 | 84 |
TryDo(s = digest, 'Different maps generated, sorry', true) |
37 | 85 |
end; |
86 |
||
371 | 87 |
procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); |
358 | 88 |
var |
371 | 89 |
eX, eY, dX, dY: LongInt; |
90 |
i, sX, sY, x, y, d: LongInt; |
|
358 | 91 |
begin |
92 |
eX:= 0; |
|
93 |
eY:= 0; |
|
94 |
dX:= X2 - X1; |
|
95 |
dY:= Y2 - Y1; |
|
96 |
||
97 |
if (dX > 0) then sX:= 1 |
|
98 |
else |
|
99 |
if (dX < 0) then |
|
100 |
begin |
|
101 |
sX:= -1; |
|
102 |
dX:= -dX |
|
103 |
end else sX:= dX; |
|
104 |
||
105 |
if (dY > 0) then sY:= 1 |
|
106 |
else |
|
107 |
if (dY < 0) then |
|
108 |
begin |
|
109 |
sY:= -1; |
|
110 |
dY:= -dY |
|
111 |
end else sY:= dY; |
|
112 |
||
113 |
if (dX > dY) then d:= dX |
|
114 |
else d:= dY; |
|
115 |
||
116 |
x:= X1; |
|
117 |
y:= Y1; |
|
2376 | 118 |
|
358 | 119 |
for i:= 0 to d do |
120 |
begin |
|
121 |
inc(eX, dX); |
|
122 |
inc(eY, dY); |
|
123 |
if (eX > d) then |
|
124 |
begin |
|
125 |
dec(eX, d); |
|
126 |
inc(x, sX); |
|
127 |
end; |
|
128 |
if (eY > d) then |
|
129 |
begin |
|
130 |
dec(eY, d); |
|
131 |
inc(y, sY); |
|
132 |
end; |
|
364 | 133 |
|
1753 | 134 |
if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then |
358 | 135 |
Land[y, x]:= Color; |
136 |
end |
|
137 |
end; |
|
138 |
||
365 | 139 |
procedure DrawEdge(var pa: TPixAr; Color: Longword); |
371 | 140 |
var i: LongInt; |
4 | 141 |
begin |
365 | 142 |
i:= 0; |
4 | 143 |
with pa do |
371 | 144 |
while i < LongInt(Count) - 1 do |
365 | 145 |
if (ar[i + 1].X = NTPX) then inc(i, 2) |
146 |
else begin |
|
147 |
DrawLine(ar[i].x, ar[i].y, ar[i + 1].x, ar[i + 1].y, Color); |
|
148 |
inc(i) |
|
149 |
end |
|
22 | 150 |
end; |
151 |
||
365 | 152 |
procedure Vector(p1, p2, p3: TPoint; var Vx, Vy: hwFloat); |
153 |
var d1, d2, d: hwFloat; |
|
364 | 154 |
begin |
498 | 155 |
Vx:= int2hwFloat(p1.X - p3.X); |
156 |
Vy:= int2hwFloat(p1.Y - p3.Y); |
|
157 |
d:= DistanceI(p2.X - p1.X, p2.Y - p1.Y); |
|
158 |
d1:= DistanceI(p2.X - p3.X, p2.Y - p3.Y); |
|
365 | 159 |
d2:= Distance(Vx, Vy); |
160 |
if d1 < d then d:= d1; |
|
161 |
if d2 < d then d:= d2; |
|
162 |
d:= d * _1div3; |
|
163 |
if d2.QWordValue = 0 then |
|
164 |
begin |
|
498 | 165 |
Vx:= _0; |
166 |
Vy:= _0 |
|
365 | 167 |
end else |
168 |
begin |
|
498 | 169 |
d2:= _1 / d2; |
365 | 170 |
Vx:= Vx * d2; |
171 |
Vy:= Vy * d2; |
|
172 |
||
173 |
Vx:= Vx * d; |
|
174 |
Vy:= Vy * d |
|
175 |
end |
|
176 |
end; |
|
177 |
||
371 | 178 |
procedure AddLoopPoints(var pa, opa: TPixAr; StartI, EndI: LongInt; Delta: hwFloat); |
179 |
var i, pi, ni: LongInt; |
|
365 | 180 |
NVx, NVy, PVx, PVy: hwFloat; |
498 | 181 |
x1, x2, y1, y2: LongInt; |
182 |
tsq, tcb, t, r1, r2, r3, cx1, cx2, cy1, cy2: hwFloat; |
|
371 | 183 |
X, Y: LongInt; |
365 | 184 |
begin |
185 |
pi:= EndI; |
|
186 |
i:= StartI; |
|
187 |
ni:= Succ(StartI); |
|
188 |
Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy); |
|
189 |
repeat |
|
190 |
inc(pi); |
|
191 |
if pi > EndI then pi:= StartI; |
|
192 |
inc(i); |
|
193 |
if i > EndI then i:= StartI; |
|
194 |
inc(ni); |
|
195 |
if ni > EndI then ni:= StartI; |
|
196 |
PVx:= NVx; |
|
197 |
PVy:= NVy; |
|
198 |
Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy); |
|
199 |
||
200 |
x1:= opa.ar[pi].x; |
|
201 |
y1:= opa.ar[pi].y; |
|
202 |
x2:= opa.ar[i].x; |
|
203 |
y2:= opa.ar[i].y; |
|
498 | 204 |
cx1:= int2hwFloat(x1) - PVx; |
205 |
cy1:= int2hwFloat(y1) - PVy; |
|
206 |
cx2:= int2hwFloat(x2) + NVx; |
|
207 |
cy2:= int2hwFloat(y2) + NVy; |
|
208 |
t:= _0; |
|
364 | 209 |
while t.Round = 0 do |
210 |
begin |
|
211 |
tsq:= t * t; |
|
212 |
tcb:= tsq * t; |
|
498 | 213 |
r1:= (_1 - t*3 + tsq*3 - tcb); |
214 |
r2:= ( t*3 - tsq*6 + tcb*3); |
|
215 |
r3:= ( tsq*3 - tcb*3); |
|
430 | 216 |
X:= hwRound(r1 * x1 + r2 * cx1 + r3 * cx2 + tcb * x2); |
217 |
Y:= hwRound(r1 * y1 + r2 * cy1 + r3 * cy2 + tcb * y2); |
|
364 | 218 |
t:= t + Delta; |
219 |
pa.ar[pa.Count].x:= X; |
|
220 |
pa.ar[pa.Count].y:= Y; |
|
221 |
inc(pa.Count); |
|
222 |
TryDo(pa.Count <= cMaxEdgePoints, 'Edge points overflow', true) |
|
223 |
end; |
|
365 | 224 |
until i = StartI; |
225 |
pa.ar[pa.Count].x:= opa.ar[StartI].X; |
|
226 |
pa.ar[pa.Count].y:= opa.ar[StartI].Y; |
|
364 | 227 |
inc(pa.Count) |
228 |
end; |
|
229 |
||
365 | 230 |
procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat); |
495 | 231 |
var i, StartLoop: LongInt; |
365 | 232 |
opa: TPixAr; |
233 |
begin |
|
234 |
opa:= pa; |
|
235 |
pa.Count:= 0; |
|
236 |
i:= 0; |
|
237 |
StartLoop:= 0; |
|
371 | 238 |
while i < LongInt(opa.Count) do |
365 | 239 |
if (opa.ar[i + 1].X = NTPX) then |
240 |
begin |
|
241 |
AddLoopPoints(pa, opa, StartLoop, i, Delta); |
|
242 |
inc(i, 2); |
|
243 |
StartLoop:= i; |
|
244 |
pa.ar[pa.Count].X:= NTPX; |
|
245 |
inc(pa.Count); |
|
246 |
end else inc(i) |
|
247 |
end; |
|
248 |
||
371 | 249 |
procedure FillLand(x, y: LongInt); |
4 | 250 |
var Stack: record |
251 |
Count: Longword; |
|
252 |
points: array[0..8192] of record |
|
371 | 253 |
xl, xr, y, dir: LongInt; |
4 | 254 |
end |
255 |
end; |
|
256 |
||
371 | 257 |
procedure Push(_xl, _xr, _y, _dir: LongInt); |
4 | 258 |
begin |
75 | 259 |
TryDo(Stack.Count <= 8192, 'FillLand: stack overflow', true); |
4 | 260 |
_y:= _y + _dir; |
1760 | 261 |
if (_y < 0) or (_y >= LAND_HEIGHT) then exit; |
4 | 262 |
with Stack.points[Stack.Count] do |
263 |
begin |
|
264 |
xl:= _xl; |
|
265 |
xr:= _xr; |
|
266 |
y:= _y; |
|
267 |
dir:= _dir |
|
268 |
end; |
|
75 | 269 |
inc(Stack.Count) |
4 | 270 |
end; |
271 |
||
371 | 272 |
procedure Pop(var _xl, _xr, _y, _dir: LongInt); |
4 | 273 |
begin |
274 |
dec(Stack.Count); |
|
275 |
with Stack.points[Stack.Count] do |
|
276 |
begin |
|
277 |
_xl:= xl; |
|
278 |
_xr:= xr; |
|
279 |
_y:= y; |
|
280 |
_dir:= dir |
|
281 |
end |
|
282 |
end; |
|
283 |
||
371 | 284 |
var xl, xr, dir: LongInt; |
351 | 285 |
begin |
4 | 286 |
Stack.Count:= 0; |
287 |
xl:= x - 1; |
|
288 |
xr:= x; |
|
23 | 289 |
Push(xl, xr, y, -1); |
290 |
Push(xl, xr, y, 1); |
|
4 | 291 |
while Stack.Count > 0 do |
292 |
begin |
|
293 |
Pop(xl, xr, y, dir); |
|
51 | 294 |
while (xl > 0) and (Land[y, xl] <> 0) do dec(xl); |
1760 | 295 |
while (xr < LAND_WIDTH - 1) and (Land[y, xr] <> 0) do inc(xr); |
4 | 296 |
while (xl < xr) do |
297 |
begin |
|
51 | 298 |
while (xl <= xr) and (Land[y, xl] = 0) do inc(xl); |
4 | 299 |
x:= xl; |
51 | 300 |
while (xl <= xr) and (Land[y, xl] <> 0) do |
4 | 301 |
begin |
51 | 302 |
Land[y, xl]:= 0; |
4 | 303 |
inc(xl) |
304 |
end; |
|
22 | 305 |
if x < xl then |
306 |
begin |
|
307 |
Push(x, Pred(xl), y, dir); |
|
308 |
Push(x, Pred(xl), y,-dir); |
|
309 |
end; |
|
4 | 310 |
end; |
311 |
end; |
|
312 |
end; |
|
313 |
||
2647 | 314 |
function LandBackPixel(x, y: LongInt): LongWord; |
315 |
var p: PLongWordArray; |
|
316 |
begin |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
317 |
if LandBackSurface = nil then LandBackPixel:= 0 |
2647 | 318 |
else |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
319 |
begin |
2647 | 320 |
p:= LandBackSurface^.pixels; |
321 |
LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
322 |
end |
2647 | 323 |
end; |
324 |
||
4 | 325 |
procedure ColorizeLand(Surface: PSDL_Surface); |
326 |
var tmpsurf: PSDL_Surface; |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
327 |
r, rr: TSDL_Rect; |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
328 |
x, yd, yu: LongInt; |
4 | 329 |
begin |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
330 |
tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
331 |
r.y:= 0; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
332 |
while r.y < LAND_HEIGHT do |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
333 |
begin |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
334 |
r.x:= 0; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
335 |
while r.x < LAND_WIDTH do |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
336 |
begin |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
337 |
SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
338 |
inc(r.x, tmpsurf^.w) |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
339 |
end; |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
340 |
inc(r.y, tmpsurf^.h) |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
341 |
end; |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
342 |
SDL_FreeSurface(tmpsurf); |
4 | 343 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
344 |
// freed in free_uLand() below |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
345 |
LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); |
2647 | 346 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
347 |
tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
348 |
for x:= 0 to LAND_WIDTH - 1 do |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
349 |
begin |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
350 |
yd:= LAND_HEIGHT - 1; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
351 |
repeat |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
352 |
while (yd > 0) and (Land[yd, x] = 0) do dec(yd); |
2376 | 353 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
354 |
if (yd < 0) then yd:= 0; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
355 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
356 |
while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
357 |
dec(yd); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
358 |
yu:= yd; |
2376 | 359 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
360 |
while (yu > 0 ) and (Land[yu, x] <> 0) do dec(yu); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
361 |
while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); |
2376 | 362 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
363 |
if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
364 |
begin |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
365 |
rr.x:= x; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
366 |
rr.y:= yd - 15; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
367 |
r.x:= x mod tmpsurf^.w; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
368 |
r.y:= 16; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
369 |
r.w:= 1; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
370 |
r.h:= 16; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
371 |
SDL_UpperBlit(tmpsurf, @r, Surface, @rr); |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
372 |
end; |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
373 |
if (yu > 0) then |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
374 |
begin |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
375 |
rr.x:= x; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
376 |
rr.y:= yu; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
377 |
r.x:= x mod tmpsurf^.w; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
378 |
r.y:= 0; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
379 |
r.w:= 1; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
380 |
r.h:= min(16, yd - yu + 1); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
381 |
SDL_UpperBlit(tmpsurf, @r, Surface, @rr); |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
382 |
end; |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
383 |
yd:= yu - 1; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
384 |
until yd < 0; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
385 |
end; |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
386 |
SDL_FreeSurface(tmpsurf); |
4 | 387 |
end; |
388 |
||
358 | 389 |
procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr); |
371 | 390 |
var i: LongInt; |
22 | 391 |
begin |
23 | 392 |
with Template do |
393 |
begin |
|
358 | 394 |
pa.Count:= BasePointsCount; |
395 |
for i:= 0 to pred(pa.Count) do |
|
23 | 396 |
begin |
371 | 397 |
pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w)); |
1792 | 398 |
if pa.ar[i].x <> NTPX then |
399 |
pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2); |
|
1776 | 400 |
pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - Template.TemplateHeight |
23 | 401 |
end; |
1183
540cea859395
Step 4: repair girder rendering (girder is 32bit now)
unc0rr
parents:
1182
diff
changeset
|
402 |
|
358 | 403 |
if canMirror then |
360 | 404 |
if getrandom(2) = 0 then |
358 | 405 |
begin |
406 |
for i:= 0 to pred(BasePointsCount) do |
|
365 | 407 |
if pa.ar[i].x <> NTPX then |
1760 | 408 |
pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x; |
358 | 409 |
for i:= 0 to pred(FillPointsCount) do |
1760 | 410 |
FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x; |
358 | 411 |
end; |
22 | 412 |
|
2338
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
413 |
(* Experiment in making this option more useful |
2376 | 414 |
if ((not isNegative) and (cTemplateFilter = 4)) or |
2338
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
415 |
(canFlip and (getrandom(2) = 0)) then |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
416 |
begin |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
417 |
for i:= 0 to pred(BasePointsCount) do |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
418 |
begin |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
419 |
pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y + (LAND_HEIGHT - TemplateHeight) * 2; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
420 |
if pa.ar[i].y > LAND_HEIGHT - 1 then |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
421 |
pa.ar[i].y:= LAND_HEIGHT - 1; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
422 |
end; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
423 |
for i:= 0 to pred(FillPointsCount) do |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
424 |
begin |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
425 |
FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y + (LAND_HEIGHT - TemplateHeight) * 2; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
426 |
if FillPoints^[i].y > LAND_HEIGHT - 1 then |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
427 |
FillPoints^[i].y:= LAND_HEIGHT - 1; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
428 |
end; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
429 |
end; |
2376 | 430 |
end |
2338
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
431 |
*) |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
432 |
// template recycling. Pull these off the floor a bit |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
433 |
if (not isNegative) and (cTemplateFilter = 4) then |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
434 |
begin |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
435 |
for i:= 0 to pred(BasePointsCount) do |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
436 |
begin |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
437 |
dec(pa.ar[i].y, 100); |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
438 |
if pa.ar[i].y < 0 then |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
439 |
pa.ar[i].y:= 0; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
440 |
end; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
441 |
for i:= 0 to pred(FillPointsCount) do |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
442 |
begin |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
443 |
dec(FillPoints^[i].y, 100); |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
444 |
if FillPoints^[i].y < 0 then |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
445 |
FillPoints^[i].y:= 0; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
446 |
end; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
447 |
end; |
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
448 |
|
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
449 |
if (canFlip and (getrandom(2) = 0)) then |
358 | 450 |
begin |
451 |
for i:= 0 to pred(BasePointsCount) do |
|
1760 | 452 |
pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y; |
358 | 453 |
for i:= 0 to pred(FillPointsCount) do |
1760 | 454 |
FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y; |
358 | 455 |
end; |
456 |
end |
|
4 | 457 |
end; |
67 | 458 |
|
561 | 459 |
function CheckIntersect(V1, V2, V3, V4: TPoint): boolean; |
460 |
var c1, c2, dm: LongInt; |
|
461 |
begin |
|
462 |
dm:= (V4.y - V3.y) * (V2.x - V1.x) - (V4.x - V3.x) * (V2.y - V1.y); |
|
463 |
c1:= (V4.x - V3.x) * (V1.y - V3.y) - (V4.y - V3.y) * (V1.x - V3.x); |
|
464 |
if dm = 0 then exit(false); |
|
465 |
||
466 |
c2:= (V2.x - V3.x) * (V1.y - V3.y) - (V2.y - V3.y) * (V1.x - V3.x); |
|
467 |
if dm > 0 then |
|
468 |
begin |
|
469 |
if (c1 < 0) or (c1 > dm) then exit(false); |
|
470 |
if (c2 < 0) or (c2 > dm) then exit(false) |
|
471 |
end else |
|
472 |
begin |
|
473 |
if (c1 > 0) or (c1 < dm) then exit(false); |
|
474 |
if (c2 > 0) or (c2 < dm) then exit(false) |
|
475 |
end; |
|
476 |
||
477 |
//AddFileLog('1 (' + inttostr(V1.x) + ',' + inttostr(V1.y) + ')x(' + inttostr(V2.x) + ',' + inttostr(V2.y) + ')'); |
|
478 |
//AddFileLog('2 (' + inttostr(V3.x) + ',' + inttostr(V3.y) + ')x(' + inttostr(V4.x) + ',' + inttostr(V4.y) + ')'); |
|
479 |
CheckIntersect:= true |
|
480 |
end; |
|
481 |
||
482 |
function CheckSelfIntersect(var pa: TPixAr; ind: Longword): boolean; |
|
483 |
var i: Longword; |
|
484 |
begin |
|
485 |
if (ind <= 0) or (ind >= Pred(pa.Count)) then exit(false); |
|
486 |
for i:= 1 to pa.Count - 3 do |
|
487 |
if (i <= ind - 1) or (i >= ind + 2) then |
|
488 |
begin |
|
489 |
if (i <> ind - 1) and |
|
490 |
CheckIntersect(pa.ar[ind], pa.ar[ind - 1], pa.ar[i], pa.ar[i - 1]) then exit(true); |
|
491 |
if (i <> ind + 2) and |
|
492 |
CheckIntersect(pa.ar[ind], pa.ar[ind + 1], pa.ar[i], pa.ar[i - 1]) then exit(true); |
|
493 |
end; |
|
494 |
CheckSelfIntersect:= false |
|
495 |
end; |
|
496 |
||
429 | 497 |
procedure RandomizePoints(var pa: TPixAr); |
364 | 498 |
const cEdge = 55; |
561 | 499 |
cMinDist = 8; |
371 | 500 |
var radz: array[0..Pred(cMaxEdgePoints)] of LongInt; |
561 | 501 |
i, k, dist, px, py: LongInt; |
364 | 502 |
begin |
503 |
radz[0]:= 0; |
|
504 |
for i:= 0 to Pred(pa.Count) do |
|
505 |
with pa.ar[i] do |
|
365 | 506 |
if x <> NTPX then |
507 |
begin |
|
1760 | 508 |
radz[i]:= Min(Max(x - cEdge, 0), Max(LAND_WIDTH - cEdge - x, 0)); |
509 |
radz[i]:= Min(radz[i], Min(Max(y - cEdge, 0), Max(LAND_HEIGHT - cEdge - y, 0))); |
|
365 | 510 |
if radz[i] > 0 then |
511 |
for k:= 0 to Pred(i) do |
|
364 | 512 |
begin |
429 | 513 |
dist:= Max(abs(x - pa.ar[k].x), abs(y - pa.ar[k].y)); |
365 | 514 |
radz[k]:= Max(0, Min((dist - cMinDist) div 2, radz[k])); |
515 |
radz[i]:= Max(0, Min(dist - radz[k] - cMinDist, radz[i])) |
|
516 |
end |
|
517 |
end; |
|
364 | 518 |
|
519 |
for i:= 0 to Pred(pa.Count) do |
|
520 |
with pa.ar[i] do |
|
1753 | 521 |
if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then |
364 | 522 |
begin |
561 | 523 |
px:= x; |
524 |
py:= y; |
|
371 | 525 |
x:= x + LongInt(GetRandom(7) - 3) * (radz[i] * 5 div 7) div 3; |
561 | 526 |
y:= y + LongInt(GetRandom(7) - 3) * (radz[i] * 5 div 7) div 3; |
527 |
if CheckSelfIntersect(pa, i) then |
|
528 |
begin |
|
529 |
x:= px; |
|
530 |
y:= py |
|
531 |
end; |
|
364 | 532 |
end |
67 | 533 |
end; |
534 |
||
364 | 535 |
|
23 | 536 |
procedure GenBlank(var Template: TEdgeTemplate); |
4 | 537 |
var pa: TPixAr; |
23 | 538 |
i: Longword; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
539 |
y, x: Longword; |
4 | 540 |
begin |
1760 | 541 |
for y:= 0 to LAND_HEIGHT - 1 do |
542 |
for x:= 0 to LAND_WIDTH - 1 do |
|
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
543 |
Land[y, x]:= COLOR_LAND; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
544 |
|
358 | 545 |
SetPoints(Template, pa); |
429 | 546 |
for i:= 1 to Template.BezierizeCount do |
547 |
begin |
|
431 | 548 |
BezierizeEdge(pa, _0_5); |
561 | 549 |
RandomizePoints(pa); |
429 | 550 |
RandomizePoints(pa) |
551 |
end; |
|
552 |
for i:= 1 to Template.RandPassesCount do RandomizePoints(pa); |
|
365 | 553 |
BezierizeEdge(pa, _0_1); |
27 | 554 |
|
365 | 555 |
DrawEdge(pa, 0); |
27 | 556 |
|
358 | 557 |
with Template do |
23 | 558 |
for i:= 0 to pred(FillPointsCount) do |
559 |
with FillPoints^[i] do |
|
89 | 560 |
FillLand(x, y); |
561 |
||
1773 | 562 |
DrawEdge(pa, COLOR_LAND); |
563 |
||
1792 | 564 |
MaxHedgehogs:= Template.MaxHedgehogs; |
1776 | 565 |
hasGirders:= Template.hasGirders; |
566 |
playHeight:= Template.TemplateHeight; |
|
567 |
playWidth:= Template.TemplateWidth; |
|
568 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
|
569 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
570 |
topY:= LAND_HEIGHT - playHeight; |
|
571 |
||
1797 | 572 |
// force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
2376 | 573 |
if (cTemplateFilter = 4) or |
2338
8f6508c97f3f
An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents:
2308
diff
changeset
|
574 |
(Template.canInvert and (getrandom(2) = 0)) or |
2376 | 575 |
(not Template.canInvert and Template.isNegative) then |
1776 | 576 |
begin |
577 |
hasBorder:= true; |
|
1773 | 578 |
for y:= 0 to LAND_HEIGHT - 1 do |
579 |
for x:= 0 to LAND_WIDTH - 1 do |
|
1776 | 580 |
if (y < topY) or (x < leftX) or (x > rightX) then |
581 |
Land[y, x]:= 0 |
|
582 |
else |
|
583 |
begin |
|
584 |
if Land[y, x] = 0 then |
|
585 |
Land[y, x]:= COLOR_LAND |
|
586 |
else if Land[y, x] = COLOR_LAND then |
|
587 |
Land[y, x]:= 0; |
|
588 |
end; |
|
589 |
end; |
|
23 | 590 |
end; |
591 |
||
371 | 592 |
function SelectTemplate: LongInt; |
161 | 593 |
begin |
1797 | 594 |
case cTemplateFilter of |
595 |
0: begin |
|
596 |
SelectTemplate:= getrandom(Succ(High(EdgeTemplates))); |
|
597 |
end; |
|
598 |
1: begin |
|
599 |
SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]; |
|
600 |
end; |
|
601 |
2: begin |
|
602 |
SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))]; |
|
603 |
end; |
|
604 |
3: begin |
|
605 |
SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))]; |
|
606 |
end; |
|
607 |
4: begin |
|
608 |
SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))]; |
|
609 |
end; |
|
610 |
5: begin |
|
611 |
SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))]; |
|
612 |
end; |
|
613 |
end; |
|
614 |
WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); |
|
161 | 615 |
end; |
616 |
||
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
617 |
procedure LandSurface2LandPixels(Surface: PSDL_Surface); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
618 |
var x, y: LongInt; |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
619 |
p: PLongwordArray; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
620 |
begin |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
621 |
TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
622 |
|
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
623 |
if SDL_MustLock(Surface) then |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
624 |
SDLTry(SDL_LockSurface(Surface) >= 0, true); |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
625 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
626 |
p:= Surface^.pixels; |
1760 | 627 |
for y:= 0 to LAND_HEIGHT - 1 do |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
628 |
begin |
1760 | 629 |
for x:= 0 to LAND_WIDTH - 1 do |
2592 | 630 |
if Land[y, x] <> 0 then LandPixels[y, x]:= p^[x] or AMask; |
2376 | 631 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
632 |
p:= @(p^[Surface^.pitch div 4]); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
633 |
end; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
634 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
635 |
if SDL_MustLock(Surface) then |
1753 | 636 |
SDL_UnlockSurface(Surface); |
1754 | 637 |
end; |
638 |
||
639 |
procedure GenLandSurface; |
|
640 |
var tmpsurf: PSDL_Surface; |
|
641 |
begin |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
642 |
WriteLnToConsole('Generating land...'); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
643 |
GenBlank(EdgeTemplates[SelectTemplate]); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
644 |
AddProgress(); |
1754 | 645 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
646 |
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0); |
1754 | 647 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
648 |
TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
649 |
ColorizeLand(tmpsurf); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
650 |
AddOnLandObjects(tmpsurf); |
1754 | 651 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
652 |
LandSurface2LandPixels(tmpsurf); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
653 |
SDL_FreeSurface(tmpsurf); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
654 |
AddProgress(); |
1754 | 655 |
end; |
656 |
||
657 |
procedure MakeFortsMap; |
|
658 |
var tmpsurf: PSDL_Surface; |
|
659 |
begin |
|
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
|
660 |
// 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 | 661 |
playHeight:= 1200; |
2096 | 662 |
playWidth:= 2560; |
1776 | 663 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
664 |
rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1); |
|
665 |
topY:= LAND_HEIGHT - playHeight; |
|
666 |
||
1754 | 667 |
WriteLnToConsole('Generating forts land...'); |
668 |
||
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
|
669 |
tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1784 | 670 |
BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
1754 | 671 |
SDL_FreeSurface(tmpsurf); |
672 |
||
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
|
673 |
tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1784 | 674 |
BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
1754 | 675 |
SDL_FreeSurface(tmpsurf); |
676 |
end; |
|
677 |
||
1792 | 678 |
// Hi unC0Rr. |
679 |
// This is a function that Tiy assures me would not be good for gameplay. |
|
680 |
// It allows the setting of arbitrary portions of landscape as indestructible, or regular, or even blank. |
|
2154
3d2917be12c3
Change default output to stderr since /tmp doesn't exist under windows and is useless under iphoneos, add a couple of extra parameters
nemo
parents:
2152
diff
changeset
|
681 |
// He said I could add it here only when I swore it would not impact gameplay. Which, as far as I can tell, is true. |
3d2917be12c3
Change default output to stderr since /tmp doesn't exist under windows and is useless under iphoneos, add a couple of extra parameters
nemo
parents:
2152
diff
changeset
|
682 |
// I would just like to play with it with my friends if you do not mind. |
1792 | 683 |
// Can allow for amusing maps. |
684 |
procedure LoadMask; |
|
685 |
var tmpsurf: PSDL_Surface; |
|
686 |
p: PLongwordArray; |
|
687 |
x, y, cpX, cpY: Longword; |
|
688 |
begin |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
689 |
tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
690 |
if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
691 |
begin |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
692 |
cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
693 |
cpY:= LAND_HEIGHT - tmpsurf^.h; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
694 |
if SDL_MustLock(tmpsurf) then |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
695 |
SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
2376 | 696 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
697 |
p:= tmpsurf^.pixels; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
698 |
for y:= 0 to Pred(tmpsurf^.h) do |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
699 |
begin |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
700 |
for x:= 0 to Pred(tmpsurf^.w) do |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
701 |
begin |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
702 |
if ((AMask and p^[x]) = 0) then // Tiy was having trouble generating transparent black |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
703 |
Land[cpY + y, cpX + x]:= 0 |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
704 |
else if p^[x] = (AMask or RMask) then |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
705 |
Land[cpY + y, cpX + x]:= COLOR_INDESTRUCTIBLE |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
706 |
else if p^[x] = $FFFFFFFF then |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
707 |
Land[cpY + y, cpX + x]:= COLOR_LAND; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
708 |
end; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
709 |
p:= @(p^[tmpsurf^.pitch div 4]); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
710 |
end; |
2243
b4764993f833
additional touch support and nemo's reduced land array size
koda
parents:
2240
diff
changeset
|
711 |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
712 |
if SDL_MustLock(tmpsurf) then |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
713 |
SDL_UnlockSurface(tmpsurf); |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
714 |
end; |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
715 |
if (tmpsurf <> nil) then |
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
716 |
SDL_FreeSurface(tmpsurf); |
1792 | 717 |
end; |
718 |
||
1754 | 719 |
procedure LoadMap; |
720 |
var tmpsurf: PSDL_Surface; |
|
1795 | 721 |
s: string; |
722 |
f: textfile; |
|
1754 | 723 |
begin |
724 |
WriteLnToConsole('Loading land from file...'); |
|
725 |
AddProgress; |
|
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
|
726 |
tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1760 | 727 |
TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); |
1754 | 728 |
|
2154
3d2917be12c3
Change default output to stderr since /tmp doesn't exist under windows and is useless under iphoneos, add a couple of extra parameters
nemo
parents:
2152
diff
changeset
|
729 |
// unC0Rr - should this be passed from the GUI? I am not sure which layer does what |
1792 | 730 |
s:= Pathz[ptMapCurrent] + '/map.cfg'; |
731 |
WriteLnToConsole('Fetching map HH limit'); |
|
732 |
Assign(f, s); |
|
2747 | 733 |
filemode:= 0; // readonly |
1792 | 734 |
Reset(f); |
1795 | 735 |
Readln(f); |
736 |
if not eof(f) then Readln(f, MaxHedgehogs); |
|
737 |
||
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
738 |
if (MaxHedgehogs = 0) then MaxHedgehogs:= 18; |
1792 | 739 |
|
1776 | 740 |
playHeight:= tmpsurf^.h; |
741 |
playWidth:= tmpsurf^.w; |
|
742 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
|
743 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
744 |
topY:= LAND_HEIGHT - playHeight; |
|
745 |
||
1754 | 746 |
TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true); |
747 |
||
1772 | 748 |
BlitImageAndGenerateCollisionInfo( |
749 |
(LAND_WIDTH - tmpsurf^.w) div 2, |
|
750 |
LAND_HEIGHT - tmpsurf^.h, |
|
751 |
tmpsurf^.w, |
|
752 |
tmpsurf); |
|
1754 | 753 |
SDL_FreeSurface(tmpsurf); |
1792 | 754 |
|
755 |
LoadMask; |
|
1754 | 756 |
end; |
757 |
||
758 |
procedure GenMap; |
|
1784 | 759 |
var x, y, w, c: Longword; |
1754 | 760 |
begin |
1776 | 761 |
hasBorder:= false; |
762 |
hasGirders:= true; |
|
1754 | 763 |
LoadThemeConfig; |
764 |
||
765 |
if (GameFlags and gfForts) = 0 then |
|
766 |
if Pathz[ptMapCurrent] <> '' then LoadMap |
|
767 |
else GenLandSurface |
|
768 |
else MakeFortsMap; |
|
769 |
AddProgress; |
|
1760 | 770 |
|
1754 | 771 |
{$IFDEF DEBUGFILE}LogLandDigest;{$ENDIF} |
1753 | 772 |
|
1768 | 773 |
// check for land near top |
1784 | 774 |
c:= 0; |
775 |
if (GameFlags and gfBorder) <> 0 then |
|
776 |
hasBorder:= true |
|
777 |
else |
|
778 |
for y:= topY to topY + 5 do |
|
779 |
for x:= leftX to rightX do |
|
780 |
if Land[y, x] <> 0 then |
|
781 |
begin |
|
782 |
inc(c); |
|
783 |
if c > 200 then // avoid accidental triggering |
|
784 |
begin |
|
785 |
hasBorder:= true; |
|
786 |
break; |
|
787 |
end; |
|
788 |
end; |
|
1768 | 789 |
|
1776 | 790 |
if hasBorder then |
1768 | 791 |
begin |
1784 | 792 |
for y:= 0 to LAND_HEIGHT - 1 do |
793 |
for x:= 0 to LAND_WIDTH - 1 do |
|
794 |
if (y < topY) or (x < leftX) or (x > rightX) then |
|
795 |
Land[y, x]:= COLOR_INDESTRUCTIBLE; |
|
1768 | 796 |
// experiment hardcoding cave |
1784 | 797 |
// also try basing cave dimensions on map/template dimensions, if they exist |
2308 | 798 |
for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade |
1784 | 799 |
begin |
800 |
for y:= topY to LAND_HEIGHT - 1 do |
|
801 |
begin |
|
802 |
Land[y, leftX + w]:= COLOR_INDESTRUCTIBLE; |
|
803 |
Land[y, rightX - w]:= COLOR_INDESTRUCTIBLE; |
|
804 |
if (y + w) mod 32 < 16 then |
|
2592 | 805 |
c:= AMask |
1784 | 806 |
else |
2619 | 807 |
c:= AMask or RMask or GMask; // FF00FFFF |
1784 | 808 |
LandPixels[y, leftX + w]:= c; |
809 |
LandPixels[y, rightX - w]:= c; |
|
810 |
end; |
|
1768 | 811 |
|
1784 | 812 |
for x:= leftX to rightX do |
813 |
begin |
|
814 |
Land[topY + w, x]:= COLOR_INDESTRUCTIBLE; |
|
815 |
if (x + w) mod 32 < 16 then |
|
2592 | 816 |
c:= AMask |
1784 | 817 |
else |
2619 | 818 |
c:= AMask or RMask or GMask; // FF00FFFF |
1784 | 819 |
LandPixels[topY + w, x]:= c; |
820 |
end; |
|
821 |
end; |
|
1768 | 822 |
end; |
823 |
||
1776 | 824 |
if ((GameFlags and gfForts) = 0) and (Pathz[ptMapCurrent] = '') then AddObjects; |
825 |
||
1807 | 826 |
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT); |
37 | 827 |
end; |
828 |
||
566 | 829 |
function GenPreview: TPreview; |
371 | 830 |
var x, y, xx, yy, t, bit: LongInt; |
566 | 831 |
Preview: TPreview; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
832 |
begin |
160 | 833 |
WriteLnToConsole('Generating preview...'); |
161 | 834 |
GenBlank(EdgeTemplates[SelectTemplate]); |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
835 |
|
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
836 |
for y:= 0 to 127 do |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
837 |
for x:= 0 to 31 do |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
838 |
begin |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
839 |
Preview[y, x]:= 0; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
840 |
for bit:= 0 to 7 do |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
841 |
begin |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
842 |
t:= 0; |
1760 | 843 |
for yy:= y * (LAND_HEIGHT div 128) to y * (LAND_HEIGHT div 128) + 7 do |
844 |
for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
|
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
845 |
if Land[yy, xx] <> 0 then inc(t); |
351 | 846 |
if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit) |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
847 |
end |
566 | 848 |
end; |
1768 | 849 |
GenPreview:= Preview |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
850 |
end; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
851 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
852 |
procedure init_uLand; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
853 |
begin |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
854 |
LandBackSurface:= nil; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
855 |
end; |
51 | 856 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
857 |
procedure free_uLand; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
858 |
begin |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
859 |
if LandBackSurface <> nil then |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
860 |
SDL_FreeSurface(LandBackSurface); |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
861 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
862 |
|
4 | 863 |
end. |