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