1 (* |
1 (* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
34 uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures, |
34 uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures, |
35 uLandGenMaze, uPhysFSLayer, uScript, uLandGenPerlin, |
35 uLandGenMaze, uPhysFSLayer, uScript, uLandGenPerlin, |
36 uLandGenTemplateBased, uLandUtils; |
36 uLandGenTemplateBased, uLandUtils; |
37 |
37 |
38 var digest: shortstring; |
38 var digest: shortstring; |
|
39 maskOnly: boolean; |
39 |
40 |
40 |
41 |
41 procedure PrettifyLandAlpha(); |
42 procedure PrettifyLandAlpha(); |
42 begin |
43 begin |
43 if (cReducedQuality and rqBlurryLand) <> 0 then |
44 if (cReducedQuality and rqBlurryLand) <> 0 then |
48 |
49 |
49 procedure DrawBorderFromImage(Surface: PSDL_Surface); |
50 procedure DrawBorderFromImage(Surface: PSDL_Surface); |
50 var tmpsurf: PSDL_Surface; |
51 var tmpsurf: PSDL_Surface; |
51 r, rr: TSDL_Rect; |
52 r, rr: TSDL_Rect; |
52 x, yd, yu: LongInt; |
53 x, yd, yu: LongInt; |
|
54 targetMask: Word; |
53 begin |
55 begin |
54 tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent); |
56 tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent); |
|
57 |
|
58 // if mask only, all land gets filled with landtex and therefore needs borders |
|
59 if maskOnly then |
|
60 targetMask:= lfLandMask |
|
61 else |
|
62 targetMask:= lfBasic; |
|
63 |
55 for x:= 0 to LAND_WIDTH - 1 do |
64 for x:= 0 to LAND_WIDTH - 1 do |
56 begin |
65 begin |
57 yd:= LAND_HEIGHT - 1; |
66 yd:= LAND_HEIGHT - 1; |
58 repeat |
67 repeat |
59 while (yd > 0) and (Land[yd, x] <> lfBasic) do dec(yd); |
68 while (yd > 0) and ((Land[yd, x] and targetMask) = 0) do dec(yd); |
60 |
69 |
61 if (yd < 0) then |
70 if (yd < 0) then |
62 yd:= 0; |
71 yd:= 0; |
63 |
72 |
64 while (yd < LAND_HEIGHT) and (Land[yd, x] = lfBasic) do |
73 while (yd < LAND_HEIGHT) and ((Land[yd, x] and targetMask) <> 0) do |
65 inc(yd); |
74 inc(yd); |
66 dec(yd); |
75 dec(yd); |
67 yu:= yd; |
76 yu:= yd; |
68 |
77 |
69 while (yu > 0 ) and (Land[yu, x] = lfBasic) do dec(yu); |
78 while (yu > 0 ) and ((Land[yu, x] and targetMask) <> 0) do dec(yu); |
70 while (yu < yd ) and (Land[yu, x] <> lfBasic) do inc(yu); |
79 while (yu < yd ) and ((Land[yu, x] and targetMask) = 0) do inc(yu); |
71 |
80 |
72 if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
81 if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
73 begin |
82 begin |
74 rr.x:= x; |
83 rr.x:= x; |
75 rr.y:= yd - 15; |
84 rr.y:= yd - 15; |
370 |
379 |
371 tmpsurf:= LoadDataImage(ptForts, ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
380 tmpsurf:= LoadDataImage(ptForts, ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
372 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
381 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
373 SDL_FreeSurface(tmpsurf); |
382 SDL_FreeSurface(tmpsurf); |
374 |
383 |
375 tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
384 // not critical because if no R we can fallback to mirrored L |
376 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
385 tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps); |
|
386 // fallback |
|
387 if tmpsurf = nil then |
|
388 begin |
|
389 tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
|
390 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true); |
|
391 end |
|
392 else |
|
393 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); |
377 SDL_FreeSurface(tmpsurf); |
394 SDL_FreeSurface(tmpsurf); |
378 end; |
395 end; |
379 |
396 |
380 procedure LoadMapConfig; |
397 procedure LoadMapConfig; |
381 var f: PFSFile; |
398 var f: PFSFile; |
800 RegisterVariable('landcheck', @chLandCheck, false); |
816 RegisterVariable('landcheck', @chLandCheck, false); |
801 RegisterVariable('sendlanddigest', @chSendLandDigest, false); |
817 RegisterVariable('sendlanddigest', @chSendLandDigest, false); |
802 |
818 |
803 LandBackSurface:= nil; |
819 LandBackSurface:= nil; |
804 digest:= ''; |
820 digest:= ''; |
|
821 maskOnly:= false; |
805 LAND_WIDTH:= 0; |
822 LAND_WIDTH:= 0; |
806 LAND_HEIGHT:= 0; |
823 LAND_HEIGHT:= 0; |
807 (* |
824 (* |
808 if (cReducedQuality and rqBlurryLand) = 0 then |
825 if (cReducedQuality and rqBlurryLand) = 0 then |
809 SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |
826 SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |