author | koda |
Wed, 08 Dec 2010 14:47:52 +0100 | |
changeset 4476 | 4bf74e158f44 |
parent 4403 | 0dfe26f48ec1 |
child 4634 | 784e2df9e79a |
permissions | -rw-r--r-- |
393 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
3236
4ab3917d7d44
Update (c) lines to 2010 as unc0rr requested - they all had varying values so I just took the first year mentioned, then tacked on -2010
nemo
parents:
2981
diff
changeset
|
3 |
* Copyright (c) 2005-2010 Andrey Korotaev <unC0Rr@gmail.com> |
393 | 4 |
* |
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 |
|
8 |
* |
|
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. |
|
13 |
* |
|
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 |
|
17 |
*) |
|
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
184 | 21 |
unit uLandGraphics; |
22 |
interface |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
3749
diff
changeset
|
23 |
uses uFloat, uConsts, uTypes; |
184 | 24 |
|
25 |
type PRangeArray = ^TRangeArray; |
|
26 |
TRangeArray = array[0..31] of record |
|
371 | 27 |
Left, Right: LongInt; |
184 | 28 |
end; |
29 |
||
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2695
diff
changeset
|
30 |
function SweepDirty: boolean; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2695
diff
changeset
|
31 |
function Despeckle(X, Y: LongInt): boolean; |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
32 |
function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; |
4377 | 33 |
function DrawExplosion(X, Y, Radius: LongInt): Longword; |
371 | 34 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
35 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
|
36 |
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
|
511 | 37 |
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
4367 | 38 |
function LandBackPixel(x, y: LongInt): LongWord; |
184 | 39 |
|
520 | 40 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
409 | 41 |
|
184 | 42 |
implementation |
4403 | 43 |
uses SDLh, uLandTexture, uVariables, uUtils, uDebug; |
184 | 44 |
|
371 | 45 |
procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword); |
46 |
var i: LongInt; |
|
184 | 47 |
begin |
1753 | 48 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
4374 | 49 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3519 | 50 |
if (Land[y + dy, i] and lfIndestructible) = 0 then |
1753 | 51 |
Land[y + dy, i]:= Value; |
52 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
|
4374 | 53 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3519 | 54 |
if (Land[y - dy, i] and lfIndestructible) = 0 then |
1753 | 55 |
Land[y - dy, i]:= Value; |
56 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
|
4374 | 57 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3519 | 58 |
if (Land[y + dx, i] and lfIndestructible) = 0 then |
1753 | 59 |
Land[y + dx, i]:= Value; |
60 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
|
4374 | 61 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3519 | 62 |
if (Land[y - dx, i] and lfIndestructible) = 0 then |
1753 | 63 |
Land[y - dx, i]:= Value; |
184 | 64 |
end; |
65 |
||
511 | 66 |
procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
67 |
var i: LongInt; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
68 |
begin |
511 | 69 |
if not doSet then |
70 |
begin |
|
1753 | 71 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
4374 | 72 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
1861 | 73 |
if (Land[y + dy, i] > 0) and (Land[y + dy, i] < 256) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data |
1753 | 74 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
4374 | 75 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
1861 | 76 |
if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then dec(Land[y - dy, i]); |
1753 | 77 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
4374 | 78 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
1861 | 79 |
if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then dec(Land[y + dx, i]); |
1753 | 80 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
4374 | 81 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
1861 | 82 |
if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then dec(Land[y - dx, i]); |
511 | 83 |
end else |
84 |
begin |
|
1753 | 85 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
4374 | 86 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
87 |
if (Land[y + dy, i] < 256) then |
1861 | 88 |
inc(Land[y + dy, i]); |
1753 | 89 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
4374 | 90 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
91 |
if (Land[y - dy, i] < 256) then |
1861 | 92 |
inc(Land[y - dy, i]); |
1753 | 93 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
4374 | 94 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
95 |
if (Land[y + dx, i] < 256) then |
1861 | 96 |
inc(Land[y + dx, i]); |
1753 | 97 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
4374 | 98 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
99 |
if (Land[y - dx, i] < 256) then |
1861 | 100 |
inc(Land[y - dx, i]); |
511 | 101 |
end |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
102 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
103 |
|
371 | 104 |
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
105 |
var dx, dy, d: LongInt; |
|
184 | 106 |
begin |
107 |
dx:= 0; |
|
108 |
dy:= Radius; |
|
109 |
d:= 3 - 2 * Radius; |
|
110 |
while (dx < dy) do |
|
111 |
begin |
|
112 |
FillCircleLines(x, y, dx, dy, Value); |
|
113 |
if (d < 0) |
|
114 |
then d:= d + 4 * dx + 6 |
|
115 |
else begin |
|
116 |
d:= d + 4 * (dx - dy) + 10; |
|
117 |
dec(dy) |
|
118 |
end; |
|
119 |
inc(dx) |
|
120 |
end; |
|
121 |
if (dx = dy) then FillCircleLines(x, y, dx, dy, Value); |
|
122 |
end; |
|
123 |
||
511 | 124 |
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
125 |
var dx, dy, d: LongInt; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
126 |
begin |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
127 |
dx:= 0; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
128 |
dy:= Radius; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
129 |
d:= 3 - 2 * Radius; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
130 |
while (dx < dy) do |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
131 |
begin |
511 | 132 |
ChangeCircleLines(x, y, dx, dy, doSet); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
133 |
if (d < 0) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
134 |
then d:= d + 4 * dx + 6 |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
135 |
else begin |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
136 |
d:= d + 4 * (dx - dy) + 10; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
137 |
dec(dy) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
138 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
139 |
inc(dx) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
140 |
end; |
511 | 141 |
if (dx = dy) then ChangeCircleLines(x, y, dx, dy, doSet) |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
142 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
143 |
|
2603 | 144 |
procedure FillLandCircleLines0(x, y, dx, dy: LongInt); |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
145 |
var i, t: LongInt; |
184 | 146 |
begin |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
147 |
t:= y + dy; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
148 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 149 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
150 |
if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 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:
3554
diff
changeset
|
151 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
152 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
153 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
154 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
155 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
156 |
t:= y - dy; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
157 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 158 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
159 |
if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 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:
3554
diff
changeset
|
160 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
161 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
162 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
163 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
164 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
165 |
t:= y + dx; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
166 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 167 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
168 |
if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 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:
3554
diff
changeset
|
169 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
170 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
171 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
172 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
173 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
174 |
t:= y - dx; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
175 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 176 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
177 |
if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 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:
3554
diff
changeset
|
178 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
179 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
180 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
181 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
182 |
|
184 | 183 |
end; |
184 |
||
3689 | 185 |
function FillLandCircleLinesBG(x, y, dx, dy: LongInt): Longword; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
186 |
var i, t: LongInt; |
3689 | 187 |
cnt: Longword; |
2647 | 188 |
begin |
3689 | 189 |
cnt:= 0; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
190 |
t:= y + dy; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
191 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 192 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
193 |
if ((Land[t, i] and lfBasic) <> 0) then |
3689 | 194 |
begin |
195 |
inc(cnt); |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
196 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
197 |
LandPixels[t, i]:= LandBackPixel(i, t) |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
198 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
199 |
LandPixels[t div 2, i div 2]:= LandBackPixel(i, t) |
3689 | 200 |
end |
2647 | 201 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
202 |
if ((Land[t, i] and lfObject) <> 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:
3554
diff
changeset
|
203 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
204 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
205 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
206 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
207 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
208 |
t:= y - dy; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
209 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 210 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
211 |
if ((Land[t, i] and lfBasic) <> 0) then |
3689 | 212 |
begin |
213 |
inc(cnt); |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
214 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
215 |
LandPixels[t, i]:= LandBackPixel(i, t) |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
216 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
217 |
LandPixels[t div 2, i div 2]:= LandBackPixel(i, t) |
3689 | 218 |
end |
2647 | 219 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
220 |
if ((Land[t, i] and lfObject) <> 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:
3554
diff
changeset
|
221 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
222 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
223 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
224 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
225 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
226 |
t:= y + dx; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
227 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 228 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
229 |
if ((Land[t, i] and lfBasic) <> 0) then |
3689 | 230 |
begin |
231 |
inc(cnt); |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
232 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
233 |
LandPixels[t, i]:= LandBackPixel(i, t) |
3697 | 234 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
235 |
LandPixels[t div 2, i div 2]:= LandBackPixel(i, t) |
3689 | 236 |
end |
2647 | 237 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
238 |
if ((Land[t, i] and lfObject) <> 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:
3554
diff
changeset
|
239 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
240 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
241 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
242 |
LandPixels[t div 2, i div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
243 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
244 |
t:= y - dx; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
245 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 246 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
247 |
if ((Land[t, i] and lfBasic) <> 0) then |
3689 | 248 |
begin |
249 |
inc(cnt); |
|
250 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
251 |
LandPixels[t, i]:= LandBackPixel(i, t) |
|
3697 | 252 |
else |
3689 | 253 |
LandPixels[t div 2, i div 2]:= LandBackPixel(i, t) |
254 |
end |
|
2647 | 255 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
256 |
if ((Land[t, i] and lfObject) <> 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:
3554
diff
changeset
|
257 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
258 |
LandPixels[t, i]:= 0 |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
259 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
260 |
LandPixels[t div 2, i div 2]:= 0; |
3689 | 261 |
FillLandCircleLinesBG:= cnt; |
2647 | 262 |
end; |
263 |
||
371 | 264 |
procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt); |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
265 |
var i, t: LongInt; |
184 | 266 |
begin |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
267 |
t:= y + dy; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
268 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 269 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
270 |
if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
271 |
begin |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
272 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
273 |
LandPixels[t, i]:= cExplosionBorderColor |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
274 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
275 |
LandPixels[t div 2, i div 2]:= cExplosionBorderColor; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
276 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
277 |
Land[t, i]:= Land[t, i] or lfDamaged; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
278 |
//Despeckle(i, t); |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
279 |
LandDirty[t div 32, i div 32]:= 1; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
280 |
end; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
281 |
|
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
282 |
t:= y - dy; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
283 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 284 |
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
285 |
if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
286 |
begin |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
287 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3697 | 288 |
LandPixels[t, i]:= cExplosionBorderColor |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
289 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
290 |
LandPixels[t div 2, i div 2]:= cExplosionBorderColor; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
291 |
Land[t, i]:= Land[t, i] or lfDamaged; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
292 |
//Despeckle(i, t); |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
293 |
LandDirty[t div 32, i div 32]:= 1; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
294 |
end; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
295 |
|
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
296 |
t:= y + dx; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
297 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 298 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
299 |
if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
300 |
begin |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
301 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
302 |
LandPixels[t, i]:= cExplosionBorderColor |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
303 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
304 |
LandPixels[t div 2, i div 2]:= cExplosionBorderColor; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
305 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
306 |
Land[t, i]:= Land[t, i] or lfDamaged; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
307 |
//Despeckle(i, t); |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
308 |
LandDirty[t div 32, i div 32]:= 1; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
309 |
end; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
310 |
|
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
311 |
t:= y - dx; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
312 |
if (t and LAND_HEIGHT_MASK) = 0 then |
4374 | 313 |
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
314 |
if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
315 |
begin |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
316 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3697 | 317 |
LandPixels[t, i]:= cExplosionBorderColor |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
318 |
else |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
319 |
LandPixels[t div 2, i div 2]:= cExplosionBorderColor; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
320 |
|
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
321 |
Land[t, i]:= Land[t, i] or lfDamaged; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
322 |
//Despeckle(i, y - dy); |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
323 |
LandDirty[t div 32, i div 32]:= 1; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
324 |
end; |
184 | 325 |
end; |
326 |
||
3689 | 327 |
function DrawExplosion(X, Y, Radius: LongInt): Longword; |
2603 | 328 |
var dx, dy, ty, tx, d: LongInt; |
3689 | 329 |
cnt: Longword; |
184 | 330 |
begin |
2647 | 331 |
|
332 |
// draw background land texture |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
333 |
begin |
3689 | 334 |
cnt:= 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
335 |
dx:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
336 |
dy:= Radius; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
337 |
d:= 3 - 2 * Radius; |
2647 | 338 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
339 |
while (dx < dy) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
340 |
begin |
3689 | 341 |
inc(cnt, FillLandCircleLinesBG(x, y, dx, dy)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
342 |
if (d < 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
343 |
then d:= d + 4 * dx + 6 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
344 |
else begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
345 |
d:= d + 4 * (dx - dy) + 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
346 |
dec(dy) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
347 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
348 |
inc(dx) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
349 |
end; |
3689 | 350 |
if (dx = dy) then inc(cnt, FillLandCircleLinesBG(x, y, dx, dy)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
351 |
end; |
2647 | 352 |
|
353 |
// draw a hole in land |
|
2733 | 354 |
if Radius > 20 then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
355 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
356 |
dx:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
357 |
dy:= Radius - 15; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
358 |
d:= 3 - 2 * dy; |
2647 | 359 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
360 |
while (dx < dy) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
361 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
362 |
FillLandCircleLines0(x, y, dx, dy); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
363 |
if (d < 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
364 |
then d:= d + 4 * dx + 6 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
365 |
else begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
366 |
d:= d + 4 * (dx - dy) + 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
367 |
dec(dy) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
368 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
369 |
inc(dx) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
370 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
371 |
if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
372 |
end; |
2647 | 373 |
|
1849 | 374 |
// FillRoundInLand after erasing land pixels to allow Land 0 check for mask.png to function |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
375 |
FillRoundInLand(X, Y, Radius, 0); |
2647 | 376 |
|
377 |
// draw explosion border |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
378 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
379 |
inc(Radius, 4); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
380 |
dx:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
381 |
dy:= Radius; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
382 |
d:= 3 - 2 * Radius; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
383 |
while (dx < dy) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
384 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
385 |
FillLandCircleLinesEBC(x, y, dx, dy); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
386 |
if (d < 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
387 |
then d:= d + 4 * dx + 6 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
388 |
else begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
389 |
d:= d + 4 * (dx - dy) + 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
390 |
dec(dy) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
391 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
392 |
inc(dx) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
393 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
394 |
if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
395 |
end; |
351 | 396 |
|
4374 | 397 |
tx:= Max(X - Radius - 1, 0); |
398 |
dx:= Min(X + Radius + 1, LAND_WIDTH) - tx; |
|
399 |
ty:= Max(Y - Radius - 1, 0); |
|
400 |
dy:= Min(Y + Radius + 1, LAND_HEIGHT) - ty; |
|
3689 | 401 |
UpdateLandTexture(tx, dx, ty, dy); |
402 |
DrawExplosion:= cnt |
|
184 | 403 |
end; |
404 |
||
371 | 405 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
184 | 406 |
var tx, ty, i: LongInt; |
407 |
begin |
|
408 |
for i:= 0 to Pred(Count) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
409 |
begin |
4374 | 410 |
for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do |
411 |
for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do |
|
3519 | 412 |
if (Land[ty, tx] and lfBasic) <> 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:
3554
diff
changeset
|
413 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
414 |
LandPixels[ty, tx]:= LandBackPixel(tx, ty) |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
415 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
416 |
LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty) |
3697 | 417 |
else |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
418 |
if (Land[ty, tx] and lfObject) <> 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
419 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
420 |
LandPixels[ty, tx]:= 0 |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
421 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
422 |
LandPixels[ty div 2, tx div 2]:= 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
423 |
inc(y, dY) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
424 |
end; |
184 | 425 |
|
426 |
inc(Radius, 4); |
|
351 | 427 |
dec(y, Count * dY); |
184 | 428 |
|
429 |
for i:= 0 to Pred(Count) do |
|
430 |
begin |
|
4374 | 431 |
for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do |
432 |
for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do |
|
3519 | 433 |
if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
434 |
begin |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
435 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
436 |
LandPixels[ty, tx]:= cExplosionBorderColor |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
437 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
438 |
LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor; |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
439 |
|
3519 | 440 |
Land[ty, tx]:= Land[ty, tx] or lfDamaged; |
3596 | 441 |
LandDirty[ty div 32, tx div 32]:= 1; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
442 |
end; |
184 | 443 |
inc(y, dY) |
444 |
end; |
|
445 |
||
818 | 446 |
|
1807 | 447 |
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT) |
184 | 448 |
end; |
449 |
||
450 |
// |
|
451 |
// - (dX, dY) - direction, vector of length = 0.5 |
|
452 |
// |
|
371 | 453 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
358 | 454 |
var nx, ny, dX8, dY8: hwFloat; |
1809 | 455 |
i, t, tx, ty, stX, stY, ddy, ddx: Longint; |
184 | 456 |
begin // (-dY, dX) is (dX, dY) rotated by PI/2 |
772
e8d530ca77be
Don't update all land texture when drawing tunnel (saves video throughput)
unc0rr
parents:
769
diff
changeset
|
457 |
stY:= hwRound(Y); |
1809 | 458 |
stX:= hwRound(X); |
772
e8d530ca77be
Don't update all land texture when drawing tunnel (saves video throughput)
unc0rr
parents:
769
diff
changeset
|
459 |
|
184 | 460 |
nx:= X + dY * (HalfWidth + 8); |
461 |
ny:= Y - dX * (HalfWidth + 8); |
|
462 |
||
358 | 463 |
dX8:= dX * 8; |
464 |
dY8:= dY * 8; |
|
184 | 465 |
for i:= 0 to 7 do |
466 |
begin |
|
358 | 467 |
X:= nx - dX8; |
468 |
Y:= ny - dY8; |
|
184 | 469 |
for t:= -8 to ticks + 8 do |
2666 | 470 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
471 |
X:= X + dX; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
472 |
Y:= Y + dY; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
473 |
tx:= hwRound(X); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
474 |
ty:= hwRound(Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
475 |
if ((ty and LAND_HEIGHT_MASK) = 0) and |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
476 |
((tx and LAND_WIDTH_MASK) = 0) and |
3697 | 477 |
(((Land[ty, tx] and lfBasic) <> 0) or |
3519 | 478 |
((Land[ty, tx] and lfObject) <> 0)) then |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
479 |
begin |
3519 | 480 |
Land[ty, tx]:= Land[ty, tx] or lfDamaged; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
481 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
482 |
LandPixels[ty, tx]:= cExplosionBorderColor |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
483 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
484 |
LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
485 |
end |
2666 | 486 |
end; |
184 | 487 |
nx:= nx - dY; |
488 |
ny:= ny + dX; |
|
489 |
end; |
|
490 |
||
491 |
for i:= -HalfWidth to HalfWidth do |
|
492 |
begin |
|
358 | 493 |
X:= nx - dX8; |
494 |
Y:= ny - dY8; |
|
184 | 495 |
for t:= 0 to 7 do |
2666 | 496 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
497 |
X:= X + dX; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
498 |
Y:= Y + dY; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
499 |
tx:= hwRound(X); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
500 |
ty:= hwRound(Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
501 |
if ((ty and LAND_HEIGHT_MASK) = 0) and |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
502 |
((tx and LAND_WIDTH_MASK) = 0) and |
3697 | 503 |
(((Land[ty, tx] and lfBasic) <> 0) or |
3519 | 504 |
((Land[ty, tx] and lfObject) <> 0)) then |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
505 |
begin |
3519 | 506 |
Land[ty, tx]:= Land[ty, tx] or lfDamaged; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
507 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
508 |
LandPixels[ty, tx]:= cExplosionBorderColor |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
509 |
else |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
510 |
LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
511 |
|
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
512 |
end |
2666 | 513 |
end; |
184 | 514 |
X:= nx; |
515 |
Y:= ny; |
|
516 |
for t:= 0 to ticks do |
|
517 |
begin |
|
518 |
X:= X + dX; |
|
519 |
Y:= Y + dY; |
|
351 | 520 |
tx:= hwRound(X); |
521 |
ty:= hwRound(Y); |
|
3519 | 522 |
if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then |
2647 | 523 |
begin |
3519 | 524 |
if (Land[ty, tx] and lfBasic) <> 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:
3554
diff
changeset
|
525 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
526 |
LandPixels[ty, tx]:= LandBackPixel(tx, ty) |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
527 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
528 |
LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty) |
3697 | 529 |
else |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
530 |
if (Land[ty, tx] and lfObject) <> 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
531 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
532 |
LandPixels[ty, tx]:= 0 |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
533 |
else |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
534 |
LandPixels[ty div 2, tx div 2]:= 0; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
535 |
|
2647 | 536 |
Land[ty, tx]:= 0; |
537 |
end |
|
184 | 538 |
end; |
539 |
for t:= 0 to 7 do |
|
2666 | 540 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
541 |
X:= X + dX; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
542 |
Y:= Y + dY; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
543 |
tx:= hwRound(X); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
544 |
ty:= hwRound(Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
545 |
if ((ty and LAND_HEIGHT_MASK) = 0) and |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
546 |
((tx and LAND_WIDTH_MASK) = 0) and |
3697 | 547 |
(((Land[ty, tx] and lfBasic) <> 0) or |
3519 | 548 |
((Land[ty, tx] and lfObject) <> 0)) then |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
549 |
begin |
3519 | 550 |
Land[ty, tx]:= Land[ty, tx] or lfDamaged; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
551 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
552 |
LandPixels[ty, tx]:= cExplosionBorderColor |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
553 |
else |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
554 |
LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
555 |
|
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
556 |
end |
2666 | 557 |
end; |
184 | 558 |
nx:= nx - dY; |
559 |
ny:= ny + dX; |
|
560 |
end; |
|
561 |
||
562 |
for i:= 0 to 7 do |
|
563 |
begin |
|
358 | 564 |
X:= nx - dX8; |
565 |
Y:= ny - dY8; |
|
184 | 566 |
for t:= -8 to ticks + 8 do |
2666 | 567 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
568 |
X:= X + dX; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
569 |
Y:= Y + dY; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
570 |
tx:= hwRound(X); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
571 |
ty:= hwRound(Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
572 |
if ((ty and LAND_HEIGHT_MASK) = 0) and |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
573 |
((tx and LAND_WIDTH_MASK) = 0) and |
3697 | 574 |
(((Land[ty, tx] and lfBasic) <> 0) or |
3519 | 575 |
((Land[ty, tx] and lfObject) <> 0)) then |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
576 |
begin |
3519 | 577 |
Land[ty, tx]:= Land[ty, tx] or lfDamaged; |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
578 |
if (cReducedQuality and rqBlurryLand) = 0 then |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
579 |
LandPixels[ty, tx]:= cExplosionBorderColor |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
580 |
else |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
581 |
LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor |
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
582 |
end |
2666 | 583 |
end; |
184 | 584 |
nx:= nx - dY; |
585 |
ny:= ny + dX; |
|
586 |
end; |
|
587 |
||
4374 | 588 |
tx:= Max(stX - HalfWidth * 2 - 4 - abs(hwRound(dX * ticks)), 0); |
589 |
ty:= Max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0); |
|
590 |
ddx:= Min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx; |
|
591 |
ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty; |
|
1809 | 592 |
|
593 |
UpdateLandTexture(tx, ddx, ty, ddy) |
|
184 | 594 |
end; |
595 |
||
520 | 596 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
2235 | 597 |
var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt; |
409 | 598 |
p: PByteArray; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
599 |
Image: PSDL_Surface; |
409 | 600 |
begin |
2235 | 601 |
numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height; |
602 |
||
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
603 |
TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true); |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
604 |
Image:= SpritesData[Obj].Surface; |
409 | 605 |
w:= SpritesData[Obj].Width; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
606 |
h:= SpritesData[Obj].Height; |
2235 | 607 |
row:= Frame mod numFramesFirstCol; |
608 |
col:= Frame div numFramesFirstCol; |
|
409 | 609 |
|
610 |
if SDL_MustLock(Image) then |
|
611 |
SDLTry(SDL_LockSurface(Image) >= 0, true); |
|
612 |
||
613 |
bpp:= Image^.format^.BytesPerPixel; |
|
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
614 |
TryDo(bpp = 4, 'It should be 32 bpp sprite', true); |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
615 |
// Check that sprite fits free space |
2236 | 616 |
p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); |
409 | 617 |
case bpp of |
618 |
4: for y:= 0 to Pred(h) do |
|
619 |
begin |
|
620 |
for x:= 0 to Pred(w) do |
|
621 |
if PLongword(@(p^[x * 4]))^ <> 0 then |
|
3749 | 622 |
if ((cpY + y) <= Longint(topY)) or |
623 |
((cpY + y) >= LAND_HEIGHT) or |
|
624 |
((cpX + x) <= Longint(leftX)) or |
|
625 |
((cpX + x) >= Longint(rightX)) or |
|
409 | 626 |
(Land[cpY + y, cpX + x] <> 0) then |
627 |
begin |
|
628 |
if SDL_MustLock(Image) then |
|
629 |
SDL_UnlockSurface(Image); |
|
630 |
exit(false) |
|
631 |
end; |
|
632 |
p:= @(p^[Image^.pitch]); |
|
633 |
end; |
|
634 |
end; |
|
635 |
||
520 | 636 |
TryPlaceOnLand:= true; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
637 |
if not doPlace then |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
638 |
begin |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
639 |
if SDL_MustLock(Image) then |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
640 |
SDL_UnlockSurface(Image); |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
641 |
exit |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
642 |
end; |
520 | 643 |
|
409 | 644 |
// Checked, now place |
2236 | 645 |
p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); |
409 | 646 |
case bpp of |
647 |
4: for y:= 0 to Pred(h) do |
|
648 |
begin |
|
649 |
for x:= 0 to Pred(w) do |
|
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
650 |
if PLongword(@(p^[x * 4]))^ <> 0 then |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
651 |
begin |
3519 | 652 |
Land[cpY + y, cpX + x]:= lfObject; |
3596 | 653 |
if (cReducedQuality and rqBlurryLand) = 0 then |
654 |
LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^ |
|
655 |
else |
|
656 |
LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^ |
|
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
657 |
end; |
409 | 658 |
p:= @(p^[Image^.pitch]); |
659 |
end; |
|
660 |
end; |
|
661 |
if SDL_MustLock(Image) then |
|
662 |
SDL_UnlockSurface(Image); |
|
663 |
||
4374 | 664 |
x:= Max(cpX, leftX); |
665 |
w:= Min(cpX + Image^.w, LAND_WIDTH) - x; |
|
666 |
y:= Max(cpY, topY); |
|
667 |
h:= Min(cpY + Image^.h, LAND_HEIGHT) - y; |
|
1807 | 668 |
UpdateLandTexture(x, w, y, h) |
409 | 669 |
end; |
670 |
||
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
671 |
// was experimenting with applying as damage occurred. |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
672 |
function Despeckle(X, Y: LongInt): boolean; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
673 |
var nx, ny, i, j, c: LongInt; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
674 |
begin |
3521
96a502730e81
Remove redundant test, add some temp variables to speed up the expensive CheckLand
nemo
parents:
3519
diff
changeset
|
675 |
if ((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0) then // check neighbours |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
676 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
677 |
c:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
678 |
for i:= -1 to 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
679 |
for j:= -1 to 1 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
680 |
if (i <> 0) or (j <> 0) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
681 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
682 |
ny:= Y + i; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
683 |
nx:= X + j; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
684 |
if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
685 |
if Land[ny, nx] > 255 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
686 |
inc(c); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
687 |
end; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
688 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
689 |
if c < 4 then // 0-3 neighbours |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
690 |
begin |
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
691 |
if (cReducedQuality and rqBlurryLand) = 0 then |
3697 | 692 |
if (Land[Y, X] and lfBasic) <> 0 then |
693 |
LandPixels[Y, X]:= LandBackPixel(X, Y) |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
694 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
695 |
LandPixels[Y, X]:= 0 |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
696 |
else |
3697 | 697 |
if (Land[Y, X] and lfBasic) <> 0 then |
698 |
LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y) |
|
3595
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
699 |
else |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
700 |
LandPixels[Y div 2, X div 2]:= 0; |
341e407e3754
partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents:
3554
diff
changeset
|
701 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
702 |
Land[Y, X]:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
703 |
exit(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
704 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
705 |
end; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
706 |
Despeckle:= false |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
707 |
end; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
708 |
|
1792 | 709 |
function SweepDirty: boolean; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
710 |
var x, y, xx, yy, ty, tx: LongInt; |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
711 |
bRes, updateBlock, resweep, recheck: boolean; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
712 |
begin |
2695 | 713 |
bRes:= false; |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
714 |
reCheck:= true; |
1792 | 715 |
|
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
716 |
while recheck do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
717 |
begin |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
718 |
recheck:= false; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
719 |
for y:= 0 to LAND_HEIGHT div 32 - 1 do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
720 |
begin |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
721 |
for x:= 0 to LAND_WIDTH div 32 - 1 do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
722 |
begin |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
723 |
if LandDirty[y, x] <> 0 then |
2167
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
724 |
begin |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
725 |
updateBlock:= false; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
726 |
resweep:= true; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
727 |
ty:= y * 32; |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
728 |
tx:= x * 32; |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
729 |
while(resweep) do |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
730 |
begin |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
731 |
resweep:= false; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
732 |
for yy:= ty to ty + 31 do |
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
733 |
for xx:= tx to tx + 31 do |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
734 |
if Despeckle(xx, yy) then |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
735 |
begin |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
736 |
bRes:= true; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
737 |
updateBlock:= true; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
738 |
resweep:= true; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
739 |
if (yy = ty) and (y > 0) then |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
740 |
begin |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
741 |
LandDirty[y-1, x]:= 1; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
742 |
recheck:= true; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
743 |
end |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
744 |
else if (yy = ty+31) and (y < LAND_HEIGHT div 32 - 1) then |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
745 |
begin |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
746 |
LandDirty[y+1, x]:= 1; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
747 |
recheck:= true; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
748 |
end; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
749 |
if (xx = tx) and (x > 0) then |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
750 |
begin |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
751 |
LandDirty[y, x-1]:= 1; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
752 |
recheck:= true; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
753 |
end |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
754 |
else if (xx = tx+31) and (x < LAND_WIDTH div 32 - 1) then |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
755 |
begin |
3601
8a74c9ceaf71
Revert most of optimisation except for some obvious fixes to errors someone or other introduced.
nemo
parents:
3596
diff
changeset
|
756 |
LandDirty[y, x+1]:= 1; |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
757 |
recheck:= true; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
758 |
end |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
759 |
end; |
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
760 |
end; |
3602
99c93fa258d6
Restore prior optimisation with the wildly out-of-bounds tx in LandDirty removed
nemo
parents:
3601
diff
changeset
|
761 |
if updateBlock then UpdateLandTexture(tx, 32, ty, 32); |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
762 |
LandDirty[y, x]:= 0; |
2167
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
763 |
end; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
764 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2741
diff
changeset
|
765 |
end; |
3554
066faceb977d
Extend pixel sweep to recheck neighbours if erasing on edges
nemo
parents:
3521
diff
changeset
|
766 |
end; |
1792 | 767 |
|
2695 | 768 |
SweepDirty:= bRes; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
769 |
end; |
184 | 770 |
|
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
771 |
// Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
772 |
function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; |
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
773 |
begin |
3509
d72c2219595d
Make land types flagged (to allow stacking future attributes such as indestructible ice, but also for a damaged flag)
nemo
parents:
3236
diff
changeset
|
774 |
CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0) |
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
775 |
end; |
4367 | 776 |
|
777 |
function LandBackPixel(x, y: LongInt): LongWord; |
|
778 |
var p: PLongWordArray; |
|
779 |
begin |
|
780 |
if LandBackSurface = nil then LandBackPixel:= 0 |
|
781 |
else |
|
782 |
begin |
|
783 |
p:= LandBackSurface^.pixels; |
|
784 |
LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000; |
|
785 |
end |
|
786 |
end; |
|
787 |
||
788 |
||
184 | 789 |
end. |