This reduces CheckLand ~5.5% on average over prior making the overall reduction ~77.4% instead of ~81.9%. It does skip centre pixel in odd w/h, but that really shouldn't matter much in this case. Can alter if any objects are noticeably off.
authornemo
Sun, 20 Jun 2010 19:31:15 -0400
changeset 3524 8d0783d2a0ff
parent 3521 96a502730e81
child 3526 a1d2180fef42
This reduces CheckLand ~5.5% on average over prior making the overall reduction ~77.4% instead of ~81.9%. It does skip centre pixel in odd w/h, but that really shouldn't matter much in this case. Can alter if any objects are noticeably off.
hedgewars/uConsts.pas
hedgewars/uLandObjects.pas
--- a/hedgewars/uConsts.pas	Sun Jun 20 18:26:49 2010 -0400
+++ b/hedgewars/uConsts.pas	Sun Jun 20 19:31:15 2010 -0400
@@ -249,6 +249,7 @@
 {$ENDIF}
 
 // To allow these to layer, going to treat them as masks. The bottom byte is reserved for objects
+// TODO - set lfBasic for all solid land, ensure all uses of the flags can handle multiple flag bits
     lfBasic          = $8000;  // white
     lfIndestructible = $4000;  // red
     lfObject         = $2000;  // no idea
--- a/hedgewars/uLandObjects.pas	Sun Jun 20 18:26:49 2010 -0400
+++ b/hedgewars/uLandObjects.pas	Sun Jun 20 19:31:15 2010 -0400
@@ -211,27 +211,31 @@
 end;
 
 function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean;
-var i, tmpx, tmpy, bx, by: LongInt;
+var tmpx, tmpx2, tmpy, tmpy2, bx, by: LongInt;
     bRes: boolean = true;
 begin
 inc(rect.x, dX);
 inc(rect.y, dY);
 bx:= rect.x + rect.w;
 by:= rect.y + rect.h;
-i:= 0;
 {$WARNINGS OFF}
 tmpx:= rect.x;
-while (tmpx <= bx) and bRes do
+tmpx2:= bx;
+while (tmpx <= bx - rect.w div 2 - 1) and bRes do
       begin
-      bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color);
-      inc(tmpx)
+      bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color) and
+             (Land[rect.y, tmpx2] = Color) and (Land[by, tmpx2] = Color);
+      inc(tmpx);
+      dec(tmpx2)
       end;
-i:= 0;
-tmpy:= rect.y;
-while (tmpy <= by) and bRes do
+tmpy:= rect.y+1;
+tmpy2:= by-1;
+while (tmpy <= by - rect.h div 2 - 1) and bRes do
       begin
-      bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color);
-      inc(tmpy)
+      bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color) and
+             (Land[tmpy2, rect.x] = Color) and (Land[tmpy2, bx] = Color);
+      inc(tmpy);
+      dec(tmpy2)
       end;
 {$WARNINGS ON}
 CheckLand:= bRes;