Revert most of optimisation except for some obvious fixes to errors someone or other introduced.
authornemo
Thu, 01 Jul 2010 00:34:39 -0400
changeset 3601 8a74c9ceaf71
parent 3600 b16a9c8461ec
child 3602 99c93fa258d6
Revert most of optimisation except for some obvious fixes to errors someone or other introduced. Something in the rest appears related to a crash in translation. Until I determine why or what, this stays out to not ruin people's games
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Wed Jun 30 23:21:46 2010 -0400
+++ b/hedgewars/uLandGraphics.pas	Thu Jul 01 00:34:39 2010 -0400
@@ -141,172 +141,153 @@
 end;
 
 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
-var i, t: LongInt;
+var i: LongInt;
 begin
-t:= y + dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if (not isMap and ((Land[y + dy, i] and lfIndestructible) = 0)) or ((Land[y + dy, i] and lfBasic) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
+                LandPixels[y + dy, i]:= 0
             else
-                LandPixels[t div 2, i div 2]:= 0;
+                LandPixels[(y + dy) div 2, i div 2]:= 0;
 
-t:= y - dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if (not isMap and ((Land[y - dy, i] and lfIndestructible) = 0)) or ((Land[y - dy, i] and lfBasic) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
+                LandPixels[y - dy, i]:= 0
             else
-                LandPixels[t div 2, i div 2]:= 0;
+                LandPixels[(y - dy) div 2, i div 2]:= 0;
 
-t:= y + dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if (not isMap and ((Land[y + dx, i] and lfIndestructible) = 0)) or ((Land[y + dx, i] and lfBasic) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
+                LandPixels[y + dx, i]:= 0
             else
-                LandPixels[t div 2, i div 2]:= 0;
+                LandPixels[(y + dx) div 2, i div 2]:= 0;
 
-t:= y - dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if (not isMap and ((Land[y - dx, i] and lfIndestructible) = 0)) or ((Land[y - dx, i] and lfBasic) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
+                LandPixels[y - dx, i]:= 0
             else
-                LandPixels[t div 2, i div 2]:= 0;
+                LandPixels[(y - dx) div 2, i div 2]:= 0;
 
 end;
 
 procedure FillLandCircleLinesBG(x, y, dx, dy: LongInt);
-var i, t: LongInt;
+var i: LongInt;
 begin
-t:= y + dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) then
+       if ((Land[y + dy, i] and lfBasic) <> 0) then
            if (cReducedQuality and rqBlurryLand) = 0 then
-               LandPixels[t, i]:= LandBackPixel(i, t)
+               LandPixels[y + dy, i]:= LandBackPixel(i, y + dy)
            else
-               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
+               LandPixels[(y + dy) div 2, i div 2]:= LandBackPixel(i, y + dy)
        else
-           if ((Land[t, i] and lfObject) <> 0) then
+           if ((Land[y + dy, i] and lfObject) <> 0) then
                if (cReducedQuality and rqBlurryLand) = 0 then
-                   LandPixels[t, i]:= 0
+                   LandPixels[y + dy, i]:= 0
                else
-                   LandPixels[t div 2, i div 2]:= 0;
+                   LandPixels[(y + dy) div 2, i div 2]:= 0;
 
-t:= y - dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) then
+       if ((Land[y - dy, i] and lfBasic) <> 0) then
            if (cReducedQuality and rqBlurryLand) = 0 then
-               LandPixels[t, i]:= LandBackPixel(i, t)
+               LandPixels[y - dy, i]:= LandBackPixel(i, y - dy)
            else
-               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
+               LandPixels[(y - dy) div 2, i div 2]:= LandBackPixel(i, y - dy)
        else
-           if ((Land[t, i] and lfObject) <> 0) then
+           if ((Land[y - dy, i] and lfObject) <> 0) then
                if (cReducedQuality and rqBlurryLand) = 0 then
-                   LandPixels[t, i]:= 0
+                   LandPixels[y - dy, i]:= 0
                else
-                   LandPixels[t div 2, i div 2]:= 0;
+                   LandPixels[(y - dy) div 2, i div 2]:= 0;
 
-t:= y + dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) then
+       if ((Land[y + dx, i] and lfBasic) <> 0) then
            if (cReducedQuality and rqBlurryLand) = 0 then
-           LandPixels[t, i]:= LandBackPixel(i, t)
+           LandPixels[y + dx, i]:= LandBackPixel(i, y + dx)
             else 
-           LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
+           LandPixels[(y + dx) div 2, i div 2]:= LandBackPixel(i, y + dx)
        else
-            if ((Land[t, i] and lfObject) <> 0) then
+            if ((Land[y + dx, i] and lfObject) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-          LandPixels[t, i]:= 0
+          LandPixels[y + dx, i]:= 0
             else
-           LandPixels[t div 2, i div 2]:= 0;
+           LandPixels[(y + dx) div 2, i div 2]:= 0;
 
-t:= y - dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) then
+       if ((Land[y - dx, i] and lfBasic) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-          LandPixels[t, i]:= LandBackPixel(i, t)
+          LandPixels[y - dx, i]:= LandBackPixel(i, y - dx)
         else 
-         LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
+         LandPixels[(y - dx) div 2, i div 2]:= LandBackPixel(i, y - dx)
 
        else
-          if ((Land[t, i] and lfObject) <> 0) then
+          if ((Land[y - dx, i] and lfObject) <> 0) then
               if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[t, i]:= 0
+                LandPixels[y - dx, i]:= 0
               else
-                LandPixels[t div 2, i div 2]:= 0;
+                LandPixels[(y - dx) div 2, i div 2]:= 0;
 
 end;
 
 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
-var i, t: LongInt;
+var i: LongInt;
 begin
-t:= y + dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
+       if ((Land[y + dy, i] and lfBasic) <> 0) or ((Land[y + dy, i] and lfObject) <> 0) then
           begin
            if (cReducedQuality and rqBlurryLand) = 0 then
-            LandPixels[t, i]:= cExplosionBorderColor
+            LandPixels[y + dy, i]:= cExplosionBorderColor
           else
-            LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
+            LandPixels[(y + dy) div 2, i div 2]:= cExplosionBorderColor;
 
-          Land[t, i]:= Land[t, i] or lfDamaged;
-          //Despeckle(i, t);
-          LandDirty[t div 32, i div 32]:= 1;
+          Land[y + dy, i]:= Land[y + dy, i] or lfDamaged;
+          LandDirty[(y + dy) div 32, i div 32]:= 1;
           end;
-
-t:= y - dy;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
+       if ((Land[y - dy, i] and lfBasic) <> 0) or ((Land[y - dy, i] and lfObject) <> 0) then
           begin
            if (cReducedQuality and rqBlurryLand) = 0 then
-              LandPixels[t, i]:= cExplosionBorderColor 
+              LandPixels[y - dy, i]:= cExplosionBorderColor 
             else
-              LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
-          Land[t, i]:= Land[t, i] or lfDamaged;
-          //Despeckle(i, t);
-          LandDirty[t div 32, i div 32]:= 1;
+              LandPixels[(y - dy) div 2, i div 2]:= cExplosionBorderColor;
+          Land[y - dy, i]:= Land[y - dy, i] or lfDamaged;
+          LandDirty[(y - dy) div 32, i div 32]:= 1;
           end;
-
-t:= y + dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
+       if ((Land[y + dx, i] and lfBasic) <> 0) or ((Land[y + dx, i] and lfObject) <> 0) then
            begin
            if (cReducedQuality and rqBlurryLand) = 0 then
-           LandPixels[t, i]:= cExplosionBorderColor
+           LandPixels[y + dx, i]:= cExplosionBorderColor
             else
-           LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
+           LandPixels[(y + dx) div 2, i div 2]:= cExplosionBorderColor;
 
-           Land[t, i]:= Land[t, i] or lfDamaged;
-           //Despeckle(i, t);
-           LandDirty[t div 32, i div 32]:= 1;
+           Land[y + dx, i]:= Land[y + dx, i] or lfDamaged;
+           LandDirty[(y + dx) div 32, i div 32]:= 1;
            end;
-
-t:= y - dx;
-if (t and LAND_HEIGHT_MASK) = 0 then
+if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
+       if ((Land[y - dx, i] and lfBasic) <> 0) or ((Land[y - dx, i] and lfObject) <> 0) then
           begin
            if (cReducedQuality and rqBlurryLand) = 0 then
-          LandPixels[t, i]:= cExplosionBorderColor 
+          LandPixels[y - dx, i]:= cExplosionBorderColor 
             else
-          LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
+          LandPixels[(y - dx) div 2, i div 2]:= cExplosionBorderColor;
 
-          Land[t, i]:= Land[t, i] or lfDamaged;
-          //Despeckle(i, y - dy);
-          LandDirty[t div 32, i div 32]:= 1;
+          Land[y - dx, i]:= Land[y - dx, i] or lfDamaged;
+          LandDirty[(y - dx) div 32, i div 32]:= 1;
           end;
 end;
 
@@ -651,7 +632,6 @@
 UpdateLandTexture(x, w, y, h)
 end;
 
-// was experimenting with applying as damage occurred.
 function Despeckle(X, Y: LongInt): boolean;
 var nx, ny, i, j, c: LongInt;
 begin
@@ -690,7 +670,7 @@
 end;
 
 function SweepDirty: boolean;
-var x, y, xx, yy, ty, tx: LongInt;
+var x, y, xx, yy: LongInt;
     bRes, updateBlock, resweep, recheck: boolean;
 begin
 bRes:= false;
@@ -707,41 +687,39 @@
                 begin
                 updateBlock:= false;
                 resweep:= true;
-                ty:= y shl 5;
-                tx:= x shl 5;
                 while(resweep) do
                     begin
                     resweep:= false;
-                    for yy:= ty to ty + 31 do
-                        for xx:= tx to tx + 31 do
+                    for yy:= y * 32 to y * 32 + 31 do
+                        for xx:= x * 32 to x * 32 + 31 do
                             if Despeckle(xx, yy) then
                                 begin
                                 bRes:= true;
                                 updateBlock:= true;
                                 resweep:= true;
-                                if (yy = ty) and (y > 0) then
+                                if (yy = y*32) and (y > 0) then
                                     begin
                                     LandDirty[y-1, x]:= 1;
                                     recheck:= true;
                                     end
-                                else if (yy = ty+31) and (y < LAND_HEIGHT div 32 - 1) then
+                                else if (yy = y*32+31) and (y < LAND_HEIGHT div 32 - 1) then
                                     begin
                                     LandDirty[y+1, x]:= 1;
                                     recheck:= true;
                                     end;
-                                if (xx = tx) and (x > 0) then
+                                if (xx = x*32) and (x > 0) then
                                     begin
                                     LandDirty[y, x-1]:= 1;
                                     recheck:= true;
                                     end
-                                else if (xx = tx+31) and (x < LAND_WIDTH div 32 - 1) then
+                                else if (xx = x*32+31) and (x < LAND_WIDTH div 32 - 1) then
                                     begin
-                                    LandDirty[y, tx+1]:= 1;
+                                    LandDirty[y, x+1]:= 1;
                                     recheck:= true;
                                     end
                                 end;
                     end;
-                if updateBlock then UpdateLandTexture(tx, 32, ty, 32);
+                if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32);
                 LandDirty[y, x]:= 0;
                 end;
             end;