520 p:= @(p^[Surface^.pitch div 4]); |
519 p:= @(p^[Surface^.pitch div 4]); |
521 end; |
520 end; |
522 |
521 |
523 if SDL_MustLock(Surface) then |
522 if SDL_MustLock(Surface) then |
524 SDL_UnlockSurface(Surface); |
523 SDL_UnlockSurface(Surface); |
|
524 end; |
|
525 |
|
526 procedure GenLandSurface; |
|
527 var tmpsurf: PSDL_Surface; |
|
528 begin |
|
529 WriteLnToConsole('Generating land...'); |
|
530 |
|
531 GenBlank(EdgeTemplates[SelectTemplate]); |
|
532 |
|
533 AddProgress; |
|
534 |
|
535 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH+1, LAND_HEIGHT+1, 32, RMask, GMask, BMask, 0); |
|
536 |
|
537 TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); |
|
538 ColorizeLand(tmpsurf); |
|
539 AddOnLandObjects(tmpsurf); |
|
540 |
|
541 LandSurface2LandPixels(tmpsurf); |
|
542 SDL_FreeSurface(tmpsurf); |
|
543 |
|
544 AddProgress; |
|
545 |
|
546 AddObjects; |
|
547 |
|
548 AddProgress |
|
549 end; |
|
550 |
|
551 procedure MakeFortsMap; |
|
552 var tmpsurf: PSDL_Surface; |
|
553 begin |
|
554 WriteLnToConsole('Generating forts land...'); |
|
555 |
|
556 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', true, true, true); |
|
557 BlitImageAndGenerateCollisionInfo(0, 0, LAND_WIDTH+1, tmpsurf); |
|
558 SDL_FreeSurface(tmpsurf); |
|
559 |
|
560 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', true, true, true); |
|
561 BlitImageAndGenerateCollisionInfo(2048, 0, LAND_WIDTH+1, tmpsurf); |
|
562 SDL_FreeSurface(tmpsurf); |
|
563 |
|
564 end; |
|
565 |
|
566 procedure LoadMap; |
|
567 var tmpsurf: PSDL_Surface; |
|
568 begin |
|
569 WriteLnToConsole('Loading land from file...'); |
|
570 AddProgress; |
|
571 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true); |
|
572 TryDo((tmpsurf^.w = LAND_WIDTH+1) and (tmpsurf^.h = LAND_HEIGHT+1), 'Map dimensions should be 4096x2048!', true); |
|
573 |
|
574 TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true); |
|
575 |
|
576 BlitImageAndGenerateCollisionInfo(0, 0, LAND_WIDTH+1, tmpsurf); |
|
577 SDL_FreeSurface(tmpsurf); |
|
578 |
|
579 end; |
|
580 |
|
581 procedure GenMap; |
|
582 var x, y: LongInt; |
|
583 c: LongWord; |
|
584 begin |
|
585 LoadThemeConfig; |
|
586 |
|
587 if (GameFlags and gfForts) = 0 then |
|
588 if Pathz[ptMapCurrent] <> '' then LoadMap |
|
589 else GenLandSurface |
|
590 else MakeFortsMap; |
|
591 AddProgress; |
|
592 {$IFDEF DEBUGFILE}LogLandDigest;{$ENDIF} |
525 |
593 |
526 for y:= 0 to 63 do |
594 for y:= 0 to 63 do |
527 for x:= 0 to 127 do |
595 for x:= 0 to 127 do |
528 LandDirty[y, x]:= 0; // TODO - ask unC0Rr why he took this out of merge - doesn't it need initialising? seems random values could result in some unintended smoothing of initial map edges. also be slower. |
596 LandDirty[y, x]:= 0; // TODO - ask unC0Rr why he took this out of merge - doesn't it need initialising? seems random values could result in some unintended smoothing of initial map edges. also be slower. |
529 |
597 |
555 else c:= $FF00FFFF; |
623 else c:= $FF00FFFF; |
556 LandPixels[0, x]:= c; |
624 LandPixels[0, x]:= c; |
557 LandPixels[1, x]:= c; |
625 LandPixels[1, x]:= c; |
558 LandPixels[2, x]:= c; |
626 LandPixels[2, x]:= c; |
559 end; |
627 end; |
560 end; |
628 |
561 |
629 UpdateLandTexture(0, LAND_HEIGHT); |
562 procedure GenLandSurface; |
|
563 var tmpsurf: PSDL_Surface; |
|
564 begin |
|
565 WriteLnToConsole('Generating land...'); |
|
566 |
|
567 GenBlank(EdgeTemplates[SelectTemplate]); |
|
568 |
|
569 AddProgress; |
|
570 |
|
571 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH+1, LAND_HEIGHT+1, 32, RMask, GMask, BMask, 0); |
|
572 |
|
573 TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); |
|
574 ColorizeLand(tmpsurf); |
|
575 AddOnLandObjects(tmpsurf); |
|
576 |
|
577 LandSurface2LandPixels(tmpsurf); |
|
578 SDL_FreeSurface(tmpsurf); |
|
579 |
|
580 AddProgress; |
|
581 |
|
582 AddObjects; |
|
583 |
|
584 UpdateLandTexture(0, LAND_WIDTH); |
|
585 AddProgress |
|
586 end; |
|
587 |
|
588 procedure MakeFortsMap; |
|
589 var tmpsurf: PSDL_Surface; |
|
590 begin |
|
591 WriteLnToConsole('Generating forts land...'); |
|
592 |
|
593 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', true, true, true); |
|
594 BlitImageAndGenerateCollisionInfo(0, 0, LAND_WIDTH+1, tmpsurf); |
|
595 SDL_FreeSurface(tmpsurf); |
|
596 |
|
597 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', true, true, true); |
|
598 BlitImageAndGenerateCollisionInfo(2048, 0, LAND_WIDTH+1, tmpsurf); |
|
599 SDL_FreeSurface(tmpsurf); |
|
600 |
|
601 UpdateLandTexture(0, LAND_HEIGHT) |
|
602 end; |
|
603 |
|
604 procedure LoadMap; |
|
605 var tmpsurf: PSDL_Surface; |
|
606 begin |
|
607 WriteLnToConsole('Loading land from file...'); |
|
608 AddProgress; |
|
609 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true); |
|
610 TryDo((tmpsurf^.w = LAND_WIDTH+1) and (tmpsurf^.h = LAND_HEIGHT+1), 'Map dimensions should be 4096x2048!', true); |
|
611 |
|
612 TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true); |
|
613 |
|
614 BlitImageAndGenerateCollisionInfo(0, 0, LAND_WIDTH+1, tmpsurf); |
|
615 SDL_FreeSurface(tmpsurf); |
|
616 |
|
617 UpdateLandTexture(0, LAND_HEIGHT) |
|
618 end; |
|
619 |
|
620 procedure GenMap; |
|
621 begin |
|
622 LoadThemeConfig; |
|
623 |
|
624 if (GameFlags and gfForts) = 0 then |
|
625 if Pathz[ptMapCurrent] <> '' then LoadMap |
|
626 else GenLandSurface |
|
627 else MakeFortsMap; |
|
628 AddProgress; |
|
629 {$IFDEF DEBUGFILE}LogLandDigest{$ENDIF} |
|
630 end; |
630 end; |
631 |
631 |
632 function GenPreview: TPreview; |
632 function GenPreview: TPreview; |
633 var x, y, xx, yy, t, bit: LongInt; |
633 var x, y, xx, yy, t, bit: LongInt; |
634 Preview: TPreview; |
634 Preview: TPreview; |