Don't calculate edges of map as edges of landscape icegun
authorUrbertar@gmail.com
Tue, 26 Feb 2013 11:00:09 +0200
branchicegun
changeset 8582 08679e8186a3
parent 8581 f3bc24ef756e
child 8583 f2edd6d5f958
Don't calculate edges of map as edges of landscape
hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc	Tue Feb 26 10:27:51 2013 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Feb 26 11:00:09 2013 +0200
@@ -5111,16 +5111,18 @@
     i, j:Longint;
 begin    
     result := 0;
-    for i := max(x - 1, 0) to min(x + 1, LAND_WIDTH-1) do
-    begin
-        for j := max(y - 1, 0) to min(y + 1, LAND_HEIGHT-1) do 
-        begin
-            if ((Land[j, i] and $FF00) = 0) then
-            begin
-                result := result + 1;
-            end;
+    for i := x - 1 to x + 1 do
+        for j := y - 1 to y + 1 do 
+        begin
+        if (i < 0) or 
+           (i > LAND_WIDTH - 1) or 
+           (j < 0) or 
+           (j > LAND_HEIGHT -1) or 
+           ((Land[j, i] and $FF00) = 0) then
+           begin
+           result := result + 1;
+           end;
         end;
-    end;
 end;