33 procedure GenMap; |
33 procedure GenMap; |
34 function GenPreview: TPreview; |
34 function GenPreview: TPreview; |
35 |
35 |
36 implementation |
36 implementation |
37 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
37 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
38 uVariables, uUtils, uCommands, Adler32, uDebug; |
38 uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted; |
39 |
39 |
40 operator=(const a, b: direction) c: Boolean; |
40 operator=(const a, b: direction) c: Boolean; |
41 begin |
41 begin |
42 c := (a.x = b.x) and (a.y = b.y); |
42 c := (a.x = b.x) and (a.y = b.y); |
43 end; |
43 end; |
494 procedure GenBlank(var Template: TEdgeTemplate); |
494 procedure GenBlank(var Template: TEdgeTemplate); |
495 var pa: TPixAr; |
495 var pa: TPixAr; |
496 i: Longword; |
496 i: Longword; |
497 y, x: Longword; |
497 y, x: Longword; |
498 begin |
498 begin |
499 for y:= 0 to LAND_HEIGHT - 1 do |
|
500 for x:= 0 to LAND_WIDTH - 1 do |
|
501 Land[y, x]:= lfBasic; |
|
502 |
|
503 {$HINTS OFF} |
|
504 SetPoints(Template, pa); |
|
505 {$HINTS ON} |
|
506 for i:= 1 to Template.BezierizeCount do |
|
507 begin |
|
508 BezierizeEdge(pa, _0_5); |
|
509 RandomizePoints(pa); |
|
510 RandomizePoints(pa) |
|
511 end; |
|
512 for i:= 1 to Template.RandPassesCount do RandomizePoints(pa); |
|
513 BezierizeEdge(pa, _0_1); |
|
514 |
|
515 DrawEdge(pa, 0); |
|
516 |
|
517 with Template do |
|
518 for i:= 0 to pred(FillPointsCount) do |
|
519 with FillPoints^[i] do |
|
520 FillLand(x, y); |
|
521 |
|
522 DrawEdge(pa, lfBasic); |
|
523 |
|
524 MaxHedgehogs:= Template.MaxHedgehogs; |
|
525 hasGirders:= Template.hasGirders; |
|
526 playHeight:= Template.TemplateHeight; |
|
527 playWidth:= Template.TemplateWidth; |
|
528 leftX:= ((LAND_WIDTH - playWidth) div 2); |
|
529 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
530 topY:= LAND_HEIGHT - playHeight; |
|
531 |
|
532 // force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
|
533 if (cTemplateFilter = 4) or |
|
534 (Template.canInvert and (getrandom(2) = 0)) or |
|
535 (not Template.canInvert and Template.isNegative) then |
|
536 begin |
|
537 hasBorder:= true; |
|
538 for y:= 0 to LAND_HEIGHT - 1 do |
499 for y:= 0 to LAND_HEIGHT - 1 do |
539 for x:= 0 to LAND_WIDTH - 1 do |
500 for x:= 0 to LAND_WIDTH - 1 do |
540 if (y < topY) or (x < leftX) or (x > rightX) then |
501 Land[y, x]:= lfBasic; |
541 Land[y, x]:= 0 |
502 {$HINTS OFF} |
542 else |
503 SetPoints(Template, pa); |
543 begin |
504 {$HINTS ON} |
544 if Land[y, x] = 0 then |
505 for i:= 1 to Template.BezierizeCount do |
545 Land[y, x]:= lfBasic |
506 begin |
546 else if Land[y, x] = lfBasic then |
507 BezierizeEdge(pa, _0_5); |
547 Land[y, x]:= 0; |
508 RandomizePoints(pa); |
548 end; |
509 RandomizePoints(pa) |
549 end; |
510 end; |
|
511 for i:= 1 to Template.RandPassesCount do RandomizePoints(pa); |
|
512 BezierizeEdge(pa, _0_1); |
|
513 |
|
514 |
|
515 DrawEdge(pa, 0); |
|
516 |
|
517 with Template do |
|
518 for i:= 0 to pred(FillPointsCount) do |
|
519 with FillPoints^[i] do |
|
520 FillLand(x, y); |
|
521 |
|
522 DrawEdge(pa, lfBasic); |
|
523 |
|
524 MaxHedgehogs:= Template.MaxHedgehogs; |
|
525 hasGirders:= Template.hasGirders; |
|
526 playHeight:= Template.TemplateHeight; |
|
527 playWidth:= Template.TemplateWidth; |
|
528 leftX:= ((LAND_WIDTH - playWidth) div 2); |
|
529 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
|
530 topY:= LAND_HEIGHT - playHeight; |
|
531 |
|
532 // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
|
533 if (cTemplateFilter = 4) or |
|
534 (Template.canInvert and (getrandom(2) = 0)) or |
|
535 (not Template.canInvert and Template.isNegative) then |
|
536 begin |
|
537 hasBorder:= true; |
|
538 for y:= 0 to LAND_HEIGHT - 1 do |
|
539 for x:= 0 to LAND_WIDTH - 1 do |
|
540 if (y < topY) or (x < leftX) or (x > rightX) then |
|
541 Land[y, x]:= 0 |
|
542 else |
|
543 begin |
|
544 if Land[y, x] = 0 then |
|
545 Land[y, x]:= lfBasic |
|
546 else if Land[y, x] = lfBasic then |
|
547 Land[y, x]:= 0; |
|
548 end; |
|
549 end; |
550 end; |
550 end; |
551 |
551 |
552 function SelectTemplate: LongInt; |
552 function SelectTemplate: LongInt; |
553 begin |
553 begin |
554 if (cReducedQuality and rqLowRes) <> 0 then |
554 if (cReducedQuality and rqLowRes) <> 0 then |