author | nemo |
Sun, 05 Feb 2012 22:22:46 -0500 | |
changeset 6633 | 2dc43ce68721 |
parent 6626 | a447993f2ad7 |
child 6700 | e04da46ee43c |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2004-2011 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 |
|
4367 | 23 |
uses SDLh, uLandTemplates, uFloat, uConsts, GLunit, uTypes; |
4 | 24 |
|
3038 | 25 |
procedure initModule; |
26 |
procedure freeModule; |
|
5717 | 27 |
procedure DrawBottomBorder; |
37 | 28 |
procedure GenMap; |
766 | 29 |
function GenPreview: TPreview; |
4 | 30 |
|
31 |
implementation |
|
4389 | 32 |
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
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
|
33 |
uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures, |
6491 | 34 |
uLandGenMaze, uLandOutline; |
365 | 35 |
|
4 | 36 |
|
37 |
procedure ColorizeLand(Surface: PSDL_Surface); |
|
38 |
var tmpsurf: PSDL_Surface; |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
39 |
r, rr: TSDL_Rect; |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
40 |
x, yd, yu: LongInt; |
4 | 41 |
begin |
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
|
42 |
tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/LandTex', ifIgnoreCaps); |
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
|
43 |
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
44 |
r.y:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
45 |
while r.y < LAND_HEIGHT do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
46 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
47 |
r.x:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
48 |
while r.x < LAND_WIDTH do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
49 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
50 |
SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
51 |
inc(r.x, tmpsurf^.w) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
52 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
53 |
inc(r.y, tmpsurf^.h) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
54 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
55 |
SDL_FreeSurface(tmpsurf); |
4 | 56 |
|
3038 | 57 |
// freed in freeModule() below |
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
|
58 |
LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); |
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
|
59 |
if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); |
6303 | 60 |
if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface); |
2647 | 61 |
|
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
|
62 |
tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Border', ifIgnoreCaps or ifTransparent); |
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
|
63 |
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
64 |
for x:= 0 to LAND_WIDTH - 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
65 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
66 |
yd:= LAND_HEIGHT - 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
67 |
repeat |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
68 |
while (yd > 0) and (Land[yd, x] = 0) do dec(yd); |
2376 | 69 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
70 |
if (yd < 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
71 |
yd:= 0; |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
72 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
73 |
while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
74 |
inc(yd); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
75 |
dec(yd); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
76 |
yu:= yd; |
2376 | 77 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
78 |
while (yu > 0 ) and (Land[yu, x] <> 0) do dec(yu); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
79 |
while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); |
2376 | 80 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
81 |
if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
82 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
83 |
rr.x:= x; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
84 |
rr.y:= yd - 15; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
85 |
r.x:= x mod tmpsurf^.w; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
86 |
r.y:= 16; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
87 |
r.w:= 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
88 |
r.h:= 16; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
89 |
SDL_UpperBlit(tmpsurf, @r, Surface, @rr); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
90 |
end; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
91 |
if (yu > 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
|
92 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
93 |
rr.x:= x; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
94 |
rr.y:= yu; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
95 |
r.x:= x mod tmpsurf^.w; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
96 |
r.y:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
97 |
r.w:= 1; |
4374 | 98 |
r.h:= Min(16, yd - yu + 1); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
99 |
SDL_UpperBlit(tmpsurf, @r, Surface, @rr); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
100 |
end; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
101 |
yd:= yu - 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
102 |
until yd < 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
103 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
104 |
SDL_FreeSurface(tmpsurf); |
4 | 105 |
end; |
106 |
||
358 | 107 |
procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr); |
371 | 108 |
var i: LongInt; |
22 | 109 |
begin |
23 | 110 |
with Template do |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
111 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
112 |
pa.Count:= BasePointsCount; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
113 |
for i:= 0 to pred(pa.Count) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
114 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
115 |
pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w)); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
116 |
if pa.ar[i].x <> NTPX then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
117 |
pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
118 |
pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
119 |
end; |
1183
540cea859395
Step 4: repair girder rendering (girder is 32bit now)
unc0rr
parents:
1182
diff
changeset
|
120 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
121 |
if canMirror then |
360 | 122 |
if getrandom(2) = 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
|
123 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
124 |
for i:= 0 to pred(BasePointsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
125 |
if pa.ar[i].x <> NTPX then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
126 |
pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
127 |
for i:= 0 to pred(FillPointsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
128 |
FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
129 |
end; |
22 | 130 |
|
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
|
131 |
(* Experiment in making this option more useful |
2376 | 132 |
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
|
133 |
(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
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
end; |
2376 | 148 |
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
|
149 |
*) |
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
|
150 |
// template recycling. Pull these off the floor a bit |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
151 |
if (not isNegative) and (cTemplateFilter = 4) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
152 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
153 |
for i:= 0 to pred(BasePointsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
154 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
155 |
dec(pa.ar[i].y, 100); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
156 |
if pa.ar[i].y < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
157 |
pa.ar[i].y:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
158 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
159 |
for i:= 0 to pred(FillPointsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
160 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
161 |
dec(FillPoints^[i].y, 100); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
162 |
if FillPoints^[i].y < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
163 |
FillPoints^[i].y:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
164 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
165 |
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
|
166 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
167 |
if (canFlip and (getrandom(2) = 0)) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
168 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
169 |
for i:= 0 to pred(BasePointsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
170 |
pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
171 |
for i:= 0 to pred(FillPointsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
172 |
FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
173 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
174 |
end |
4 | 175 |
end; |
67 | 176 |
|
364 | 177 |
|
23 | 178 |
procedure GenBlank(var Template: TEdgeTemplate); |
4 | 179 |
var pa: TPixAr; |
23 | 180 |
i: Longword; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
181 |
y, x: Longword; |
4 | 182 |
begin |
1773 | 183 |
for y:= 0 to LAND_HEIGHT - 1 do |
184 |
for x:= 0 to LAND_WIDTH - 1 do |
|
4458 | 185 |
Land[y, x]:= lfBasic; |
186 |
{$HINTS OFF} |
|
187 |
SetPoints(Template, pa); |
|
188 |
{$HINTS ON} |
|
189 |
for i:= 1 to Template.BezierizeCount do |
|
190 |
begin |
|
191 |
BezierizeEdge(pa, _0_5); |
|
192 |
RandomizePoints(pa); |
|
193 |
RandomizePoints(pa) |
|
194 |
end; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
195 |
for i:= 1 to Template.RandPassesCount do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
196 |
RandomizePoints(pa); |
4458 | 197 |
BezierizeEdge(pa, _0_1); |
198 |
||
199 |
||
200 |
DrawEdge(pa, 0); |
|
201 |
||
202 |
with Template do |
|
203 |
for i:= 0 to pred(FillPointsCount) do |
|
204 |
with FillPoints^[i] do |
|
205 |
FillLand(x, y); |
|
206 |
||
207 |
DrawEdge(pa, lfBasic); |
|
208 |
||
209 |
MaxHedgehogs:= Template.MaxHedgehogs; |
|
210 |
hasGirders:= Template.hasGirders; |
|
211 |
playHeight:= Template.TemplateHeight; |
|
212 |
playWidth:= Template.TemplateWidth; |
|
213 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
|
214 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
215 |
topY:= LAND_HEIGHT - playHeight; |
|
216 |
||
217 |
// HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
218 |
if (cTemplateFilter = 4) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
219 |
or (Template.canInvert and (getrandom(2) = 0)) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
220 |
or (not Template.canInvert and Template.isNegative) then |
4458 | 221 |
begin |
222 |
hasBorder:= true; |
|
223 |
for y:= 0 to LAND_HEIGHT - 1 do |
|
224 |
for x:= 0 to LAND_WIDTH - 1 do |
|
225 |
if (y < topY) or (x < leftX) or (x > rightX) then |
|
226 |
Land[y, x]:= 0 |
|
227 |
else |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
228 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
229 |
if Land[y, x] = 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
230 |
Land[y, x]:= lfBasic |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
231 |
else if Land[y, x] = lfBasic then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
232 |
Land[y, x]:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
233 |
end; |
4458 | 234 |
end; |
23 | 235 |
end; |
236 |
||
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
237 |
procedure GenDrawnMap; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
238 |
begin |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
239 |
uLandPainted.Draw; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
240 |
|
4559 | 241 |
MaxHedgehogs:= 48; |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
242 |
hasGirders:= true; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
243 |
playHeight:= 2048; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
244 |
playWidth:= 4096; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
245 |
leftX:= ((LAND_WIDTH - playWidth) div 2); |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
246 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
247 |
topY:= LAND_HEIGHT - playHeight; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
248 |
end; |
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
249 |
|
371 | 250 |
function SelectTemplate: LongInt; |
161 | 251 |
begin |
3612
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
case cTemplateFilter of |
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
|
256 |
0: SelectTemplate:= getrandom(Succ(High(EdgeTemplates))); |
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
|
257 |
1: 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
|
258 |
2: SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))]; |
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
|
259 |
3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))]; |
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
|
260 |
4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))]; |
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
|
261 |
5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))]; |
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
|
262 |
end; |
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
263 |
|
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
|
264 |
WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); |
161 | 265 |
end; |
266 |
||
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
267 |
procedure LandSurface2LandPixels(Surface: PSDL_Surface); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
268 |
var x, y: LongInt; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
269 |
p: PLongwordArray; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
270 |
begin |
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
271 |
TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true); |
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
272 |
|
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
273 |
if SDL_MustLock(Surface) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
274 |
SDLTry(SDL_LockSurface(Surface) >= 0, true); |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
275 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
276 |
p:= Surface^.pixels; |
1760 | 277 |
for y:= 0 to LAND_HEIGHT - 1 do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
278 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
279 |
for x:= 0 to LAND_WIDTH - 1 do |
3598 | 280 |
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
|
281 |
if (cReducedQuality and rqBlurryLand) = 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
|
282 |
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
|
283 |
else |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
284 |
LandPixels[y div 2, x div 2]:= p^[x] or AMask; |
2376 | 285 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
286 |
p:= @(p^[Surface^.pitch div 4]); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
287 |
end; |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1085
diff
changeset
|
288 |
|
1182
e2e13aa055c1
Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents:
1181
diff
changeset
|
289 |
if SDL_MustLock(Surface) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
290 |
SDL_UnlockSurface(Surface); |
1754 | 291 |
end; |
292 |
||
3133 | 293 |
|
1754 | 294 |
procedure GenLandSurface; |
295 |
var tmpsurf: PSDL_Surface; |
|
5225 | 296 |
x,y: Longword; |
1754 | 297 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
298 |
WriteLnToConsole('Generating land...'); |
3133 | 299 |
case cMapGen of |
300 |
0: GenBlank(EdgeTemplates[SelectTemplate]); |
|
301 |
1: GenMaze; |
|
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
302 |
2: GenDrawnMap; |
4562 | 303 |
else |
304 |
OutError('Unknown mapgen', true); |
|
3133 | 305 |
end; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
306 |
AddProgress(); |
1754 | 307 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
308 |
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0); |
1754 | 309 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
310 |
TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
311 |
ColorizeLand(tmpsurf); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
312 |
AddOnLandObjects(tmpsurf); |
1754 | 313 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
314 |
LandSurface2LandPixels(tmpsurf); |
5227 | 315 |
SDL_FreeSurface(tmpsurf); |
5274 | 316 |
for x:= leftX+2 to rightX-2 do |
317 |
for y:= topY+2 to LAND_HEIGHT-3 do |
|
318 |
if (Land[y, x] = 0) and |
|
319 |
(((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
|
320 |
((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |
|
321 |
begin |
|
322 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
323 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
324 |
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
|
325 |
LandPixels[y, x]:= LandPixels[y, x-1] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
326 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
327 |
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
|
328 |
LandPixels[y, x]:= LandPixels[y, x+1] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
329 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
330 |
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
|
331 |
LandPixels[y, x]:= LandPixels[y-1, x] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
332 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
333 |
else if (Land[y+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
|
334 |
LandPixels[y, x]:= LandPixels[y+1, x]; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
335 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
336 |
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
|
337 |
LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
5274 | 338 |
end; |
339 |
Land[y,x]:= lfObject |
|
340 |
end |
|
341 |
else if (Land[y, x] = 0) and |
|
342 |
(((Land[y, x-1] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
|
343 |
((Land[y, x-1] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
|
344 |
((Land[y, x+1] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
|
345 |
((Land[y, x+1] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
|
346 |
((Land[y+1, x] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
|
347 |
((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
|
348 |
((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or |
|
349 |
((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
350 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
351 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
352 |
|
5274 | 353 |
if (cReducedQuality and rqBlurryLand) = 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
|
354 |
|
5274 | 355 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
356 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
357 |
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
|
358 |
LandPixels[y, x]:= LandPixels[y, x-1] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
359 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
360 |
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
|
361 |
LandPixels[y, x]:= LandPixels[y, x+1] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
362 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
363 |
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
|
364 |
LandPixels[y, x]:= LandPixels[y+1, x] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
365 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
366 |
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
|
367 |
LandPixels[y, x]:= LandPixels[y-1, x]; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
368 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
369 |
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
|
370 |
LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
5274 | 371 |
end; |
372 |
Land[y,x]:= lfObject |
|
373 |
end; |
|
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
374 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
375 |
AddProgress(); |
1754 | 376 |
end; |
377 |
||
378 |
procedure MakeFortsMap; |
|
379 |
var tmpsurf: PSDL_Surface; |
|
380 |
begin |
|
2866 | 381 |
MaxHedgehogs:= 32; |
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
|
382 |
// 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 | 383 |
playHeight:= 1200; |
2096 | 384 |
playWidth:= 2560; |
1776 | 385 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
386 |
rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1); |
|
387 |
topY:= LAND_HEIGHT - playHeight; |
|
388 |
||
1754 | 389 |
WriteLnToConsole('Generating forts land...'); |
390 |
||
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
|
391 |
tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifTransparent or ifIgnoreCaps); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
392 |
if tmpsurf = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
393 |
tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1784 | 394 |
BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
1754 | 395 |
SDL_FreeSurface(tmpsurf); |
396 |
||
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
|
397 |
tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
398 |
if tmpsurf = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
399 |
tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1784 | 400 |
BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
1754 | 401 |
SDL_FreeSurface(tmpsurf); |
402 |
end; |
|
403 |
||
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
|
404 |
// Loads Land[] from an image, allowing overriding standard collision |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
405 |
procedure LoadMask(mapName: shortstring); |
1792 | 406 |
var tmpsurf: PSDL_Surface; |
407 |
p: PLongwordArray; |
|
408 |
x, y, cpX, cpY: Longword; |
|
409 |
begin |
|
5770 | 410 |
tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
411 |
if tmpsurf = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
412 |
tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
5770 | 413 |
if tmpsurf = nil then |
414 |
begin |
|
415 |
mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
|
416 |
tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
417 |
if tmpsurf = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
418 |
tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
5770 | 419 |
end; |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
420 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
421 |
|
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
422 |
if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) 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
|
423 |
begin |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
424 |
disableLandBack:= true; |
2376 | 425 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
426 |
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
|
427 |
cpY:= LAND_HEIGHT - tmpsurf^.h; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
428 |
if SDL_MustLock(tmpsurf) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
429 |
SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
430 |
|
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
431 |
p:= tmpsurf^.pixels; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
432 |
for y:= 0 to Pred(tmpsurf^.h) do |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
433 |
begin |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
434 |
for x:= 0 to Pred(tmpsurf^.w) do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
435 |
begin |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
436 |
if ((AMask and p^[x]) = 0) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
437 |
Land[cpY + y, cpX + x]:= 0 |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
438 |
else if p^[x] = $FFFFFFFF then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
439 |
Land[cpY + y, cpX + x]:= lfObject |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
440 |
else if p^[x] = (AMask or RMask) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
441 |
Land[cpY + y, cpX + x]:= lfIndestructible |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
442 |
else if p^[x] = AMask then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
443 |
begin |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
444 |
Land[cpY + y, cpX + x]:= lfBasic; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
445 |
disableLandBack:= false |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
446 |
end |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
447 |
else if p^[x] = (AMask or BMask) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
448 |
Land[cpY + y, cpX + x]:= lfObject or lfIce |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
449 |
end; |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
450 |
p:= @(p^[tmpsurf^.pitch div 4]); |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
451 |
end; |
2243
b4764993f833
additional touch support and nemo's reduced land array size
koda
parents:
2240
diff
changeset
|
452 |
|
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
453 |
if SDL_MustLock(tmpsurf) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
454 |
SDL_UnlockSurface(tmpsurf); |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
455 |
if not disableLandBack then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
456 |
begin |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
457 |
// freed in freeModule() below |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
458 |
LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
459 |
if LandBackSurface = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
460 |
LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
461 |
if (LandBackSurface <> nil) and cGrayScale then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
462 |
Surface2GrayScale(LandBackSurface) |
6096
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
463 |
end; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
464 |
end; |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
465 |
if (tmpsurf <> nil) then |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
466 |
SDL_FreeSurface(tmpsurf); |
a00dbbf49d6c
Add landbacktex to a few maps, just to see how it looks.
nemo
parents:
6082
diff
changeset
|
467 |
tmpsurf:= nil; |
1792 | 468 |
end; |
469 |
||
1754 | 470 |
procedure LoadMap; |
471 |
var tmpsurf: PSDL_Surface; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
472 |
s: shortstring; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
473 |
f: textfile; |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
474 |
mapName: shortstring = ''; |
1754 | 475 |
begin |
2981 | 476 |
isMap:= true; |
1754 | 477 |
WriteLnToConsole('Loading land from file...'); |
478 |
AddProgress; |
|
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
|
479 |
tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
480 |
if tmpsurf = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
481 |
tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
3912
e11df2de6af2
have engine try for a second position when map loading fails (in this way it's possible to move Missions data to any path)
koda
parents:
3836
diff
changeset
|
482 |
if tmpsurf = nil then |
5770 | 483 |
begin |
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
|
484 |
mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
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
|
485 |
tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
486 |
if tmpsurf = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
487 |
tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
5770 | 488 |
end; |
1760 | 489 |
TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); |
1754 | 490 |
|
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
|
491 |
// unC0Rr - should this be passed from the GUI? I am not sure which layer does what |
5241 | 492 |
s:= UserPathz[ptMapCurrent] + '/map.cfg'; |
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 not FileExists(s) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
494 |
s:= Pathz[ptMapCurrent] + '/map.cfg'; |
1792 | 495 |
WriteLnToConsole('Fetching map HH limit'); |
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
|
496 |
{$I-} |
1792 | 497 |
Assign(f, s); |
2747 | 498 |
filemode:= 0; // readonly |
1792 | 499 |
Reset(f); |
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
|
500 |
if IOResult <> 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
|
501 |
begin |
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
|
502 |
s:= Pathz[ptMissionMaps] + '/' + mapName + '/map.cfg'; |
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
|
503 |
Assign(f, s); |
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
|
504 |
Reset(f); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
505 |
end; |
1795 | 506 |
Readln(f); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
507 |
if not eof(f) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
508 |
Readln(f, MaxHedgehogs); |
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
|
509 |
{$I+} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
510 |
if (MaxHedgehogs = 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
511 |
MaxHedgehogs:= 18; |
1792 | 512 |
|
1776 | 513 |
playHeight:= tmpsurf^.h; |
514 |
playWidth:= tmpsurf^.w; |
|
515 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
|
516 |
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
517 |
topY:= LAND_HEIGHT - playHeight; |
|
518 |
||
1754 | 519 |
TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true); |
520 |
||
1772 | 521 |
BlitImageAndGenerateCollisionInfo( |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
522 |
(LAND_WIDTH - tmpsurf^.w) div 2, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
523 |
LAND_HEIGHT - tmpsurf^.h, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
524 |
tmpsurf^.w, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
525 |
tmpsurf); |
1754 | 526 |
SDL_FreeSurface(tmpsurf); |
1792 | 527 |
|
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
528 |
LoadMask(mapname); |
1754 | 529 |
end; |
530 |
||
5717 | 531 |
procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD |
5832
f730c8a9777b
Remove some unused variables and options.inc which uFloat doesn't use, probably should never use, and was getting in the way of my testcase - but most importantly, remove the inline on hwSqrt which was causing very bad math on my compiler/machine. We may have to remove more inlining. A pity.
nemo
parents:
5775
diff
changeset
|
532 |
var x, w, c: Longword; |
5717 | 533 |
begin |
5718
e74de0528ef4
Let's draw the bottom border thicker, so it is more visible
nemo
parents:
5717
diff
changeset
|
534 |
for w:= 0 to 23 do |
5717 | 535 |
for x:= leftX to rightX do |
536 |
begin |
|
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
5832
diff
changeset
|
537 |
Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible; |
5717 | 538 |
if (x + w) mod 32 < 16 then |
539 |
c:= AMask |
|
540 |
else |
|
541 |
c:= AMask or RMask or GMask; // FF00FFFF |
|
542 |
||
543 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
5832
diff
changeset
|
544 |
LandPixels[Longword(cWaterLine) - 1 - w, x]:= c |
5717 | 545 |
else |
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
5832
diff
changeset
|
546 |
LandPixels[(Longword(cWaterLine) - 1 - w) div 2, x div 2]:= c |
5718
e74de0528ef4
Let's draw the bottom border thicker, so it is more visible
nemo
parents:
5717
diff
changeset
|
547 |
end |
5717 | 548 |
end; |
549 |
||
1754 | 550 |
procedure GenMap; |
1784 | 551 |
var x, y, w, c: Longword; |
1754 | 552 |
begin |
3463 | 553 |
hasBorder:= false; |
2891
e1f902eb0cfe
Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents:
2866
diff
changeset
|
554 |
|
3463 | 555 |
LoadThemeConfig; |
556 |
isMap:= false; |
|
3697 | 557 |
|
4900 | 558 |
// is this not needed any more? lets hope setlength sets also 0s |
3630 | 559 |
//if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then |
560 |
// FillChar(Land,SizeOf(TCollisionArray),0);*) |
|
3697 | 561 |
|
3463 | 562 |
if (GameFlags and gfForts) = 0 then |
563 |
if Pathz[ptMapCurrent] <> '' then |
|
564 |
LoadMap |
|
565 |
else |
|
566 |
GenLandSurface |
|
567 |
else |
|
568 |
MakeFortsMap; |
|
569 |
||
570 |
AddProgress; |
|
1760 | 571 |
|
1768 | 572 |
// check for land near top |
1784 | 573 |
c:= 0; |
574 |
if (GameFlags and gfBorder) <> 0 then |
|
575 |
hasBorder:= true |
|
576 |
else |
|
577 |
for y:= topY to topY + 5 do |
|
578 |
for x:= leftX to rightX do |
|
579 |
if Land[y, x] <> 0 then |
|
580 |
begin |
|
581 |
inc(c); |
|
582 |
if c > 200 then // avoid accidental triggering |
|
583 |
begin |
|
584 |
hasBorder:= true; |
|
585 |
break; |
|
586 |
end; |
|
587 |
end; |
|
1768 | 588 |
|
1776 | 589 |
if hasBorder then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
590 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
591 |
for y:= 0 to LAND_HEIGHT - 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
592 |
for x:= 0 to LAND_WIDTH - 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
593 |
if (y < topY) or (x < leftX) or (x > rightX) then |
3519 | 594 |
Land[y, x]:= lfIndestructible; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
595 |
// experiment hardcoding cave |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
596 |
// also try basing cave dimensions on map/template dimensions, if they exist |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
597 |
for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
598 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
599 |
for y:= topY to LAND_HEIGHT - 1 do |
5717 | 600 |
begin |
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
|
601 |
Land[y, leftX + w]:= lfIndestructible; |
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
|
602 |
Land[y, rightX - w]:= lfIndestructible; |
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
|
603 |
if (y + w) mod 32 < 16 then |
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
|
604 |
c:= AMask |
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
|
605 |
else |
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
|
606 |
c:= AMask or RMask or GMask; // FF00FFFF |
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
|
607 |
|
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
|
608 |
if (cReducedQuality and rqBlurryLand) = 0 then |
5717 | 609 |
begin |
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
|
610 |
LandPixels[y, leftX + w]:= c; |
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
|
611 |
LandPixels[y, rightX - w]:= c; |
5717 | 612 |
end |
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
|
613 |
else |
5717 | 614 |
begin |
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
|
615 |
LandPixels[y div 2, (leftX + w) div 2]:= c; |
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
|
616 |
LandPixels[y div 2, (rightX - w) div 2]:= c; |
5717 | 617 |
end; |
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
|
618 |
end; |
1768 | 619 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
620 |
for x:= leftX to rightX do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
621 |
begin |
5717 | 622 |
Land[topY + w, x]:= lfIndestructible; |
623 |
if (x + w) mod 32 < 16 then |
|
624 |
c:= AMask |
|
625 |
else |
|
626 |
c:= AMask or RMask or GMask; // FF00FFFF |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3551
diff
changeset
|
627 |
|
5717 | 628 |
if (cReducedQuality and rqBlurryLand) = 0 then |
629 |
LandPixels[topY + w, x]:= c |
|
630 |
else |
|
631 |
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
|
632 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
633 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
634 |
end; |
1768 | 635 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
636 |
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
|
637 |
DrawBottomBorder; |
5717 | 638 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
639 |
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
|
640 |
hasGirders:= false; |
2891
e1f902eb0cfe
Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents:
2866
diff
changeset
|
641 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
642 |
if ((GameFlags and gfForts) = 0) and (Pathz[ptMapCurrent] = '') then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
643 |
AddObjects |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
644 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
645 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
646 |
AddProgress(); |
1776 | 647 |
|
3058 | 648 |
FreeLandObjects; |
649 |
||
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
650 |
if cGrayScale then |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
651 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
652 |
if (cReducedQuality and rqBlurryLand) = 0 then |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
653 |
for x:= leftX to rightX do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
654 |
for y:= topY to LAND_HEIGHT-1 do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
655 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
656 |
w:= LandPixels[y,x]; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
657 |
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
|
658 |
(w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
659 |
(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
|
660 |
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
|
661 |
w:= 255; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
662 |
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
|
663 |
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
|
664 |
end |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
665 |
else |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
666 |
for x:= leftX div 2 to rightX div 2 do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
667 |
for y:= topY div 2 to LAND_HEIGHT-1 div 2 do |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
668 |
begin |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
669 |
w:= LandPixels[y div 2,x div 2]; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
670 |
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
|
671 |
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
|
672 |
w:= 255; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
673 |
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
|
674 |
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
|
675 |
end |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
676 |
end; |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5274
diff
changeset
|
677 |
|
1807 | 678 |
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT); |
37 | 679 |
end; |
680 |
||
566 | 681 |
function GenPreview: TPreview; |
3617 | 682 |
var x, y, xx, yy, t, bit, cbit, lh, lw: LongInt; |
566 | 683 |
Preview: TPreview; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
684 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
685 |
WriteLnToConsole('Generating preview...'); |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
686 |
case cMapGen of |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
687 |
0: GenBlank(EdgeTemplates[SelectTemplate]); |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
688 |
1: GenMaze; |
4494
9585435e20f7
Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents:
4458
diff
changeset
|
689 |
2: GenDrawnMap; |
4562 | 690 |
else |
691 |
OutError('Unknown mapgen', true); |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
692 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
693 |
|
3617 | 694 |
lh:= LAND_HEIGHT div 128; |
695 |
lw:= LAND_WIDTH div 32; |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
696 |
for y:= 0 to 127 do |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
697 |
for x:= 0 to 31 do |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
698 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
699 |
Preview[y, x]:= 0; |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
700 |
for bit:= 0 to 7 do |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
701 |
begin |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
702 |
t:= 0; |
3617 | 703 |
cbit:= bit * 8; |
704 |
for yy:= y * lh to y * lh + 7 do |
|
705 |
for xx:= x * lw + cbit to x * lw + cbit + 7 do |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
706 |
if Land[yy, xx] <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6491
diff
changeset
|
707 |
inc(t); |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
708 |
if t > 8 then |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
709 |
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
|
710 |
end; |
566 | 711 |
end; |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
712 |
|
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3287
diff
changeset
|
713 |
GenPreview:= Preview |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
714 |
end; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
715 |
|
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
|
716 |
|
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
|
717 |
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
|
718 |
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
|
719 |
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
|
720 |
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
|
721 |
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
|
722 |
else |
6025
cac1d5601d7c
reviewed the build system and parts of the previous merge, performed some code cleanup
koda
parents:
6023
diff
changeset
|
723 |
TryDo(s = digest, 'Different maps generated, sorry', true); |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
724 |
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
|
725 |
|
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
|
726 |
procedure chSendLandDigest(var s: shortstring); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
727 |
var adler, i: LongInt; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
728 |
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
|
729 |
adler:= 1; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
730 |
for i:= 0 to LAND_HEIGHT-1 do |
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
|
731 |
Adler32Update(adler, @Land[i,0], LAND_WIDTH); |
6254
e90fb60cb46d
Force a desync if there is a script name mismatch. This avoids playing until the game desyncs due to script differences.
nemo
parents:
6096
diff
changeset
|
732 |
s:= 'M' + IntToStr(adler) + cScriptName; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
733 |
|
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
|
734 |
chLandCheck(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
|
735 |
SendIPCRaw(@s[0], Length(s) + 1) |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4389
diff
changeset
|
736 |
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
|
737 |
|
3038 | 738 |
procedure initModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
739 |
begin |
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
|
740 |
RegisterVariable('landcheck', vtCommand, @chLandCheck, false); |
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
|
741 |
RegisterVariable('sendlanddigest', vtCommand, @chSendLandDigest, false); |
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
|
742 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
743 |
LandBackSurface:= nil; |
3369
c7289e42f0ee
add other controls for map preview, also fix a bug in digest
koda
parents:
3365
diff
changeset
|
744 |
digest:= ''; |
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
|
745 |
|
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
|
746 |
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
|
747 |
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
|
748 |
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
|
749 |
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
|
750 |
|
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
|
751 |
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
|
752 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
753 |
end; |
51 | 754 |
|
3038 | 755 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
756 |
begin |
3612
b50215a8a43d
land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents:
3608
diff
changeset
|
757 |
Land:= nil; |
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
|
758 |
LandPixels:= nil; |
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
|
759 |
LandDirty:= nil; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
760 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2692
diff
changeset
|
761 |
|
4 | 762 |
end. |