hedgewars/uLandGraphics.pas
changeset 6982 8d41d22a291d
parent 6700 e04da46ee43c
child 6990 40e5af28d026
equal deleted inserted replaced
6981:045e8162c9cd 6982:8d41d22a291d
   326 if (t and LAND_HEIGHT_MASK) = 0 then
   326 if (t and LAND_HEIGHT_MASK) = 0 then
   327     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   327     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   328         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   328         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   329             begin
   329             begin
   330             if (cReducedQuality and rqBlurryLand) = 0 then
   330             if (cReducedQuality and rqBlurryLand) = 0 then
   331                 LandPixels[t, i]:= cExplosionBorderColor
   331                 LandPixels[t, i]:= ExplosionBorderColor
   332             else
   332             else
   333                 LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   333                 LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
   334 
   334 
   335             Land[t, i]:= Land[t, i] or lfDamaged;
   335             Land[t, i]:= Land[t, i] or lfDamaged;
   336             //Despeckle(i, t);
   336             //Despeckle(i, t);
   337             LandDirty[t div 32, i div 32]:= 1;
   337             LandDirty[t div 32, i div 32]:= 1;
   338             end;
   338             end;
   341 if (t and LAND_HEIGHT_MASK) = 0 then
   341 if (t and LAND_HEIGHT_MASK) = 0 then
   342     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   342     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   343         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   343         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   344             begin
   344             begin
   345             if (cReducedQuality and rqBlurryLand) = 0 then
   345             if (cReducedQuality and rqBlurryLand) = 0 then
   346                 LandPixels[t, i]:= cExplosionBorderColor
   346                 LandPixels[t, i]:= ExplosionBorderColor
   347             else
   347             else
   348                 LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   348                 LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
   349             Land[t, i]:= Land[t, i] or lfDamaged;
   349             Land[t, i]:= Land[t, i] or lfDamaged;
   350             //Despeckle(i, t);
   350             //Despeckle(i, t);
   351             LandDirty[t div 32, i div 32]:= 1;
   351             LandDirty[t div 32, i div 32]:= 1;
   352             end;
   352             end;
   353 
   353 
   355 if (t and LAND_HEIGHT_MASK) = 0 then
   355 if (t and LAND_HEIGHT_MASK) = 0 then
   356     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   356     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   357         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   357         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   358             begin
   358             begin
   359             if (cReducedQuality and rqBlurryLand) = 0 then
   359             if (cReducedQuality and rqBlurryLand) = 0 then
   360                 LandPixels[t, i]:= cExplosionBorderColor
   360                 LandPixels[t, i]:= ExplosionBorderColor
   361             else
   361             else
   362                LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   362                LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
   363 
   363 
   364             Land[t, i]:= Land[t, i] or lfDamaged;
   364             Land[t, i]:= Land[t, i] or lfDamaged;
   365             //Despeckle(i, t);
   365             //Despeckle(i, t);
   366             LandDirty[t div 32, i div 32]:= 1;
   366             LandDirty[t div 32, i div 32]:= 1;
   367             end;
   367             end;
   370 if (t and LAND_HEIGHT_MASK) = 0 then
   370 if (t and LAND_HEIGHT_MASK) = 0 then
   371     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   371     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   372         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   372         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   373             begin
   373             begin
   374             if (cReducedQuality and rqBlurryLand) = 0 then
   374             if (cReducedQuality and rqBlurryLand) = 0 then
   375                 LandPixels[t, i]:= cExplosionBorderColor
   375                 LandPixels[t, i]:= ExplosionBorderColor
   376             else
   376             else
   377                 LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
   377                 LandPixels[t div 2, i div 2]:= ExplosionBorderColor;
   378 
   378 
   379             Land[t, i]:= Land[t, i] or lfDamaged;
   379             Land[t, i]:= Land[t, i] or lfDamaged;
   380             //Despeckle(i, y - dy);
   380             //Despeckle(i, y - dy);
   381             LandDirty[t div 32, i div 32]:= 1;
   381             LandDirty[t div 32, i div 32]:= 1;
   382             end;
   382             end;
   501     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   501     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   502         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   502         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   503             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   503             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   504                 begin
   504                 begin
   505                  if (cReducedQuality and rqBlurryLand) = 0 then
   505                  if (cReducedQuality and rqBlurryLand) = 0 then
   506                     LandPixels[ty, tx]:= cExplosionBorderColor
   506                     LandPixels[ty, tx]:= ExplosionBorderColor
   507                 else
   507                 else
   508                     LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor;
   508                     LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor;
   509 
   509 
   510                 Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   510                 Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   511                 LandDirty[ty div 32, tx div 32]:= 1;
   511                 LandDirty[ty div 32, tx div 32]:= 1;
   512                 end;
   512                 end;
   513     inc(y, dY)
   513     inc(y, dY)
   553             begin
   553             begin
   554             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   554             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   555             LandDirty[ty div 32, tx div 32]:= 1
   555             LandDirty[ty div 32, tx div 32]:= 1
   556             end;
   556             end;
   557         if (cReducedQuality and rqBlurryLand) = 0 then
   557         if (cReducedQuality and rqBlurryLand) = 0 then
   558             LandPixels[ty, tx]:= cExplosionBorderColor
   558             LandPixels[ty, tx]:= ExplosionBorderColor
   559         else
   559         else
   560             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   560             LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
   561         end
   561         end
   562     end;
   562     end;
   563     nx:= nx - dY;
   563     nx:= nx - dY;
   564     ny:= ny + dX;
   564     ny:= ny + dX;
   565     end;
   565     end;
   579             begin
   579             begin
   580             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   580             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   581             if despeckle then
   581             if despeckle then
   582                 LandDirty[ty div 32, tx div 32]:= 1;
   582                 LandDirty[ty div 32, tx div 32]:= 1;
   583             if (cReducedQuality and rqBlurryLand) = 0 then
   583             if (cReducedQuality and rqBlurryLand) = 0 then
   584                 LandPixels[ty, tx]:= cExplosionBorderColor
   584                 LandPixels[ty, tx]:= ExplosionBorderColor
   585             else
   585             else
   586                 LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   586                 LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
   587             end
   587             end
   588         end;
   588         end;
   589     X:= nx;
   589     X:= nx;
   590     Y:= ny;
   590     Y:= ny;
   591     for t:= 0 to ticks do
   591     for t:= 0 to ticks do
   622         begin
   622         begin
   623         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   623         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   624         if despeckle then
   624         if despeckle then
   625             LandDirty[ty div 32, tx div 32]:= 1;
   625             LandDirty[ty div 32, tx div 32]:= 1;
   626         if (cReducedQuality and rqBlurryLand) = 0 then
   626         if (cReducedQuality and rqBlurryLand) = 0 then
   627             LandPixels[ty, tx]:= cExplosionBorderColor
   627             LandPixels[ty, tx]:= ExplosionBorderColor
   628         else
   628         else
   629             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   629             LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
   630         end
   630         end
   631         end;
   631         end;
   632     nx:= nx - dY;
   632     nx:= nx - dY;
   633     ny:= ny + dX;
   633     ny:= ny + dX;
   634     end;
   634     end;
   648         begin
   648         begin
   649         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   649         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   650         if despeckle then
   650         if despeckle then
   651             LandDirty[ty div 32, tx div 32]:= 1;
   651             LandDirty[ty div 32, tx div 32]:= 1;
   652         if (cReducedQuality and rqBlurryLand) = 0 then
   652         if (cReducedQuality and rqBlurryLand) = 0 then
   653             LandPixels[ty, tx]:= cExplosionBorderColor
   653             LandPixels[ty, tx]:= ExplosionBorderColor
   654         else
   654         else
   655             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   655             LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor
   656         end
   656         end
   657     end;
   657     end;
   658     nx:= nx - dY;
   658     nx:= nx - dY;
   659     ny:= ny + dX;
   659     ny:= ny + dX;
   660     end;
   660     end;
   822     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
   822     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
   823         begin
   823         begin
   824         if (cReducedQuality and rqBlurryLand) = 0 then
   824         if (cReducedQuality and rqBlurryLand) = 0 then
   825             begin
   825             begin
   826             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
   826             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
   827                 LandPixels[y,x]:= (cExplosionBorderColor and (not AMask)) or (128 shl AShift)
   827                 LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (128 shl AShift)
   828             else
   828             else
   829                 LandPixels[y,x]:=
   829                 LandPixels[y,x]:=
   830                                 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((cExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
   830                                 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
   831                                 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((cExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
   831                                 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
   832                                 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((cExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
   832                                 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
   833             end;
   833             end;
   834         if (Land[y, x-1] = lfObject) then
   834         if (Land[y, x-1] = lfObject) then
   835             Land[y,x]:= lfObject
   835             Land[y,x]:= lfObject
   836         else if (Land[y, x+1] = lfObject) then
   836         else if (Land[y, x+1] = lfObject) then
   837             Land[y,x]:= lfObject
   837             Land[y,x]:= lfObject
   848     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
   848     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
   849         begin
   849         begin
   850         if (cReducedQuality and rqBlurryLand) = 0 then
   850         if (cReducedQuality and rqBlurryLand) = 0 then
   851             begin
   851             begin
   852             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
   852             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
   853                 LandPixels[y,x]:= (cExplosionBorderColor and (not AMask)) or (64 shl AShift)
   853                 LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (64 shl AShift)
   854             else
   854             else
   855                 LandPixels[y,x]:=
   855                 LandPixels[y,x]:=
   856                                 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((cExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
   856                                 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
   857                                 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((cExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
   857                                 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
   858                                 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((cExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
   858                                 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
   859             end;
   859             end;
   860         if (Land[y, x-1] = lfObject) then
   860         if (Land[y, x-1] = lfObject) then
   861             Land[y, x]:= lfObject
   861             Land[y, x]:= lfObject
   862         else if (Land[y, x+1] = lfObject) then
   862         else if (Land[y, x+1] = lfObject) then
   863             Land[y, x]:= lfObject
   863             Land[y, x]:= lfObject
   874     begin
   874     begin
   875     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
   875     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
   876     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
   876     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
   877         begin
   877         begin
   878         LandPixels[y,x]:=
   878         LandPixels[y,x]:=
   879                         (((((LandPixels[y,x] and RMask shr RShift) div 2)+((cExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
   879                         (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
   880                         (((((LandPixels[y,x] and GMask shr GShift) div 2)+((cExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
   880                         (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
   881                         (((((LandPixels[y,x] and BMask shr BShift) div 2)+((cExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
   881                         (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
   882         end
   882         end
   883     else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
   883     else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
   884     or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
   884     or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
   885     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
   885     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
   886     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
   886     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
   888     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0))
   888     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0))
   889     or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))
   889     or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))
   890     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
   890     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
   891         begin
   891         begin
   892         LandPixels[y,x]:=
   892         LandPixels[y,x]:=
   893                         (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((cExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
   893                         (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
   894                         (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((cExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
   894                         (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
   895                         (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((cExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
   895                         (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
   896         end
   896         end
   897     end
   897     end
   898 end;
   898 end;
   899 
   899 
   900 function SweepDirty: boolean;
   900 function SweepDirty: boolean;