hedgewars/uLandGraphics.pas
changeset 6096 a00dbbf49d6c
parent 6081 537bbd5c1a62
child 6097 db10abae541f
equal deleted inserted replaced
6095:332d45c08592 6096:a00dbbf49d6c
   178 var i, t: LongInt;
   178 var i, t: LongInt;
   179 begin
   179 begin
   180 t:= y + dy;
   180 t:= y + dy;
   181 if (t and LAND_HEIGHT_MASK) = 0 then
   181 if (t and LAND_HEIGHT_MASK) = 0 then
   182     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   182     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   183         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   183         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   184             if (cReducedQuality and rqBlurryLand) = 0 then
   184             if (cReducedQuality and rqBlurryLand) = 0 then
   185                 LandPixels[t, i]:= 0
   185                 LandPixels[t, i]:= 0
   186             else
   186             else
   187                 LandPixels[t div 2, i div 2]:= 0;
   187                 LandPixels[t div 2, i div 2]:= 0;
   188 
   188 
   189 t:= y - dy;
   189 t:= y - dy;
   190 if (t and LAND_HEIGHT_MASK) = 0 then
   190 if (t and LAND_HEIGHT_MASK) = 0 then
   191     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   191     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   192         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   192         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   193             if (cReducedQuality and rqBlurryLand) = 0 then
   193             if (cReducedQuality and rqBlurryLand) = 0 then
   194                 LandPixels[t, i]:= 0
   194                 LandPixels[t, i]:= 0
   195             else
   195             else
   196                 LandPixels[t div 2, i div 2]:= 0;
   196                 LandPixels[t div 2, i div 2]:= 0;
   197 
   197 
   198 t:= y + dx;
   198 t:= y + dx;
   199 if (t and LAND_HEIGHT_MASK) = 0 then
   199 if (t and LAND_HEIGHT_MASK) = 0 then
   200     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   200     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   201         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   201         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   202             if (cReducedQuality and rqBlurryLand) = 0 then
   202             if (cReducedQuality and rqBlurryLand) = 0 then
   203                 LandPixels[t, i]:= 0
   203                 LandPixels[t, i]:= 0
   204             else
   204             else
   205                 LandPixels[t div 2, i div 2]:= 0;
   205                 LandPixels[t div 2, i div 2]:= 0;
   206 
   206 
   207 t:= y - dx;
   207 t:= y - dx;
   208 if (t and LAND_HEIGHT_MASK) = 0 then
   208 if (t and LAND_HEIGHT_MASK) = 0 then
   209     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   209     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   210         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   210         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   211             if (cReducedQuality and rqBlurryLand) = 0 then
   211             if (cReducedQuality and rqBlurryLand) = 0 then
   212                 LandPixels[t, i]:= 0
   212                 LandPixels[t, i]:= 0
   213             else
   213             else
   214                 LandPixels[t div 2, i div 2]:= 0;
   214                 LandPixels[t div 2, i div 2]:= 0;
   215 
   215 
   221 begin
   221 begin
   222 cnt:= 0;
   222 cnt:= 0;
   223 t:= y + dy;
   223 t:= y + dy;
   224 if (t and LAND_HEIGHT_MASK) = 0 then
   224 if (t and LAND_HEIGHT_MASK) = 0 then
   225    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   225    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   226        begin
   226        if (Land[t, i] and lfIndestructible) = 0 then
   227        if (cReducedQuality and rqBlurryLand) = 0 then
       
   228            begin
   227            begin
   229            by:= t; bx:= i;
   228            if (cReducedQuality and rqBlurryLand) = 0 then
   230            end
   229                begin
   231        else
   230                by:= t; bx:= i;
       
   231                end
       
   232            else
       
   233                begin
       
   234                by:= t div 2; bx:= i div 2;
       
   235                end;
       
   236            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
       
   237                begin
       
   238                inc(cnt);
       
   239                LandPixels[by, bx]:= LandBackPixel(i, t)
       
   240                end
       
   241            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
       
   242                LandPixels[by, bx]:= 0
       
   243            end;
       
   244 
       
   245 t:= y - dy;
       
   246 if (t and LAND_HEIGHT_MASK) = 0 then
       
   247    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
       
   248        if (Land[t, i] and lfIndestructible) = 0 then
   232            begin
   249            begin
   233            by:= t div 2; bx:= i div 2;
   250            if (cReducedQuality and rqBlurryLand) = 0 then
       
   251                begin
       
   252                by:= t; bx:= i;
       
   253                end
       
   254            else
       
   255                begin
       
   256                by:= t div 2; bx:= i div 2;
       
   257                end;
       
   258            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
       
   259                begin
       
   260                inc(cnt);
       
   261                LandPixels[by, bx]:= LandBackPixel(i, t)
       
   262                end
       
   263            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
       
   264                LandPixels[by, bx]:= 0
   234            end;
   265            end;
   235        if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
   266 
       
   267 t:= y + dx;
       
   268 if (t and LAND_HEIGHT_MASK) = 0 then
       
   269    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
       
   270        if (Land[t, i] and lfIndestructible) = 0 then
   236            begin
   271            begin
   237            inc(cnt);
   272            if (cReducedQuality and rqBlurryLand) = 0 then
   238            LandPixels[by, bx]:= LandBackPixel(i, t)
   273                begin
   239            end
   274                by:= t; bx:= i;
   240        else
   275                end
   241            if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
   276            else
   242               LandPixels[by, bx]:= 0
   277                begin
   243        end;
   278                by:= t div 2; bx:= i div 2;
   244 
   279                end;
   245 t:= y - dy;
   280            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
   246 if (t and LAND_HEIGHT_MASK) = 0 then
   281                begin
   247    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   282                inc(cnt);
   248        begin
   283                LandPixels[by, bx]:= LandBackPixel(i, t)
   249        if (cReducedQuality and rqBlurryLand) = 0 then
   284                end
       
   285            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
       
   286                LandPixels[by, bx]:= 0
       
   287            end;
       
   288 t:= y - dx;
       
   289 if (t and LAND_HEIGHT_MASK) = 0 then
       
   290    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
       
   291        if (Land[t, i] and lfIndestructible) = 0 then
   250            begin
   292            begin
   251            by:= t; bx:= i;
   293            if (cReducedQuality and rqBlurryLand) = 0 then
   252            end
   294                begin
   253        else
   295                by:= t; bx:= i;
   254            begin
   296                end
   255            by:= t div 2; bx:= i div 2;
   297            else
       
   298                begin
       
   299                by:= t div 2; bx:= i div 2;
       
   300                end;
       
   301            if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
       
   302                begin
       
   303                inc(cnt);
       
   304                LandPixels[by, bx]:= LandBackPixel(i, t)
       
   305                end
       
   306            else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
       
   307                LandPixels[by, bx]:= 0
   256            end;
   308            end;
   257        if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
       
   258            begin
       
   259            inc(cnt);
       
   260            LandPixels[by, bx]:= LandBackPixel(i, t)
       
   261            end
       
   262        else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
       
   263               LandPixels[by, bx]:= 0
       
   264        end;
       
   265 
       
   266 t:= y + dx;
       
   267 if (t and LAND_HEIGHT_MASK) = 0 then
       
   268    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
       
   269        begin
       
   270        if (cReducedQuality and rqBlurryLand) = 0 then
       
   271            begin
       
   272            by:= t; bx:= i;
       
   273            end
       
   274        else
       
   275            begin
       
   276            by:= t div 2; bx:= i div 2;
       
   277            end;
       
   278        if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
       
   279            begin
       
   280            inc(cnt);
       
   281            LandPixels[by, bx]:= LandBackPixel(i, t)
       
   282            end
       
   283        else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
       
   284            LandPixels[by, bx]:= 0
       
   285        end;
       
   286 t:= y - dx;
       
   287 if (t and LAND_HEIGHT_MASK) = 0 then
       
   288    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
       
   289        begin
       
   290        if (cReducedQuality and rqBlurryLand) = 0 then
       
   291            begin
       
   292            by:= t; bx:= i;
       
   293            end
       
   294        else
       
   295            begin
       
   296            by:= t div 2; bx:= i div 2;
       
   297            end;
       
   298        if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
       
   299            begin
       
   300            inc(cnt);
       
   301            LandPixels[by, bx]:= LandBackPixel(i, t)
       
   302            end
       
   303        else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
       
   304            LandPixels[by, bx]:= 0
       
   305        end;
       
   306 FillLandCircleLinesBG:= cnt;
   309 FillLandCircleLinesBG:= cnt;
   307 end;
   310 end;
   308 
   311 
   309 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   312 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   310 var i, t: LongInt;
   313 var i, t: LongInt;
   453 for i:= 0 to Pred(Count) do
   456 for i:= 0 to Pred(Count) do
   454     begin
   457     begin
   455     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   458     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   456         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   459         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   457             begin
   460             begin
   458             if (cReducedQuality and rqBlurryLand) = 0 then
   461             if (Land[ty, tx] and lfIndestructible) = 0 then
   459                 begin
   462                 begin
   460                 by:= ty; bx:= tx;
   463                 if (cReducedQuality and rqBlurryLand) = 0 then
       
   464                     begin
       
   465                     by:= ty; bx:= tx;
       
   466                     end
       
   467                 else
       
   468                     begin
       
   469                     by:= ty div 2; bx:= tx div 2;
       
   470                     end;
       
   471                 if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
       
   472                     LandPixels[by, bx]:= LandBackPixel(tx, ty)
       
   473                 else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
       
   474                     LandPixels[by, bx]:= 0
   461                 end
   475                 end
   462             else
       
   463                 begin
       
   464                 by:= ty div 2; bx:= tx div 2;
       
   465                 end;
       
   466             if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then 
       
   467                 LandPixels[by, bx]:= LandBackPixel(tx, ty)
       
   468             else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then 
       
   469                 LandPixels[by, bx]:= 0
       
   470             end;
   476             end;
   471     inc(y, dY)
   477     inc(y, dY)
   472     end;
   478     end;
   473 
   479 
   474 inc(Radius, 4);
   480 inc(Radius, 4);
   580                 end
   586                 end
   581             else
   587             else
   582                 begin
   588                 begin
   583                 by:= ty div 2; bx:= tx div 2;
   589                 by:= ty div 2; bx:= tx div 2;
   584                 end;
   590                 end;
   585             if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
   591             if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
   586                     LandPixels[by, bx]:= LandBackPixel(tx, ty)
   592                 LandPixels[by, bx]:= LandBackPixel(tx, ty)
   587             else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
   593             else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   588                 LandPixels[by, bx]:= 0;
   594                 LandPixels[by, bx]:= 0
   589 
       
   590             Land[ty, tx]:= 0;
       
   591             end
   595             end
   592         end;
   596         end;
   593     for t:= 0 to 7 do
   597     for t:= 0 to 7 do
   594     begin
   598     begin
   595     X:= X + dX;
   599     X:= X + dX;
   911 SweepDirty:= bRes;
   915 SweepDirty:= bRes;
   912 end;
   916 end;
   913 
   917 
   914 
   918 
   915 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
   919 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
   916 function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
   920 function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; inline;
   917 begin
   921 begin
   918      CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0)
   922      CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0)
   919 end;
   923 end;
   920 
   924 
   921 function LandBackPixel(x, y: LongInt): LongWord;
   925 function LandBackPixel(x, y: LongInt): LongWord; inline;
   922 var p: PLongWordArray;
   926 var p: PLongWordArray;
   923 begin
   927 begin
   924     if LandBackSurface = nil then LandBackPixel:= 0
   928     if LandBackSurface = nil then LandBackPixel:= 0
   925     else
   929     else
   926     begin
   930     begin