588 else MakeFortsMap; |
591 else MakeFortsMap; |
589 AddProgress; |
592 AddProgress; |
590 |
593 |
591 {$IFDEF DEBUGFILE}LogLandDigest;{$ENDIF} |
594 {$IFDEF DEBUGFILE}LogLandDigest;{$ENDIF} |
592 |
595 |
|
596 isCave:= false; |
|
597 // check for land near top |
|
598 for x:= 0 to LAND_WIDTH-1 do |
|
599 for y:= 0 to 4 do |
|
600 if Land[y, x] <> 0 then |
|
601 begin |
|
602 isCave:= true; |
|
603 break; |
|
604 end; |
|
605 |
|
606 if isCave then |
|
607 begin |
|
608 // experiment hardcoding cave |
|
609 for y:= 0 to LAND_HEIGHT-1 do |
|
610 begin |
|
611 Land[y, 0]:= COLOR_INDESTRUCTIBLE; |
|
612 Land[y, 1]:= COLOR_INDESTRUCTIBLE; |
|
613 Land[y, 2]:= COLOR_INDESTRUCTIBLE; |
|
614 Land[y, LAND_WIDTH-3]:= COLOR_INDESTRUCTIBLE; |
|
615 Land[y, LAND_WIDTH-2]:= COLOR_INDESTRUCTIBLE; |
|
616 Land[y, LAND_WIDTH-1]:= COLOR_INDESTRUCTIBLE; |
|
617 if y mod 32 < 16 then c:= $FF000000 |
|
618 else c:= $FF00FFFF; |
|
619 LandPixels[y, 0]:= c; |
|
620 LandPixels[y, 1]:= c; |
|
621 LandPixels[y, 2]:= c; |
|
622 LandPixels[y, LAND_WIDTH-3]:= c; |
|
623 LandPixels[y, LAND_WIDTH-2]:= c; |
|
624 LandPixels[y, LAND_WIDTH-1]:= c; |
|
625 end; |
|
626 |
|
627 for x:= 0 to LAND_WIDTH-1 do |
|
628 begin |
|
629 Land[0, x]:= COLOR_INDESTRUCTIBLE; |
|
630 Land[1, x]:= COLOR_INDESTRUCTIBLE; |
|
631 Land[2, x]:= COLOR_INDESTRUCTIBLE; |
|
632 if x mod 32 < 16 then c:= $FF000000 |
|
633 else c:= $FF00FFFF; |
|
634 LandPixels[0, x]:= c; |
|
635 LandPixels[1, x]:= c; |
|
636 LandPixels[2, x]:= c; |
|
637 end; |
|
638 end; |
|
639 |
593 UpdateLandTexture(0, LAND_HEIGHT); |
640 UpdateLandTexture(0, LAND_HEIGHT); |
594 end; |
641 end; |
595 |
642 |
596 function GenPreview: TPreview; |
643 function GenPreview: TPreview; |
597 var x, y, xx, yy, t, bit: LongInt; |
644 var x, y, xx, yy, t, bit: LongInt; |
598 Preview: TPreview; |
645 Preview: TPreview; |
599 isCave: boolean; |
|
600 c: LongWord; |
|
601 begin |
646 begin |
602 WriteLnToConsole('Generating preview...'); |
647 WriteLnToConsole('Generating preview...'); |
603 GenBlank(EdgeTemplates[SelectTemplate]); |
648 GenBlank(EdgeTemplates[SelectTemplate]); |
604 |
649 |
605 for y:= 0 to 127 do |
650 for y:= 0 to 127 do |
613 for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
658 for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
614 if Land[yy, xx] <> 0 then inc(t); |
659 if Land[yy, xx] <> 0 then inc(t); |
615 if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit) |
660 if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit) |
616 end |
661 end |
617 end; |
662 end; |
618 GenPreview:= Preview; |
663 GenPreview:= Preview |
619 |
|
620 isCave:= false; |
|
621 // check for land near top |
|
622 for x:= 0 to LAND_WIDTH-1 do |
|
623 for y:= 0 to 4 do |
|
624 if Land[y, x] <> 0 then |
|
625 begin |
|
626 isCave:= true; |
|
627 break; |
|
628 end; |
|
629 |
|
630 if isCave then |
|
631 begin |
|
632 // experiment hardcoding cave |
|
633 for y:= 0 to LAND_HEIGHT-1 do |
|
634 begin |
|
635 Land[y, 0]:= COLOR_INDESTRUCTIBLE; |
|
636 Land[y, 1]:= COLOR_INDESTRUCTIBLE; |
|
637 Land[y, 2]:= COLOR_INDESTRUCTIBLE; |
|
638 Land[y, LAND_WIDTH-3]:= COLOR_INDESTRUCTIBLE; |
|
639 Land[y, LAND_WIDTH-2]:= COLOR_INDESTRUCTIBLE; |
|
640 Land[y, LAND_WIDTH-1]:= COLOR_INDESTRUCTIBLE; |
|
641 if y mod 32 < 16 then c:= $FF000000 |
|
642 else c:= $FF00FFFF; |
|
643 LandPixels[y, 0]:= c; |
|
644 LandPixels[y, 1]:= c; |
|
645 LandPixels[y, 2]:= c; |
|
646 LandPixels[y, LAND_WIDTH-3]:= c; |
|
647 LandPixels[y, LAND_WIDTH-2]:= c; |
|
648 LandPixels[y, LAND_WIDTH-1]:= c; |
|
649 end; |
|
650 |
|
651 for x:= 0 to LAND_WIDTH-1 do |
|
652 begin |
|
653 Land[0, x]:= COLOR_INDESTRUCTIBLE; |
|
654 Land[1, x]:= COLOR_INDESTRUCTIBLE; |
|
655 Land[2, x]:= COLOR_INDESTRUCTIBLE; |
|
656 if x mod 32 < 16 then c:= $FF000000 |
|
657 else c:= $FF00FFFF; |
|
658 LandPixels[0, x]:= c; |
|
659 LandPixels[1, x]:= c; |
|
660 LandPixels[2, x]:= c; |
|
661 end; |
|
662 end; |
|
663 end; |
664 end; |
664 |
665 |
665 procedure UpdateLandTexture(Y, Height: LongInt); |
666 procedure UpdateLandTexture(Y, Height: LongInt); |
666 begin |
667 begin |
667 if (Height <= 0) then exit; |
668 if (Height <= 0) then exit; |