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