35 |
35 |
36 var digest: shortstring; |
36 var digest: shortstring; |
37 |
37 |
38 procedure ResizeLand(width, height: LongWord); |
38 procedure ResizeLand(width, height: LongWord); |
39 var potW, potH: LongInt; |
39 var potW, potH: LongInt; |
40 begin |
40 begin |
41 potW:= toPowerOf2(width); |
41 potW:= toPowerOf2(width); |
42 potH:= toPowerOf2(height); |
42 potH:= toPowerOf2(height); |
43 if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then |
43 if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then |
44 begin |
44 begin |
45 LAND_WIDTH:= potW; |
45 LAND_WIDTH:= potW; |
238 playWidth:= Template.TemplateWidth; |
238 playWidth:= Template.TemplateWidth; |
239 leftX:= ((LAND_WIDTH - playWidth) div 2); |
239 leftX:= ((LAND_WIDTH - playWidth) div 2); |
240 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
240 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
241 topY:= LAND_HEIGHT - playHeight; |
241 topY:= LAND_HEIGHT - playHeight; |
242 |
242 |
243 |
243 |
244 // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
244 // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
245 if (cTemplateFilter = 4) |
245 if (cTemplateFilter = 4) |
246 or (Template.canInvert and (getrandom(2) = 0)) |
246 or (Template.canInvert and (getrandom(2) = 0)) |
247 or (not Template.canInvert and Template.isNegative) then |
247 or (not Template.canInvert and Template.isNegative) then |
248 begin |
248 begin |
338 |
338 |
339 LandSurface2LandPixels(tmpsurf); |
339 LandSurface2LandPixels(tmpsurf); |
340 SDL_FreeSurface(tmpsurf); |
340 SDL_FreeSurface(tmpsurf); |
341 for x:= leftX+2 to rightX-2 do |
341 for x:= leftX+2 to rightX-2 do |
342 for y:= topY+2 to LAND_HEIGHT-3 do |
342 for y:= topY+2 to LAND_HEIGHT-3 do |
343 if (Land[y, x] = 0) and |
343 if (Land[y, x] = 0) and |
344 (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
344 (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
345 ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |
345 ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |
346 begin |
346 begin |
347 if (cReducedQuality and rqBlurryLand) = 0 then |
347 if (cReducedQuality and rqBlurryLand) = 0 then |
348 begin |
348 begin |
349 if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then |
349 if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then |
350 LandPixels[y, x]:= LandPixels[y, x-1] |
350 LandPixels[y, x]:= LandPixels[y, x-1] |
351 |
351 |
352 else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then |
352 else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then |
353 LandPixels[y, x]:= LandPixels[y, x+1] |
353 LandPixels[y, x]:= LandPixels[y, x+1] |
354 |
354 |
355 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then |
355 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then |
356 LandPixels[y, x]:= LandPixels[y-1, x] |
356 LandPixels[y, x]:= LandPixels[y-1, x] |
357 |
357 |
358 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then |
358 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then |
359 LandPixels[y, x]:= LandPixels[y+1, x]; |
359 LandPixels[y, x]:= LandPixels[y+1, x]; |
360 |
360 |
361 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
361 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
362 LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
362 LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
363 end; |
363 end; |
364 Land[y,x]:= lfObject |
364 Land[y,x]:= lfObject |
365 end |
365 end |
370 ((Land[y, x+1] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
370 ((Land[y, x+1] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y-2,x] = lfBasic)) or |
371 ((Land[y+1, x] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
371 ((Land[y+1, x] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
372 ((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
372 ((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or |
373 ((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or |
373 ((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or |
374 ((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then |
374 ((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then |
375 |
375 |
376 begin |
376 begin |
377 |
377 |
378 if (cReducedQuality and rqBlurryLand) = 0 then |
378 if (cReducedQuality and rqBlurryLand) = 0 then |
379 |
379 |
380 begin |
380 begin |
381 |
381 |
382 if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then |
382 if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then |
383 LandPixels[y, x]:= LandPixels[y, x-1] |
383 LandPixels[y, x]:= LandPixels[y, x-1] |
384 |
384 |
385 else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then |
385 else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then |
386 LandPixels[y, x]:= LandPixels[y, x+1] |
386 LandPixels[y, x]:= LandPixels[y, x+1] |
387 |
387 |
388 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then |
388 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then |
389 LandPixels[y, x]:= LandPixels[y+1, x] |
389 LandPixels[y, x]:= LandPixels[y+1, x] |
390 |
390 |
391 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then |
391 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then |
392 LandPixels[y, x]:= LandPixels[y-1, x]; |
392 LandPixels[y, x]:= LandPixels[y-1, x]; |
393 |
393 |
394 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
394 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
395 LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
395 LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
396 end; |
396 end; |
397 Land[y,x]:= lfObject |
397 Land[y,x]:= lfObject |
398 end; |
398 end; |
486 for y:= 0 to Pred(tmpsurf^.h) do |
486 for y:= 0 to Pred(tmpsurf^.h) do |
487 begin |
487 begin |
488 for x:= 0 to Pred(tmpsurf^.w) do |
488 for x:= 0 to Pred(tmpsurf^.w) do |
489 begin |
489 begin |
490 // this an if instead of masking colours to avoid confusing map creators |
490 // this an if instead of masking colours to avoid confusing map creators |
491 if ((AMask and p^[x]) = 0) then |
491 if ((AMask and p^[x]) = 0) then |
492 Land[cpY + y, cpX + x]:= 0 |
492 Land[cpY + y, cpX + x]:= 0 |
493 else if p^[x] = $FFFFFFFF then // white |
493 else if p^[x] = $FFFFFFFF then // white |
494 Land[cpY + y, cpX + x]:= lfObject |
494 Land[cpY + y, cpX + x]:= lfObject |
495 else if p^[x] = AMask then // black |
495 else if p^[x] = AMask then // black |
496 begin |
496 begin |