hedgewars/uLandGraphics.pas
changeset 3554 066faceb977d
parent 3521 96a502730e81
child 3595 341e407e3754
equal deleted inserted replaced
3553:eed7ab6a5087 3554:066faceb977d
   672 Despeckle:= false
   672 Despeckle:= false
   673 end;
   673 end;
   674 
   674 
   675 function SweepDirty: boolean;
   675 function SweepDirty: boolean;
   676 var x, y, xx, yy: LongInt;
   676 var x, y, xx, yy: LongInt;
   677     bRes, updateBlock, resweep: boolean;
   677     bRes, updateBlock, resweep, recheck: boolean;
   678 begin
   678 begin
   679 bRes:= false;
   679 bRes:= false;
   680 
   680 reCheck:= true;
   681 for y:= 0 to LAND_HEIGHT div 32 - 1 do
   681 
   682     begin
   682 while recheck do
   683 
   683     begin
   684     for x:= 0 to LAND_WIDTH div 32 - 1 do
   684     recheck:= false;
   685         begin
   685     for y:= 0 to LAND_HEIGHT div 32 - 1 do
   686         if LandDirty[y, x] <> 0 then
   686         begin
       
   687         for x:= 0 to LAND_WIDTH div 32 - 1 do
   687             begin
   688             begin
   688             updateBlock:= false;
   689             if LandDirty[y, x] <> 0 then
   689             resweep:= true;
       
   690             while(resweep) do
       
   691                 begin
   690                 begin
   692                 resweep:= false;
   691                 updateBlock:= false;
   693                 for yy:= y * 32 to y * 32 + 31 do
   692                 resweep:= true;
   694                     for xx:= x * 32 to x * 32 + 31 do
   693                 while(resweep) do
   695                         if Despeckle(xx, yy) then
   694                     begin
   696                             begin
   695                     resweep:= false;
   697                             bRes:= true;
   696                     for yy:= y * 32 to y * 32 + 31 do
   698                             updateBlock:= true;
   697                         for xx:= x * 32 to x * 32 + 31 do
   699                             resweep:= true;
   698                             if Despeckle(xx, yy) then
   700                             end;
   699                                 begin
       
   700                                 bRes:= true;
       
   701                                 updateBlock:= true;
       
   702                                 resweep:= true;
       
   703                                 if (yy = y*32) and (y > 0) then
       
   704                                     begin
       
   705                                     LandDirty[y-1, x]:= 1;
       
   706                                     recheck:= true;
       
   707                                     end
       
   708                                 else if (yy = y*32+31) and (y < LAND_HEIGHT div 32 - 1) then
       
   709                                     begin
       
   710                                     LandDirty[y+1, x]:= 1;
       
   711                                     recheck:= true;
       
   712                                     end;
       
   713                                 if (xx = x*32) and (x > 0) then
       
   714                                     begin
       
   715                                     LandDirty[y, x-1]:= 1;
       
   716                                     recheck:= true;
       
   717                                     end
       
   718                                 else if (xx = x*32+31) and (x < LAND_WIDTH div 32 - 1) then
       
   719                                     begin
       
   720                                     LandDirty[y, x+1]:= 1;
       
   721                                     recheck:= true;
       
   722                                     end
       
   723                                 end;
       
   724                     end;
       
   725                 if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32);
       
   726                 LandDirty[y, x]:= 0;
   701                 end;
   727                 end;
   702             if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32);
       
   703             LandDirty[y, x]:= 0;
       
   704             end;
   728             end;
   705         end;
   729         end;
   706     end;
   730      end;
   707 
   731 
   708 SweepDirty:= bRes;
   732 SweepDirty:= bRes;
   709 end;
   733 end;
   710 
   734 
   711 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
   735 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc