39 maskOnly: boolean; |
39 maskOnly: boolean; |
40 |
40 |
41 procedure PrettifyLandAlpha(); |
41 procedure PrettifyLandAlpha(); |
42 begin |
42 begin |
43 if (cReducedQuality and rqBlurryLand) <> 0 then |
43 if (cReducedQuality and rqBlurryLand) <> 0 then |
44 PrettifyAlpha2D(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2) |
44 PrettifyAlpha2D(LAND_HEIGHT div 2, LAND_WIDTH div 2) |
45 else |
45 else |
46 PrettifyAlpha2D(LandPixels, LAND_HEIGHT, LAND_WIDTH); |
46 PrettifyAlpha2D(LAND_HEIGHT, LAND_WIDTH); |
47 end; |
47 end; |
48 |
48 |
49 procedure DrawBorderFromImage(Surface: PSDL_Surface); |
49 procedure DrawBorderFromImage(Surface: PSDL_Surface); |
50 var tmpsurf: PSDL_Surface; |
50 var tmpsurf: PSDL_Surface; |
51 x, yd, yu: LongInt; |
51 x, yd, yu: LongInt; |
404 for y:= 0 to LAND_HEIGHT - 1 do |
404 for y:= 0 to LAND_HEIGHT - 1 do |
405 begin |
405 begin |
406 for x:= 0 to LAND_WIDTH - 1 do |
406 for x:= 0 to LAND_WIDTH - 1 do |
407 if LandGet(y, x) <> 0 then |
407 if LandGet(y, x) <> 0 then |
408 if (cReducedQuality and rqBlurryLand) = 0 then |
408 if (cReducedQuality and rqBlurryLand) = 0 then |
409 LandPixels[y, x]:= p^[x]// or AMask |
409 LandPixelSet(y, x, p^[x])// or AMask |
410 else |
410 else |
411 LandPixels[y div 2, x div 2]:= p^[x]; |
411 LandPixelSet(y div 2, x div 2, p^[x]); |
412 |
412 |
413 p:= PLongwordArray(@(p^[Surface^.pitch div 4])); |
413 p:= PLongwordArray(@(p^[Surface^.pitch div 4])); |
414 end; |
414 end; |
415 |
415 |
416 if SDL_MustLock(Surface) then |
416 if SDL_MustLock(Surface) then |
442 (((LandGet(y, x-1) = lfBasic) and ((LandGet(y+1,x) = lfBasic)) or (LandGet(y-1,x) = lfBasic)) or |
442 (((LandGet(y, x-1) = lfBasic) and ((LandGet(y+1,x) = lfBasic)) or (LandGet(y-1,x) = lfBasic)) or |
443 ((LandGet(y, x+1) = lfBasic) and ((LandGet(y-1,x) = lfBasic) or (LandGet(y+1,x) = lfBasic)))) then |
443 ((LandGet(y, x+1) = lfBasic) and ((LandGet(y-1,x) = lfBasic) or (LandGet(y+1,x) = lfBasic)))) then |
444 begin |
444 begin |
445 if (cReducedQuality and rqBlurryLand) = 0 then |
445 if (cReducedQuality and rqBlurryLand) = 0 then |
446 begin |
446 begin |
447 if (LandGet(y, x-1) = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then |
447 if (LandGet(y, x-1) = lfBasic) and (LandPixelGet(y, x-1) and AMask <> 0) then |
448 LandPixels[y, x]:= LandPixels[y, x-1] |
448 LandPixelSet(y, x, LandPixelGet(y, x-1)) |
449 |
449 |
450 else if (LandGet(y, x+1) = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then |
450 else if (LandGet(y, x+1) = lfBasic) and (LandPixelGet(y, x+1) and AMask <> 0) then |
451 LandPixels[y, x]:= LandPixels[y, x+1] |
451 LandPixelSet(y, x, LandPixelGet(y, x+1)) |
452 |
452 |
453 else if (LandGet(y-1, x) = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then |
453 else if (LandGet(y-1, x) = lfBasic) and (LandPixelGet(y-1, x) and AMask <> 0) then |
454 LandPixels[y, x]:= LandPixels[y-1, x] |
454 LandPixelSet(y, x, LandPixelGet(y-1, x)) |
455 |
455 |
456 else if (LandGet(y+1, x) = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then |
456 else if (LandGet(y+1, x) = lfBasic) and (LandPixelGet(y+1, x) and AMask <> 0) then |
457 LandPixels[y, x]:= LandPixels[y+1, x]; |
457 LandPixelSet(y, x, LandPixelGet(y+1, x)); |
458 |
458 |
459 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
459 if (((LandPixelGet(y,x) and AMask) shr AShift) > 10) then |
460 LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
460 LandPixelSet(y, x, (LandPixelGet(y,x) and (not AMask)) or (128 shl AShift)) |
461 end; |
461 end; |
462 LandSet(y, x, lfObject) |
462 LandSet(y, x, lfObject) |
463 end |
463 end |
464 else if (LandGet(y, x) = 0) and |
464 else if (LandGet(y, x) = 0) and |
465 (((LandGet(y, x-1) = lfBasic) and (LandGet(y+1,x-1) = lfBasic) and (LandGet(y+2,x) = lfBasic)) or |
465 (((LandGet(y, x-1) = lfBasic) and (LandGet(y+1,x-1) = lfBasic) and (LandGet(y+2,x) = lfBasic)) or |
475 |
475 |
476 if (cReducedQuality and rqBlurryLand) = 0 then |
476 if (cReducedQuality and rqBlurryLand) = 0 then |
477 |
477 |
478 begin |
478 begin |
479 |
479 |
480 if (LandGet(y, x-1) = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then |
480 if (LandGet(y, x-1) = lfBasic) and (LandPixelGet(y,x-1) and AMask <> 0) then |
481 LandPixels[y, x]:= LandPixels[y, x-1] |
481 LandPixelSet(y, x, LandPixelGet(y, x-1)) |
482 |
482 |
483 else if (LandGet(y, x+1) = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then |
483 else if (LandGet(y, x+1) = lfBasic) and (LandPixelGet(y,x+1) and AMask <> 0) then |
484 LandPixels[y, x]:= LandPixels[y, x+1] |
484 LandPixelSet(y, x, LandPixelGet(y, x+1)) |
485 |
485 |
486 else if (LandGet(y+1, x) = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then |
486 else if (LandGet(y+1, x) = lfBasic) and (LandPixelGet(y+1,x) and AMask <> 0) then |
487 LandPixels[y, x]:= LandPixels[y+1, x] |
487 LandPixelSet(y, x, LandPixelGet(y+1, x)) |
488 |
488 |
489 else if (LandGet(y-1, x) = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then |
489 else if (LandGet(y-1, x) = lfBasic) and (LandPixelGet(y-1,x) and AMask <> 0) then |
490 LandPixels[y, x]:= LandPixels[y-1, x]; |
490 LandPixelSet(y, x, LandPixelGet(y-1, x)); |
491 |
491 |
492 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then |
492 if (((LandPixelGet(y,x) and AMask) shr AShift) > 10) then |
493 LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
493 LandPixelSet(y, x, (LandPixelGet(y,x) and (not AMask)) or (64 shl AShift)) |
494 end; |
494 end; |
495 LandSet(y, x, lfObject) |
495 LandSet(y, x, lfObject) |
496 end; |
496 end; |
497 |
497 |
498 AddProgress(); |
498 AddProgress(); |
760 c:= AMask |
760 c:= AMask |
761 else |
761 else |
762 c:= AMask or RMask or GMask; // FF00FFFF |
762 c:= AMask or RMask or GMask; // FF00FFFF |
763 |
763 |
764 if (cReducedQuality and rqBlurryLand) = 0 then |
764 if (cReducedQuality and rqBlurryLand) = 0 then |
765 LandPixels[y, x]:= c |
765 LandPixelSet(y, x, c) |
766 else |
766 else |
767 LandPixels[y div 2, x div 2]:= c |
767 LandPixelSet(y div 2, x div 2, c) |
768 end |
768 end |
769 end; |
769 end; |
770 |
770 |
771 procedure GenMap; |
771 procedure GenMap; |
772 var x, y, w, c, c2: Longword; |
772 var x, y, w, c, c2: Longword; |
862 else |
862 else |
863 c2:= AMask or RMask or GMask; // yellow |
863 c2:= AMask or RMask or GMask; // yellow |
864 |
864 |
865 if (cReducedQuality and rqBlurryLand) = 0 then |
865 if (cReducedQuality and rqBlurryLand) = 0 then |
866 begin |
866 begin |
867 LandPixels[y, leftX + w]:= c; |
867 LandPixelSet(y, leftX + w, c); |
868 LandPixels[y, rightX - w]:= c2; |
868 LandPixelSet(y, rightX - w, c2); |
869 end |
869 end |
870 else |
870 else |
871 begin |
871 begin |
872 LandPixels[y div 2, (leftX + w) div 2]:= c; |
872 LandPixelSet(y div 2, (leftX + w) div 2, c); |
873 LandPixels[y div 2, (rightX - w) div 2]:= c2; |
873 LandPixelSet(y div 2, (rightX - w) div 2, c2); |
874 end; |
874 end; |
875 end; |
875 end; |
876 |
876 |
877 // Top border |
877 // Top border |
878 for x:= LongWord(leftX) to LongWord(rightX) do |
878 for x:= LongWord(leftX) to LongWord(rightX) do |
912 begin |
912 begin |
913 if (cReducedQuality and rqBlurryLand) = 0 then |
913 if (cReducedQuality and rqBlurryLand) = 0 then |
914 for x:= LongWord(leftX) to LongWord(rightX) do |
914 for x:= LongWord(leftX) to LongWord(rightX) do |
915 for y:= LongWord(topY) to LAND_HEIGHT-1 do |
915 for y:= LongWord(topY) to LAND_HEIGHT-1 do |
916 begin |
916 begin |
917 w:= LandPixels[y,x]; |
917 w:= LandPixelGet(y,x); |
918 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + |
918 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + |
919 (w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
919 (w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
920 (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); |
920 (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); |
921 if w > 255 then |
921 if w > 255 then |
922 w:= 255; |
922 w:= 255; |
923 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y,x] and AMask); |
923 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixelGet(y,x) and AMask); |
924 LandPixels[y,x]:= w or (LandPixels[y, x] and AMask) |
924 LandPixelSet(y, x, w or (LandPixelGet(y, x) and AMask)) |
925 end |
925 end |
926 else |
926 else |
927 for x:= LongWord(leftX div 2) to LongWord(rightX div 2) do |
927 for x:= LongWord(leftX div 2) to LongWord(rightX div 2) do |
928 for y:= LongWord(topY div 2) to LAND_HEIGHT-1 div 2 do |
928 for y:= LongWord(topY div 2) to LAND_HEIGHT-1 div 2 do |
929 begin |
929 begin |
930 w:= LandPixels[y div 2,x div 2]; |
930 w:= LandPixelGet(y div 2,x div 2); |
931 w:= ((w shr RShift and $FF) + (w shr BShift and $FF) + (w shr GShift and $FF)) div 3; |
931 w:= ((w shr RShift and $FF) + (w shr BShift and $FF) + (w shr GShift and $FF)) div 3; |
932 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y div 2,x div 2] and AMask); |
932 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixelGet(y div 2,x div 2) and AMask); |
933 LandPixels[y,x]:= w or (LandPixels[y div 2, x div 2] and AMask) |
933 LandPixelSet(y, x, w or (LandPixelGet(y div 2, x div 2) and AMask)) |
934 end |
934 end |
935 end; |
935 end; |
936 |
936 |
937 PrettifyLandAlpha(); |
937 PrettifyLandAlpha(); |
938 |
938 |
1070 procedure chSendLandDigest(var s: shortstring); |
1070 procedure chSendLandDigest(var s: shortstring); |
1071 var i: LongInt; |
1071 var i: LongInt; |
1072 landPixelDigest : LongInt; |
1072 landPixelDigest : LongInt; |
1073 begin |
1073 begin |
1074 landPixelDigest:= 1; |
1074 landPixelDigest:= 1; |
1075 // for i:= 0 to LAND_HEIGHT-1 do |
1075 for i:= 0 to LAND_HEIGHT-1 do |
1076 // landPixelDigest:= Adler32Update(landPixelDigest, @LandGet(i,x), 2); |
1076 landPixelDigest:= Adler32Update(landPixelDigest, LandRow(i), LAND_WIDTH*2); |
1077 s:= 'M' + IntToStr(syncedPixelDigest)+'|'+IntToStr(landPixelDigest); |
1077 s:= 'M' + IntToStr(syncedPixelDigest)+'|'+IntToStr(landPixelDigest); |
1078 |
1078 |
1079 ScriptSetString('LandDigest',IntToStr(landPixelDigest)); |
1079 ScriptSetString('LandDigest',IntToStr(landPixelDigest)); |
1080 |
1080 |
1081 chLandCheck(s); |
1081 chLandCheck(s); |