178 var i, t: LongInt; |
178 var i, t: LongInt; |
179 begin |
179 begin |
180 t:= y + dy; |
180 t:= y + dy; |
181 if (t and LAND_HEIGHT_MASK) = 0 then |
181 if (t and LAND_HEIGHT_MASK) = 0 then |
182 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
182 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
183 if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then |
183 if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255)) then |
184 if (cReducedQuality and rqBlurryLand) = 0 then |
184 if (cReducedQuality and rqBlurryLand) = 0 then |
185 LandPixels[t, i]:= 0 |
185 LandPixels[t, i]:= 0 |
186 else |
186 else |
187 LandPixels[t div 2, i div 2]:= 0; |
187 LandPixels[t div 2, i div 2]:= 0; |
188 |
188 |
189 t:= y - dy; |
189 t:= y - dy; |
190 if (t and LAND_HEIGHT_MASK) = 0 then |
190 if (t and LAND_HEIGHT_MASK) = 0 then |
191 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
191 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
192 if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then |
192 if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255)) then |
193 if (cReducedQuality and rqBlurryLand) = 0 then |
193 if (cReducedQuality and rqBlurryLand) = 0 then |
194 LandPixels[t, i]:= 0 |
194 LandPixels[t, i]:= 0 |
195 else |
195 else |
196 LandPixels[t div 2, i div 2]:= 0; |
196 LandPixels[t div 2, i div 2]:= 0; |
197 |
197 |
198 t:= y + dx; |
198 t:= y + dx; |
199 if (t and LAND_HEIGHT_MASK) = 0 then |
199 if (t and LAND_HEIGHT_MASK) = 0 then |
200 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
200 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
201 if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then |
201 if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255)) then |
202 if (cReducedQuality and rqBlurryLand) = 0 then |
202 if (cReducedQuality and rqBlurryLand) = 0 then |
203 LandPixels[t, i]:= 0 |
203 LandPixels[t, i]:= 0 |
204 else |
204 else |
205 LandPixels[t div 2, i div 2]:= 0; |
205 LandPixels[t div 2, i div 2]:= 0; |
206 |
206 |
207 t:= y - dx; |
207 t:= y - dx; |
208 if (t and LAND_HEIGHT_MASK) = 0 then |
208 if (t and LAND_HEIGHT_MASK) = 0 then |
209 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
209 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
210 if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then |
210 if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255)) then |
211 if (cReducedQuality and rqBlurryLand) = 0 then |
211 if (cReducedQuality and rqBlurryLand) = 0 then |
212 LandPixels[t, i]:= 0 |
212 LandPixels[t, i]:= 0 |
213 else |
213 else |
214 LandPixels[t div 2, i div 2]:= 0; |
214 LandPixels[t div 2, i div 2]:= 0; |
215 |
215 |
221 begin |
221 begin |
222 cnt:= 0; |
222 cnt:= 0; |
223 t:= y + dy; |
223 t:= y + dy; |
224 if (t and LAND_HEIGHT_MASK) = 0 then |
224 if (t and LAND_HEIGHT_MASK) = 0 then |
225 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
225 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
226 begin |
226 if (Land[t, i] and lfIndestructible) = 0 then |
227 if (cReducedQuality and rqBlurryLand) = 0 then |
|
228 begin |
227 begin |
229 by:= t; bx:= i; |
228 if (cReducedQuality and rqBlurryLand) = 0 then |
230 end |
229 begin |
231 else |
230 by:= t; bx:= i; |
|
231 end |
|
232 else |
|
233 begin |
|
234 by:= t div 2; bx:= i div 2; |
|
235 end; |
|
236 if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then |
|
237 begin |
|
238 inc(cnt); |
|
239 LandPixels[by, bx]:= LandBackPixel(i, t) |
|
240 end |
|
241 else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then |
|
242 LandPixels[by, bx]:= 0 |
|
243 end; |
|
244 |
|
245 t:= y - dy; |
|
246 if (t and LAND_HEIGHT_MASK) = 0 then |
|
247 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
|
248 if (Land[t, i] and lfIndestructible) = 0 then |
232 begin |
249 begin |
233 by:= t div 2; bx:= i div 2; |
250 if (cReducedQuality and rqBlurryLand) = 0 then |
|
251 begin |
|
252 by:= t; bx:= i; |
|
253 end |
|
254 else |
|
255 begin |
|
256 by:= t div 2; bx:= i div 2; |
|
257 end; |
|
258 if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then |
|
259 begin |
|
260 inc(cnt); |
|
261 LandPixels[by, bx]:= LandBackPixel(i, t) |
|
262 end |
|
263 else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then |
|
264 LandPixels[by, bx]:= 0 |
234 end; |
265 end; |
235 if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then |
266 |
|
267 t:= y + dx; |
|
268 if (t and LAND_HEIGHT_MASK) = 0 then |
|
269 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
|
270 if (Land[t, i] and lfIndestructible) = 0 then |
236 begin |
271 begin |
237 inc(cnt); |
272 if (cReducedQuality and rqBlurryLand) = 0 then |
238 LandPixels[by, bx]:= LandBackPixel(i, t) |
273 begin |
239 end |
274 by:= t; bx:= i; |
240 else |
275 end |
241 if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then |
276 else |
242 LandPixels[by, bx]:= 0 |
277 begin |
243 end; |
278 by:= t div 2; bx:= i div 2; |
244 |
279 end; |
245 t:= y - dy; |
280 if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then |
246 if (t and LAND_HEIGHT_MASK) = 0 then |
281 begin |
247 for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do |
282 inc(cnt); |
248 begin |
283 LandPixels[by, bx]:= LandBackPixel(i, t) |
249 if (cReducedQuality and rqBlurryLand) = 0 then |
284 end |
|
285 else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then |
|
286 LandPixels[by, bx]:= 0 |
|
287 end; |
|
288 t:= y - dx; |
|
289 if (t and LAND_HEIGHT_MASK) = 0 then |
|
290 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
|
291 if (Land[t, i] and lfIndestructible) = 0 then |
250 begin |
292 begin |
251 by:= t; bx:= i; |
293 if (cReducedQuality and rqBlurryLand) = 0 then |
252 end |
294 begin |
253 else |
295 by:= t; bx:= i; |
254 begin |
296 end |
255 by:= t div 2; bx:= i div 2; |
297 else |
|
298 begin |
|
299 by:= t div 2; bx:= i div 2; |
|
300 end; |
|
301 if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then |
|
302 begin |
|
303 inc(cnt); |
|
304 LandPixels[by, bx]:= LandBackPixel(i, t) |
|
305 end |
|
306 else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then |
|
307 LandPixels[by, bx]:= 0 |
256 end; |
308 end; |
257 if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then |
|
258 begin |
|
259 inc(cnt); |
|
260 LandPixels[by, bx]:= LandBackPixel(i, t) |
|
261 end |
|
262 else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then |
|
263 LandPixels[by, bx]:= 0 |
|
264 end; |
|
265 |
|
266 t:= y + dx; |
|
267 if (t and LAND_HEIGHT_MASK) = 0 then |
|
268 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
|
269 begin |
|
270 if (cReducedQuality and rqBlurryLand) = 0 then |
|
271 begin |
|
272 by:= t; bx:= i; |
|
273 end |
|
274 else |
|
275 begin |
|
276 by:= t div 2; bx:= i div 2; |
|
277 end; |
|
278 if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then |
|
279 begin |
|
280 inc(cnt); |
|
281 LandPixels[by, bx]:= LandBackPixel(i, t) |
|
282 end |
|
283 else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then |
|
284 LandPixels[by, bx]:= 0 |
|
285 end; |
|
286 t:= y - dx; |
|
287 if (t and LAND_HEIGHT_MASK) = 0 then |
|
288 for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do |
|
289 begin |
|
290 if (cReducedQuality and rqBlurryLand) = 0 then |
|
291 begin |
|
292 by:= t; bx:= i; |
|
293 end |
|
294 else |
|
295 begin |
|
296 by:= t div 2; bx:= i div 2; |
|
297 end; |
|
298 if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then |
|
299 begin |
|
300 inc(cnt); |
|
301 LandPixels[by, bx]:= LandBackPixel(i, t) |
|
302 end |
|
303 else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then |
|
304 LandPixels[by, bx]:= 0 |
|
305 end; |
|
306 FillLandCircleLinesBG:= cnt; |
309 FillLandCircleLinesBG:= cnt; |
307 end; |
310 end; |
308 |
311 |
309 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt); |
312 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt); |
310 var i, t: LongInt; |
313 var i, t: LongInt; |
453 for i:= 0 to Pred(Count) do |
456 for i:= 0 to Pred(Count) do |
454 begin |
457 begin |
455 for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do |
458 for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do |
456 for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do |
459 for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do |
457 begin |
460 begin |
458 if (cReducedQuality and rqBlurryLand) = 0 then |
461 if (Land[ty, tx] and lfIndestructible) = 0 then |
459 begin |
462 begin |
460 by:= ty; bx:= tx; |
463 if (cReducedQuality and rqBlurryLand) = 0 then |
|
464 begin |
|
465 by:= ty; bx:= tx; |
|
466 end |
|
467 else |
|
468 begin |
|
469 by:= ty div 2; bx:= tx div 2; |
|
470 end; |
|
471 if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then |
|
472 LandPixels[by, bx]:= LandBackPixel(tx, ty) |
|
473 else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then |
|
474 LandPixels[by, bx]:= 0 |
461 end |
475 end |
462 else |
|
463 begin |
|
464 by:= ty div 2; bx:= tx div 2; |
|
465 end; |
|
466 if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then |
|
467 LandPixels[by, bx]:= LandBackPixel(tx, ty) |
|
468 else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then |
|
469 LandPixels[by, bx]:= 0 |
|
470 end; |
476 end; |
471 inc(y, dY) |
477 inc(y, dY) |
472 end; |
478 end; |
473 |
479 |
474 inc(Radius, 4); |
480 inc(Radius, 4); |
700 4: for y:= 0 to Pred(h) do |
705 4: for y:= 0 to Pred(h) do |
701 begin |
706 begin |
702 for x:= 0 to Pred(w) do |
707 for x:= 0 to Pred(w) do |
703 if PLongword(@(p^[x * 4]))^ <> 0 then |
708 if PLongword(@(p^[x * 4]))^ <> 0 then |
704 begin |
709 begin |
|
710 if (cReducedQuality and rqBlurryLand) = 0 then |
|
711 begin |
|
712 gX:= cpX + x; |
|
713 gY:= cpY + y; |
|
714 end |
|
715 else |
|
716 begin |
|
717 gX:= (cpX + x) div 2; |
|
718 gY:= (cpY + y) div 2; |
|
719 end; |
705 if indestructible then |
720 if indestructible then |
706 Land[cpY + y, cpX + x]:= lfIndestructible |
721 Land[cpY + y, cpX + x]:= lfIndestructible |
|
722 else if (LandPixels[gY, gX] and AMask) shr AShift = 255 then // This test assumes lfBasic and lfObject differ only graphically |
|
723 Land[cpY + y, cpX + x]:= lfBasic |
707 else |
724 else |
708 Land[cpY + y, cpX + x]:= lfObject; |
725 Land[cpY + y, cpX + x]:= lfObject; |
709 if (cReducedQuality and rqBlurryLand) = 0 then |
726 // For testing only. Intent is to flag this on objects with masks, or use it for an ice ray gun |
710 LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^ |
727 if (Theme = 'Snow') or (Theme = 'Christmas') then Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or lfIce; |
711 else |
728 LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ |
712 LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^ |
|
713 end; |
729 end; |
714 p:= @(p^[Image^.pitch]); |
730 p:= @(p^[Image^.pitch]); |
715 end; |
731 end; |
716 end; |
732 end; |
717 if SDL_MustLock(Image) then |
733 if SDL_MustLock(Image) then |
820 if (Land[y, x-1] = lfObject) then Land[y, x]:= lfObject |
836 if (Land[y, x-1] = lfObject) then Land[y, x]:= lfObject |
821 else if (Land[y, x+1] = lfObject) then Land[y, x]:= lfObject |
837 else if (Land[y, x+1] = lfObject) then Land[y, x]:= lfObject |
822 else if (Land[y+1, x] = lfObject) then Land[y, x]:= lfObject |
838 else if (Land[y+1, x] = lfObject) then Land[y, x]:= lfObject |
823 else if (Land[y-1, x] = lfObject) then Land[y, x]:= lfObject |
839 else if (Land[y-1, x] = lfObject) then Land[y, x]:= lfObject |
824 else Land[y,x]:= lfBasic |
840 else Land[y,x]:= lfBasic |
|
841 end |
|
842 end |
|
843 else if ((cReducedQuality and rqBlurryLand) = 0) and (LandPixels[Y, X] and AMask = 255) and |
|
844 ((Land[Y, X] and (lfDamaged or lfBasic) = lfBasic) or (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)) and |
|
845 (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then |
|
846 begin |
|
847 if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0)) or |
|
848 (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then |
|
849 begin |
|
850 LandPixels[y,x]:= |
|
851 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((cExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or |
|
852 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((cExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or |
|
853 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((cExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) |
|
854 end |
|
855 else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or |
|
856 (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or |
|
857 (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or |
|
858 (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or |
|
859 (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or |
|
860 (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or |
|
861 (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0)) or |
|
862 (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then |
|
863 begin |
|
864 LandPixels[y,x]:= |
|
865 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((cExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or |
|
866 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((cExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or |
|
867 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((cExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) |
825 end |
868 end |
826 end |
869 end |
827 end; |
870 end; |
828 |
871 |
829 function SweepDirty: boolean; |
872 function SweepDirty: boolean; |