hedgewars/uLandGraphics.pas
changeset 10601 3f4964eeaf01
parent 10600 e28d86fc393e
child 10674 fddbab2eecea
equal deleted inserted replaced
10600:e28d86fc393e 10601:3f4964eeaf01
   981     end
   981     end
   982 end;
   982 end;
   983 
   983 
   984 function SweepDirty: boolean;
   984 function SweepDirty: boolean;
   985 var x, y, xx, yy, ty, tx: LongInt;
   985 var x, y, xx, yy, ty, tx: LongInt;
   986     bRes, updateBlock, resweep, recheck: boolean;
   986     bRes, resweep, recheck: boolean;
   987 begin
   987 begin
   988 bRes:= false;
   988 bRes:= false;
   989 reCheck:= true;
   989 reCheck:= true;
   990 
   990 
   991 while recheck do
   991 while recheck do
   995         begin
   995         begin
   996         for x:= 0 to LAND_WIDTH div 32 - 1 do
   996         for x:= 0 to LAND_WIDTH div 32 - 1 do
   997             begin
   997             begin
   998             if LandDirty[y, x] = 1 then
   998             if LandDirty[y, x] = 1 then
   999                 begin
   999                 begin
  1000                 updateBlock:= false;
       
  1001                 resweep:= true;
  1000                 resweep:= true;
  1002                 ty:= y * 32;
  1001                 ty:= y * 32;
  1003                 tx:= x * 32;
  1002                 tx:= x * 32;
  1004                 while(resweep) do
  1003                 while(resweep) do
  1005                     begin
  1004                     begin
  1007                     for yy:= ty to ty + 31 do
  1006                     for yy:= ty to ty + 31 do
  1008                         for xx:= tx to tx + 31 do
  1007                         for xx:= tx to tx + 31 do
  1009                             if Despeckle(xx, yy) then
  1008                             if Despeckle(xx, yy) then
  1010                                 begin
  1009                                 begin
  1011                                 bRes:= true;
  1010                                 bRes:= true;
  1012                                 updateBlock:= true;
       
  1013                                 resweep:= true;
  1011                                 resweep:= true;
  1014                                 if (yy = ty) and (y > 0) then
  1012                                 if (yy = ty) and (y > 0) then
  1015                                     begin
  1013                                     begin
  1016                                     LandDirty[y-1, x]:= 1;
  1014                                     LandDirty[y-1, x]:= 1;
  1017                                     recheck:= true;
  1015                                     recheck:= true;
  1031                                     LandDirty[y, x+1]:= 1;
  1029                                     LandDirty[y, x+1]:= 1;
  1032                                     recheck:= true;
  1030                                     recheck:= true;
  1033                                     end
  1031                                     end
  1034                                 end;
  1032                                 end;
  1035                     end;
  1033                     end;
  1036                 if updateBlock then
       
  1037                     UpdateLandTexture(tx, 32, ty, 32, false);
       
  1038                 LandDirty[y, x]:= 2;
       
  1039                 end;
  1034                 end;
  1040             end;
  1035             end;
  1041         end;
  1036         end;
  1042      end;
  1037      end;
  1043 
  1038 
  1044 for y:= 0 to LAND_HEIGHT div 32 - 1 do
  1039 for y:= 0 to LAND_HEIGHT div 32 - 1 do
  1045     for x:= 0 to LAND_WIDTH div 32 - 1 do
  1040     for x:= 0 to LAND_WIDTH div 32 - 1 do
  1046         if LandDirty[y, x] <> 0 then
  1041         if LandDirty[y, x] <> 0 then
  1047             begin
  1042             begin
  1048             LandDirty[y, x]:= 0;
       
  1049             ty:= y * 32;
  1043             ty:= y * 32;
  1050             tx:= x * 32;
  1044             tx:= x * 32;
  1051             for yy:= ty to ty + 31 do
  1045             for yy:= ty to ty + 31 do
  1052                 for xx:= tx to tx + 31 do
  1046                 for xx:= tx to tx + 31 do
  1053                     Smooth(xx,yy)
  1047                     Smooth(xx,yy)
       
  1048             end;
       
  1049 
       
  1050 for y:= 0 to LAND_HEIGHT div 32 - 1 do
       
  1051     for x:= 0 to LAND_WIDTH div 32 - 1 do
       
  1052         if LandDirty[y, x] <> 0 then
       
  1053             begin
       
  1054             LandDirty[y, x]:= 0;
       
  1055             ty:= y * 32;
       
  1056             tx:= x * 32;
       
  1057             UpdateLandTexture(tx, 32, ty, 32, false);
  1054             end;
  1058             end;
  1055 
  1059 
  1056 SweepDirty:= bRes;
  1060 SweepDirty:= bRes;
  1057 end;
  1061 end;
  1058 
  1062