hedgewars/uLand.pas
branchwebgl
changeset 9950 2759212a27de
parent 9521 8054d9d775fd
parent 9892 5a0a7ef7af2d
child 10015 4feced261c68
equal deleted inserted replaced
9521:8054d9d775fd 9950:2759212a27de
   121     // vertical
   121     // vertical
   122     s:= LAND_HEIGHT;
   122     s:= LAND_HEIGHT;
   123     
   123     
   124     for x:= 0 to LAND_WIDTH - 1 do
   124     for x:= 0 to LAND_WIDTH - 1 do
   125         for y:= 0 to LAND_HEIGHT - 1 do
   125         for y:= 0 to LAND_HEIGHT - 1 do
   126             if LandPixels[y, x] = 0 then
   126             if Land[y, x] = 0 then
   127                 if s < y then
   127                 if s < y then
   128                     begin
   128                     begin
   129                     for i:= max(s, y - 8) to y - 1 do
   129                     for i:= max(s, y - 8) to y - 1 do
   130                         begin
   130                         begin
   131                         if ((x + i) and 16) = 0 then c:= c1 else c:= c2;
   131                         if ((x + i) and 16) = 0 then c:= c1 else c:= c2;
   155     // horizontal
   155     // horizontal
   156     s:= LAND_WIDTH;
   156     s:= LAND_WIDTH;
   157     
   157     
   158     for y:= 0 to LAND_HEIGHT - 1 do
   158     for y:= 0 to LAND_HEIGHT - 1 do
   159         for x:= 0 to LAND_WIDTH - 1 do
   159         for x:= 0 to LAND_WIDTH - 1 do
   160             if LandPixels[y, x] = 0 then
   160             if Land[y, x] = 0 then
   161                 if s < x then
   161                 if s < x then
   162                     begin
   162                     begin
   163                     for i:= max(s, x - 8) to x - 1 do
   163                     for i:= max(s, x - 8) to x - 1 do
   164                         begin
   164                         begin
   165                         if ((y + i) and 16) = 0 then c:= c1 else c:= c2;
   165                         if ((y + i) and 16) = 0 then c:= c1 else c:= c2;
   188 end;
   188 end;
   189 
   189 
   190 procedure ColorizeLand(Surface: PSDL_Surface);
   190 procedure ColorizeLand(Surface: PSDL_Surface);
   191 var tmpsurf: PSDL_Surface;
   191 var tmpsurf: PSDL_Surface;
   192     r: TSDL_Rect;
   192     r: TSDL_Rect;
       
   193     y: LongWord; // stupid SDL 1.2 uses stupid SmallInt for y which limits us to 32767.  But is even worse if LandTex is large, can overflow on 32767 map.
   193 begin
   194 begin
   194     tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps);
   195     tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps);
   195     r.y:= 0;
   196     r.y:= 0;
   196     while r.y < LAND_HEIGHT do
   197     y:= 0;
   197     begin
   198     while y < LAND_HEIGHT do
       
   199         begin
   198         r.x:= 0;
   200         r.x:= 0;
   199         while r.x < LAND_WIDTH do
   201         while r.x < LAND_WIDTH do
   200         begin
   202             begin
   201             SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   203             SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   202             inc(r.x, tmpsurf^.w)
   204             inc(r.x, tmpsurf^.w)
   203         end;
   205             end;
   204         inc(r.y, tmpsurf^.h)
   206         inc(y, tmpsurf^.h);
   205     end;
   207         r.y:= y
       
   208         end;
   206     SDL_FreeSurface(tmpsurf);
   209     SDL_FreeSurface(tmpsurf);
   207 
   210 
   208     // freed in freeModule() below
   211     // freed in freeModule() below
   209     LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
   212     LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
   210     if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface);
   213     if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface);
   729                 Land[y, x]:= lfIndestructible;
   732                 Land[y, x]:= lfIndestructible;
   730     // experiment hardcoding cave
   733     // experiment hardcoding cave
   731     // also try basing cave dimensions on map/template dimensions, if they exist
   734     // also try basing cave dimensions on map/template dimensions, if they exist
   732     for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
   735     for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
   733         begin
   736         begin
   734         for y:= topY to LAND_HEIGHT - 1 do
   737         if (WorldEdge <> weBounce) and (WorldEdge <> weWrap) then
   735                 begin
   738             for y:= topY to LAND_HEIGHT - 1 do
   736                 Land[y, leftX + w]:= lfIndestructible;
       
   737                 Land[y, rightX - w]:= lfIndestructible;
       
   738                 if (y + w) mod 32 < 16 then
       
   739                     c:= AMask
       
   740                 else
       
   741                     c:= AMask or RMask or GMask; // FF00FFFF
       
   742 
       
   743                 if (cReducedQuality and rqBlurryLand) = 0 then
       
   744                     begin
   739                     begin
   745                     LandPixels[y, leftX + w]:= c;
   740                     Land[y, leftX + w]:= lfIndestructible;
   746                     LandPixels[y, rightX - w]:= c;
   741                     Land[y, rightX - w]:= lfIndestructible;
   747                     end
   742                     if (y + w) mod 32 < 16 then
   748                 else
   743                         c:= AMask
   749                     begin
   744                     else
   750                     LandPixels[y div 2, (leftX + w) div 2]:= c;
   745                         c:= AMask or RMask or GMask; // FF00FFFF
   751                     LandPixels[y div 2, (rightX - w) div 2]:= c;
   746 
       
   747                     if (cReducedQuality and rqBlurryLand) = 0 then
       
   748                         begin
       
   749                         LandPixels[y, leftX + w]:= c;
       
   750                         LandPixels[y, rightX - w]:= c;
       
   751                         end
       
   752                     else
       
   753                         begin
       
   754                         LandPixels[y div 2, (leftX + w) div 2]:= c;
       
   755                         LandPixels[y div 2, (rightX - w) div 2]:= c;
       
   756                         end;
   752                     end;
   757                     end;
   753                 end;
       
   754 
   758 
   755         for x:= leftX to rightX do
   759         for x:= leftX to rightX do
   756             begin
   760             begin
   757             Land[topY + w, x]:= lfIndestructible;
   761             Land[topY + w, x]:= lfIndestructible;
   758             if (x + w) mod 32 < 16 then
   762             if (x + w) mod 32 < 16 then