hedgewars/uLandGraphics.pas
changeset 4647 20b982afbe6e
parent 4640 bc30434ae156
child 4659 ce5897f53072
equal deleted inserted replaced
4588:5ef5415c4ee1 4647:20b982afbe6e
   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 if not isMap or ((Land[t, i] and lfObject) <> 0) then
   202            if ((Land[t, i] and lfObject) <> 0) then
   202            begin
   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            end;
   207 
   208 
   208 t:= y - dy;
   209 t:= y - dy;
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   210 if (t and LAND_HEIGHT_MASK) = 0 then
   210    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   211    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   211        if ((Land[t, i] and lfBasic) <> 0) then
   212        if ((Land[t, i] and lfBasic) <> 0) then
   214            if (cReducedQuality and rqBlurryLand) = 0 then
   215            if (cReducedQuality and rqBlurryLand) = 0 then
   215                LandPixels[t, i]:= LandBackPixel(i, t)
   216                LandPixels[t, i]:= LandBackPixel(i, t)
   216            else
   217            else
   217                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   218                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   218            end
   219            end
   219        else
   220        else if not isMap or ((Land[t, i] and lfObject) <> 0) then
   220            if ((Land[t, i] and lfObject) <> 0) then
   221            begin
   221                if (cReducedQuality and rqBlurryLand) = 0 then
   222            if (cReducedQuality and rqBlurryLand) = 0 then
   222                    LandPixels[t, i]:= 0
   223                LandPixels[t, i]:= 0
   223                else
   224            else
   224                    LandPixels[t div 2, i div 2]:= 0;
   225                LandPixels[t div 2, i div 2]:= 0
       
   226            end;
   225 
   227 
   226 t:= y + dx;
   228 t:= y + dx;
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   229 if (t and LAND_HEIGHT_MASK) = 0 then
   228    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   230    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   229        if ((Land[t, i] and lfBasic) <> 0) then
   231        if ((Land[t, i] and lfBasic) <> 0) then
   230            begin
   232            begin
   231            inc(cnt);
   233            inc(cnt);
   232            if (cReducedQuality and rqBlurryLand) = 0 then
   234            if (cReducedQuality and rqBlurryLand) = 0 then
   233            LandPixels[t, i]:= LandBackPixel(i, t)
   235                LandPixels[t, i]:= LandBackPixel(i, t)
       
   236            else
       
   237                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
       
   238            end
       
   239        else if not isMap or ((Land[t, i] and lfObject) <> 0) then
       
   240             begin
       
   241             if (cReducedQuality and rqBlurryLand) = 0 then
       
   242           	    LandPixels[t, i]:= 0
   234             else
   243             else
   235            LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   244            	    LandPixels[t div 2, i div 2]:= 0
   236            end
   245             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 
   246 
   244 t:= y - dx;
   247 t:= y - dx;
   245 if (t and LAND_HEIGHT_MASK) = 0 then
   248 if (t and LAND_HEIGHT_MASK) = 0 then
   246    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   249    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   247        if ((Land[t, i] and lfBasic) <> 0) then
   250        if ((Land[t, i] and lfBasic) <> 0) then
   250            if (cReducedQuality and rqBlurryLand) = 0 then
   253            if (cReducedQuality and rqBlurryLand) = 0 then
   251                LandPixels[t, i]:= LandBackPixel(i, t)
   254                LandPixels[t, i]:= LandBackPixel(i, t)
   252            else
   255            else
   253                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   256                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
   254            end
   257            end
   255        else
   258        else if not isMap or ((Land[t, i] and lfObject) <> 0) then
   256           if ((Land[t, i] and lfObject) <> 0) then
   259            begin
   257               if (cReducedQuality and rqBlurryLand) = 0 then
   260            if (cReducedQuality and rqBlurryLand) = 0 then
   258                 LandPixels[t, i]:= 0
   261                LandPixels[t, i]:= 0
   259               else
   262            else
   260                 LandPixels[t div 2, i div 2]:= 0;
   263                LandPixels[t div 2, i div 2]:= 0
       
   264            end;
   261 FillLandCircleLinesBG:= cnt;
   265 FillLandCircleLinesBG:= cnt;
   262 end;
   266 end;
   263 
   267 
   264 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   268 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   265 var i, t: LongInt;
   269 var i, t: LongInt;
   266 begin
   270 begin
   267 t:= y + dy;
   271 t:= y + dy;
   268 if (t and LAND_HEIGHT_MASK) = 0 then
   272 if (t and LAND_HEIGHT_MASK) = 0 then
   269    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   273    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   270        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   274        if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
   271           begin
   275           begin
   272            if (cReducedQuality and rqBlurryLand) = 0 then
   276            if (cReducedQuality and rqBlurryLand) = 0 then
   273             LandPixels[t, i]:= cExplosionBorderColor
   277             LandPixels[t, i]:= cExplosionBorderColor
   274           else
   278           else
   275             LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   279             LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   280           end;
   284           end;
   281 
   285 
   282 t:= y - dy;
   286 t:= y - dy;
   283 if (t and LAND_HEIGHT_MASK) = 0 then
   287 if (t and LAND_HEIGHT_MASK) = 0 then
   284    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   288    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   285        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   289        if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
   286           begin
   290           begin
   287            if (cReducedQuality and rqBlurryLand) = 0 then
   291            if (cReducedQuality and rqBlurryLand) = 0 then
   288               LandPixels[t, i]:= cExplosionBorderColor
   292               LandPixels[t, i]:= cExplosionBorderColor
   289             else
   293             else
   290               LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   294               LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   294           end;
   298           end;
   295 
   299 
   296 t:= y + dx;
   300 t:= y + dx;
   297 if (t and LAND_HEIGHT_MASK) = 0 then
   301 if (t and LAND_HEIGHT_MASK) = 0 then
   298    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   302    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   299        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   303        if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
   300            begin
   304            begin
   301            if (cReducedQuality and rqBlurryLand) = 0 then
   305            if (cReducedQuality and rqBlurryLand) = 0 then
   302            LandPixels[t, i]:= cExplosionBorderColor
   306            LandPixels[t, i]:= cExplosionBorderColor
   303             else
   307             else
   304            LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   308            LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   309            end;
   313            end;
   310 
   314 
   311 t:= y - dx;
   315 t:= y - dx;
   312 if (t and LAND_HEIGHT_MASK) = 0 then
   316 if (t and LAND_HEIGHT_MASK) = 0 then
   313    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   317    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   314        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   318        if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
   315           begin
   319           begin
   316            if (cReducedQuality and rqBlurryLand) = 0 then
   320            if (cReducedQuality and rqBlurryLand) = 0 then
   317           LandPixels[t, i]:= cExplosionBorderColor
   321           LandPixels[t, i]:= cExplosionBorderColor
   318             else
   322             else
   319           LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   323           LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   412             if (Land[ty, tx] and lfBasic) <> 0 then
   416             if (Land[ty, tx] and lfBasic) <> 0 then
   413                 if (cReducedQuality and rqBlurryLand) = 0 then
   417                 if (cReducedQuality and rqBlurryLand) = 0 then
   414                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   418                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   415                 else
   419                 else
   416                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   420                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   417             else
   421             else if not isMap then
   418                 if (Land[ty, tx] and lfObject) <> 0 then
   422                 begin
   419                     if (cReducedQuality and rqBlurryLand) = 0 then
   423 	        if (cReducedQuality and rqBlurryLand) = 0 then
   420                         LandPixels[ty, tx]:= 0
   424 	     	    LandPixels[ty, tx]:= 0
   421                     else
   425 	        else
   422                         LandPixels[ty div 2, tx div 2]:= 0;
   426 		    LandPixels[ty div 2, tx div 2]:= 0
       
   427                 end;
   423     inc(y, dY)
   428     inc(y, dY)
   424     end;
   429     end;
   425 
   430 
   426 inc(Radius, 4);
   431 inc(Radius, 4);
   427 dec(y, Count * dY);
   432 dec(y, Count * dY);
   428 
   433 
   429 for i:= 0 to Pred(Count) do
   434 for i:= 0 to Pred(Count) do
   430     begin
   435     begin
   431     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   436     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   432         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   437         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   433             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   438             if (Land[ty, tx] and (lfBasic or lfObject)) <> 0 then
   434                 begin
   439                 begin
   435                     if (cReducedQuality and rqBlurryLand) = 0 then
   440                     if (cReducedQuality and rqBlurryLand) = 0 then
   436                         LandPixels[ty, tx]:= cExplosionBorderColor
   441                         LandPixels[ty, tx]:= cExplosionBorderColor
   437                     else
   442                     else
   438                         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor;
   443                         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor;
   472     Y:= Y + dY;
   477     Y:= Y + dY;
   473     tx:= hwRound(X);
   478     tx:= hwRound(X);
   474     ty:= hwRound(Y);
   479     ty:= hwRound(Y);
   475     if ((ty and LAND_HEIGHT_MASK) = 0) and
   480     if ((ty and LAND_HEIGHT_MASK) = 0) and
   476        ((tx and LAND_WIDTH_MASK) = 0) and
   481        ((tx and LAND_WIDTH_MASK) = 0) and
   477        (((Land[ty, tx] and lfBasic) <> 0) or
   482        ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
   478        ((Land[ty, tx] and lfObject) <> 0)) then
       
   479         begin
   483         begin
   480         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   484         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   481             if (cReducedQuality and rqBlurryLand) = 0 then
   485         if (cReducedQuality and rqBlurryLand) = 0 then
   482             LandPixels[ty, tx]:= cExplosionBorderColor
   486             LandPixels[ty, tx]:= cExplosionBorderColor
   483             else
   487         else
   484             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   488             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   485         end
   489         end
   486     end;
   490     end;
   487     nx:= nx - dY;
   491     nx:= nx - dY;
   488     ny:= ny + dX;
   492     ny:= ny + dX;
   498     Y:= Y + dY;
   502     Y:= Y + dY;
   499     tx:= hwRound(X);
   503     tx:= hwRound(X);
   500     ty:= hwRound(Y);
   504     ty:= hwRound(Y);
   501     if ((ty and LAND_HEIGHT_MASK) = 0) and
   505     if ((ty and LAND_HEIGHT_MASK) = 0) and
   502        ((tx and LAND_WIDTH_MASK) = 0) and
   506        ((tx and LAND_WIDTH_MASK) = 0) and
   503        (((Land[ty, tx] and lfBasic) <> 0) or
   507        ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
   504        ((Land[ty, tx] and lfObject) <> 0)) then
       
   505         begin
   508         begin
   506         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   509         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   507             if (cReducedQuality and rqBlurryLand) = 0 then
   510         if (cReducedQuality and rqBlurryLand) = 0 then 
   508         LandPixels[ty, tx]:= cExplosionBorderColor
   511             LandPixels[ty, tx]:= cExplosionBorderColor
   509             else
   512 	    else
   510         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   513             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   511 
       
   512         end
   514         end
   513     end;
   515     end;
   514     X:= nx;
   516     X:= nx;
   515     Y:= ny;
   517     Y:= ny;
   516     for t:= 0 to ticks do
   518     for t:= 0 to ticks do
   524             if (Land[ty, tx] and lfBasic) <> 0 then
   526             if (Land[ty, tx] and lfBasic) <> 0 then
   525                 if (cReducedQuality and rqBlurryLand) = 0 then
   527                 if (cReducedQuality and rqBlurryLand) = 0 then
   526                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   528                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   527                 else
   529                 else
   528                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   530                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   529             else
   531             else if not isMap or ((Land[ty, tx] and lfObject) <> 0) then
   530               if (Land[ty, tx] and lfObject) <> 0 then
   532                 begin
   531                 if (cReducedQuality and rqBlurryLand) = 0 then
   533                 if (cReducedQuality and rqBlurryLand) = 0 then
   532                 LandPixels[ty, tx]:= 0
   534                      LandPixels[ty, tx]:= 0
   533                 else
   535                 else
   534                 LandPixels[ty div 2, tx div 2]:= 0;
   536                      LandPixels[ty div 2, tx div 2]:= 0
       
   537                 end;
   535 
   538 
   536             Land[ty, tx]:= 0;
   539             Land[ty, tx]:= 0;
   537             end
   540             end
   538         end;
   541         end;
   539     for t:= 0 to 7 do
   542     for t:= 0 to 7 do
   542     Y:= Y + dY;
   545     Y:= Y + dY;
   543     tx:= hwRound(X);
   546     tx:= hwRound(X);
   544     ty:= hwRound(Y);
   547     ty:= hwRound(Y);
   545     if ((ty and LAND_HEIGHT_MASK) = 0) and
   548     if ((ty and LAND_HEIGHT_MASK) = 0) and
   546        ((tx and LAND_WIDTH_MASK) = 0) and
   549        ((tx and LAND_WIDTH_MASK) = 0) and
   547        (((Land[ty, tx] and lfBasic) <> 0) or
   550        ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
   548        ((Land[ty, tx] and lfObject) <> 0)) then
       
   549         begin
   551         begin
   550         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   552         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   551         if (cReducedQuality and rqBlurryLand) = 0 then
   553         if (cReducedQuality and rqBlurryLand) = 0 then
   552         LandPixels[ty, tx]:= cExplosionBorderColor
   554             LandPixels[ty, tx]:= cExplosionBorderColor
   553         else
   555         else
   554         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   556             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   555 
       
   556         end
   557         end
   557     end;
   558     end;
   558     nx:= nx - dY;
   559     nx:= nx - dY;
   559     ny:= ny + dX;
   560     ny:= ny + dX;
   560     end;
   561     end;
   569     Y:= Y + dY;
   570     Y:= Y + dY;
   570     tx:= hwRound(X);
   571     tx:= hwRound(X);
   571     ty:= hwRound(Y);
   572     ty:= hwRound(Y);
   572     if ((ty and LAND_HEIGHT_MASK) = 0) and
   573     if ((ty and LAND_HEIGHT_MASK) = 0) and
   573        ((tx and LAND_WIDTH_MASK) = 0) and
   574        ((tx and LAND_WIDTH_MASK) = 0) and
   574        (((Land[ty, tx] and lfBasic) <> 0) or
   575        ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
   575        ((Land[ty, tx] and lfObject) <> 0)) then
       
   576         begin
   576         begin
   577         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   577         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   578         if (cReducedQuality and rqBlurryLand) = 0 then
   578         if (cReducedQuality and rqBlurryLand) = 0 then
   579         LandPixels[ty, tx]:= cExplosionBorderColor
   579             LandPixels[ty, tx]:= cExplosionBorderColor
   580         else
   580         else
   581         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   581             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   582         end
   582         end
   583     end;
   583     end;
   584     nx:= nx - dY;
   584     nx:= nx - dY;
   585     ny:= ny + dX;
   585     ny:= ny + dX;
   586     end;
   586     end;
   687                 end;
   687                 end;
   688 
   688 
   689     if c < 4 then // 0-3 neighbours
   689     if c < 4 then // 0-3 neighbours
   690         begin
   690         begin
   691         if (cReducedQuality and rqBlurryLand) = 0 then
   691         if (cReducedQuality and rqBlurryLand) = 0 then
       
   692             begin
   692             if (Land[Y, X] and lfBasic) <> 0 then
   693             if (Land[Y, X] and lfBasic) <> 0 then
   693                 LandPixels[Y, X]:= LandBackPixel(X, Y)
   694                 LandPixels[Y, X]:= LandBackPixel(X, Y)
   694             else
   695             else if not isMap or ((Land[Y, X] and lfObject) <> 0) then
   695                 LandPixels[Y, X]:= 0
   696                 LandPixels[Y, X]:= 0
       
   697             end
   696         else
   698         else
   697             if (Land[Y, X] and lfBasic) <> 0 then
   699             if (Land[Y, X] and lfBasic) <> 0 then
   698                 LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y)
   700                 LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y)
   699             else
   701             else if not isMap or ((Land[Y, X] and lfObject) <> 0) then
   700                 LandPixels[Y div 2, X div 2]:= 0;
   702                 LandPixels[Y div 2, X div 2]:= 0;
   701 
   703 
   702         Land[Y, X]:= 0;
   704         Land[Y, X]:= 0;
   703         exit(true);
   705         exit(true);
   704         end;
   706         end;