hedgewars/uLandGraphics.pas
branch0.9.15
changeset 4696 4102737cf2ac
parent 4695 ac2cb3b99d70
child 4700 e8fd20b2d66b
equal deleted inserted replaced
4693:6f74c97147fe 4696:4102737cf2ac
   188 begin
   188 begin
   189 cnt:= 0;
   189 cnt:= 0;
   190 t:= y + dy;
   190 t:= y + dy;
   191 if (t and LAND_HEIGHT_MASK) = 0 then
   191 if (t and LAND_HEIGHT_MASK) = 0 then
   192    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   192    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   193        if ((Land[t, i] and lfBasic) <> 0) then
   193        if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
   194            begin
   194            begin
   195            inc(cnt);
   195            inc(cnt);
   196            if (cReducedQuality and rqBlurryLand) = 0 then
   196            if (cReducedQuality and rqBlurryLand) = 0 then
   197                LandPixels[t, i]:= LandBackPixel(i, t)
   197                LandPixels[t, i]:= LandBackPixel(i, t)
   198            else
   198            else
   199                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   199                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   200            end
   200            end
   201        else
   201        else
   202            if ((Land[t, i] and lfObject) <> 0) then
   202            if ((Land[t, i] and lfObject) <> 0) or disableLandBack then
   203                if (cReducedQuality and rqBlurryLand) = 0 then
   203                if (cReducedQuality and rqBlurryLand) = 0 then
   204                    LandPixels[t, i]:= 0
   204                    LandPixels[t, i]:= 0
   205                else
   205                else
   206                    LandPixels[t div 2, i div 2]:= 0;
   206                    LandPixels[t div 2, i div 2]:= 0;
   207 
   207 
   208 t:= y - dy;
   208 t:= y - dy;
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   210    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   210    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   211        if ((Land[t, i] and lfBasic) <> 0) then
   211        if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
   212            begin
   212            begin
   213            inc(cnt);
   213            inc(cnt);
   214            if (cReducedQuality and rqBlurryLand) = 0 then
   214            if (cReducedQuality and rqBlurryLand) = 0 then
   215                LandPixels[t, i]:= LandBackPixel(i, t)
   215                LandPixels[t, i]:= LandBackPixel(i, t)
   216            else
   216            else
   217                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   217                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   218            end
   218            end
   219        else
   219        else
   220            if ((Land[t, i] and lfObject) <> 0) then
   220            if ((Land[t, i] and lfObject) <> 0) or disableLandBack then
   221                if (cReducedQuality and rqBlurryLand) = 0 then
   221                if (cReducedQuality and rqBlurryLand) = 0 then
   222                    LandPixels[t, i]:= 0
   222                    LandPixels[t, i]:= 0
   223                else
   223                else
   224                    LandPixels[t div 2, i div 2]:= 0;
   224                    LandPixels[t div 2, i div 2]:= 0;
   225 
   225 
   226 t:= y + dx;
   226 t:= y + dx;
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   228    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   228    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   229        if ((Land[t, i] and lfBasic) <> 0) then
   229        if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
   230            begin
       
   231            inc(cnt);
       
   232            if (cReducedQuality and rqBlurryLand) = 0 then
       
   233            LandPixels[t, i]:= LandBackPixel(i, t)
       
   234             else
       
   235            LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
       
   236            end
       
   237        else
       
   238             if ((Land[t, i] and lfObject) <> 0) then
       
   239             if (cReducedQuality and rqBlurryLand) = 0 then
       
   240           LandPixels[t, i]:= 0
       
   241             else
       
   242            LandPixels[t div 2, i div 2]:= 0;
       
   243 
       
   244 t:= y - dx;
       
   245 if (t and LAND_HEIGHT_MASK) = 0 then
       
   246    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
       
   247        if ((Land[t, i] and lfBasic) <> 0) then
       
   248            begin
   230            begin
   249            inc(cnt);
   231            inc(cnt);
   250            if (cReducedQuality and rqBlurryLand) = 0 then
   232            if (cReducedQuality and rqBlurryLand) = 0 then
   251                LandPixels[t, i]:= LandBackPixel(i, t)
   233                LandPixels[t, i]:= LandBackPixel(i, t)
   252            else
   234            else
   253                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   235                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   254            end
   236            end
   255        else
   237        else
   256           if ((Land[t, i] and lfObject) <> 0) then
   238            if ((Land[t, i] and lfObject) <> 0) or disableLandBack then
       
   239                if (cReducedQuality and rqBlurryLand) = 0 then
       
   240                    LandPixels[t, i]:= 0
       
   241                else
       
   242                    LandPixels[t div 2, i div 2]:= 0;
       
   243 
       
   244 t:= y - dx;
       
   245 if (t and LAND_HEIGHT_MASK) = 0 then
       
   246    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
       
   247        if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
       
   248            begin
       
   249            inc(cnt);
       
   250            if (cReducedQuality and rqBlurryLand) = 0 then
       
   251                LandPixels[t, i]:= LandBackPixel(i, t)
       
   252            else
       
   253                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
       
   254            end
       
   255        else
       
   256            if ((Land[t, i] and lfObject) <> 0) or disableLandBack then
   257               if (cReducedQuality and rqBlurryLand) = 0 then
   257               if (cReducedQuality and rqBlurryLand) = 0 then
   258                 LandPixels[t, i]:= 0
   258                   LandPixels[t, i]:= 0
   259               else
   259               else
   260                 LandPixels[t div 2, i div 2]:= 0;
   260                   LandPixels[t div 2, i div 2]:= 0;
   261 FillLandCircleLinesBG:= cnt;
   261 FillLandCircleLinesBG:= cnt;
   262 end;
   262 end;
   263 
   263 
   264 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   264 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   265 var i, t: LongInt;
   265 var i, t: LongInt;
   407 begin
   407 begin
   408 for i:= 0 to Pred(Count) do
   408 for i:= 0 to Pred(Count) do
   409     begin
   409     begin
   410     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   410     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   411         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   411         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   412             if (Land[ty, tx] and lfBasic) <> 0 then
   412             if ((Land[ty, tx] and lfBasic) <> 0) and not disableLandBack then
   413                 if (cReducedQuality and rqBlurryLand) = 0 then
   413                 if (cReducedQuality and rqBlurryLand) = 0 then
   414                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   414                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   415                 else
   415                 else
   416                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   416                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   417             else
   417             else
   418                 if (Land[ty, tx] and lfObject) <> 0 then
   418                 if ((Land[ty, tx] and lfObject) <> 0) or disableLandBack then
   419                     if (cReducedQuality and rqBlurryLand) = 0 then
   419                     if (cReducedQuality and rqBlurryLand) = 0 then
   420                         LandPixels[ty, tx]:= 0
   420                         LandPixels[ty, tx]:= 0
   421                     else
   421                     else
   422                         LandPixels[ty div 2, tx div 2]:= 0;
   422                         LandPixels[ty div 2, tx div 2]:= 0;
   423     inc(y, dY)
   423     inc(y, dY)
   519         Y:= Y + dY;
   519         Y:= Y + dY;
   520         tx:= hwRound(X);
   520         tx:= hwRound(X);
   521         ty:= hwRound(Y);
   521         ty:= hwRound(Y);
   522         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then
   522         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then
   523             begin
   523             begin
   524             if (Land[ty, tx] and lfBasic) <> 0 then
   524             if ((Land[ty, tx] and lfBasic) <> 0) and not disableLandBack then
   525                 if (cReducedQuality and rqBlurryLand) = 0 then
   525                 if (cReducedQuality and rqBlurryLand) = 0 then
   526                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   526                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   527                 else
   527                 else
   528                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   528                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   529             else
   529             else
   530               if (Land[ty, tx] and lfObject) <> 0 then
   530               if ((Land[ty, tx] and lfObject) <> 0) or disableLandBack then
   531                 if (cReducedQuality and rqBlurryLand) = 0 then
   531                 if (cReducedQuality and rqBlurryLand) = 0 then
   532                 LandPixels[ty, tx]:= 0
   532                 LandPixels[ty, tx]:= 0
   533                 else
   533                 else
   534                 LandPixels[ty div 2, tx div 2]:= 0;
   534                 LandPixels[ty div 2, tx div 2]:= 0;
   535 
   535 
   668 UpdateLandTexture(x, w, y, h)
   668 UpdateLandTexture(x, w, y, h)
   669 end;
   669 end;
   670 
   670 
   671 // was experimenting with applying as damage occurred.
   671 // was experimenting with applying as damage occurred.
   672 function Despeckle(X, Y: LongInt): boolean;
   672 function Despeckle(X, Y: LongInt): boolean;
   673 var nx, ny, i, j, c: LongInt;
   673 var nx, ny, i, j, c, xx, yy: LongInt;
   674 begin
   674     pixelsweep: boolean;
   675 if ((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0) then // check neighbours
   675 begin
       
   676 if (cReducedQuality and rqBlurryLand) = 0 then
       
   677    begin
       
   678    xx:= X;
       
   679    yy:= Y;
       
   680    end
       
   681 else
       
   682    begin
       
   683    xx:= X div 2;
       
   684    yy:= Y div 2;
       
   685    end;
       
   686 pixelsweep:= ((Land[Y, X] and $FF00) = 0) and (LandPixels[yy, xx] <> 0);
       
   687 if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then
   676     begin
   688     begin
   677     c:= 0;
   689     c:= 0;
   678     for i:= -1 to 1 do
   690     for i:= -1 to 1 do
   679         for j:= -1 to 1 do
   691         for j:= -1 to 1 do
   680             if (i <> 0) or (j <> 0) then
   692             if (i <> 0) or (j <> 0) then
   681                 begin
   693                 begin
   682                 ny:= Y + i;
   694                 ny:= Y + i;
   683                 nx:= X + j;
   695                 nx:= X + j;
   684                 if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then
   696                 if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then
   685                     if Land[ny, nx] > 255 then
   697                     begin
   686                         inc(c);
   698                     if pixelsweep then
       
   699                         begin
       
   700                         if ((cReducedQuality and rqBlurryLand) <> 0) then
       
   701                             begin
       
   702                             nx:= nx div 2;
       
   703                             ny:= ny div 2
       
   704                             end;
       
   705                         if LandPixels[ny, nx] <> 0 then inc(c);
       
   706                         end
       
   707                     else if Land[ny, nx] > 255 then inc(c);
       
   708                     end
   687                 end;
   709                 end;
   688 
   710 
   689     if c < 4 then // 0-3 neighbours
   711     if c < 4 then // 0-3 neighbours
   690         begin
   712         begin
   691         if (cReducedQuality and rqBlurryLand) = 0 then
   713         if ((Land[Y, X] and lfBasic) <> 0) and not disableLandBack then
   692             if (Land[Y, X] and lfBasic) <> 0 then
   714             LandPixels[yy, xx]:= LandBackPixel(X, Y)
   693                 LandPixels[Y, X]:= LandBackPixel(X, Y)
       
   694             else
       
   695                 LandPixels[Y, X]:= 0
       
   696         else
   715         else
   697             if (Land[Y, X] and lfBasic) <> 0 then
   716             LandPixels[yy, xx]:= 0;
   698                 LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y)
       
   699             else
       
   700                 LandPixels[Y div 2, X div 2]:= 0;
       
   701 
   717 
   702         Land[Y, X]:= 0;
   718         Land[Y, X]:= 0;
   703         exit(true);
   719         if not pixelsweep then exit(true);
   704         end;
   720         end;
   705     end;
   721     end;
   706 Despeckle:= false
   722 Despeckle:= false
   707 end;
   723 end;
   708 
   724