hedgewars/uLandGraphics.pas
changeset 7270 93e92e82d5c8
parent 7268 3a61c53346a8
child 7492 3188794b9d87
--- a/hedgewars/uLandGraphics.pas	Sat Jun 23 22:44:11 2012 +0400
+++ b/hedgewars/uLandGraphics.pas	Sat Jun 23 21:37:47 2012 -0400
@@ -36,7 +36,7 @@
 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
-procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
+procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
 function  LandBackPixel(x, y: LongInt): LongWord;
 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
 procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
@@ -99,46 +99,62 @@
             Land[y - dx, i]:= Value;
 end;
 
-procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
+procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet, isCurrent: boolean);
 var i: LongInt;
 begin
 if not doSet then
     begin
     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[y + dy, i] > 0) and (Land[y + dy, i] < 256) then
-                dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data
+            if isCurrent then 
+                Land[y + dy, i]:= Land[y + dy, i] and $FF7F
+            else if Land[y + dy, i] and $007F > 0 then
+                Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) - 1);
     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[y - dy, i] > 0) and (Land[y - dy, i] < 256) then
-                dec(Land[y - dy, i]);
+            if isCurrent then 
+                Land[y - dy, i]:= Land[y - dy, i] and $FF7F
+            else if Land[y - dy, i] and $007F > 0 then
+                Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) - 1);
     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[y + dx, i] > 0) and (Land[y + dx, i] < 256) then
-                dec(Land[y + dx, i]);
+            if isCurrent then 
+                Land[y + dx, i]:= Land[y + dx, i] and $FF7F
+            else if Land[y + dx, i] and $007F > 0 then
+                Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) - 1);
     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[y - dx, i] > 0) and (Land[y - dx, i] < 256) then
-                dec(Land[y - dx, i]);
+            if isCurrent then 
+                Land[y - dx, i]:= Land[y - dx, i] and $FF7F
+            else if Land[y - dx, i] and $007F > 0 then
+                Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) - 1)
     end
 else
     begin
     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[y + dy, i] < 256) then
-                inc(Land[y + dy, i]);
-    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[y - dy, i] < 256) then
-                inc(Land[y - dy, i]);
-    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[y + dx, i] < 256) then
-                inc(Land[y + dx, i]);
-    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[y - dx, i] < 256) then
-                inc(Land[y - dx, i]);
+            if isCurrent then 
+                Land[y + dy, i]:= Land[y + dy, i] or $80
+            else if Land[y + dy, i] and $007F < 127 then
+                Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) + 1);
+    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then                                                   
+        for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do                                  
+            if isCurrent then                                                                     
+                Land[y - dy, i]:= Land[y - dy, i] or $80                                          
+            else if Land[y - dy, i] and $007F < 127 then                                          
+                Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) + 1);
+    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then                                                   
+        for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do                                  
+            if isCurrent then                                                                     
+                Land[y + dx, i]:= Land[y + dx, i] or $80                                          
+            else if Land[y + dx, i] and $007F < 127 then                                          
+                Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) + 1);
+    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then                                                   
+        for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do                                  
+            if isCurrent then                                                                     
+                Land[y - dx, i]:= Land[y - dx, i] or $80                                          
+            else if Land[y - dx, i] and $007F < 127 then                                          
+                Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) + 1)
     end
 end;
 
@@ -164,7 +180,7 @@
     FillCircleLines(x, y, dx, dy, Value);
 end;
 
-procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
+procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
 var dx, dy, d: LongInt;
 begin
 dx:= 0;
@@ -172,7 +188,7 @@
 d:= 3 - 2 * Radius;
 while (dx < dy) do
     begin
-    ChangeCircleLines(x, y, dx, dy, doSet);
+    ChangeCircleLines(x, y, dx, dy, doSet, isCurrent);
     if (d < 0) then
         d:= d + 4 * dx + 6
     else
@@ -183,7 +199,7 @@
     inc(dx)
     end;
 if (dx = dy) then
-    ChangeCircleLines(x, y, dx, dy, doSet)
+    ChangeCircleLines(x, y, dx, dy, doSet, isCurrent)
 end;
 
 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);