# HG changeset patch # User nemo # Date 1277072809 14400 # Node ID 96a502730e81a635cedc6817185ae029242fa6c0 # Parent c3dcb80bdb1da3ac72e15bd3e34b4faeb75baade Remove redundant test, add some temp variables to speed up the expensive CheckLand diff -r c3dcb80bdb1d -r 96a502730e81 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Fri Jun 18 20:45:45 2010 +0200 +++ b/hedgewars/uLandGraphics.pas Sun Jun 20 18:26:49 2010 -0400 @@ -644,7 +644,7 @@ function Despeckle(X, Y: LongInt): boolean; var nx, ny, i, j, c: LongInt; begin -if (Land[Y, X] > 255) and ((Land[Y, X] and lfIndestructible) = 0) and ((Land[Y, X] and lfDamaged) <> 0)then // check neighbours +if ((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0) then // check neighbours begin c:= 0; for i:= -1 to 1 do diff -r c3dcb80bdb1d -r 96a502730e81 hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Fri Jun 18 20:45:45 2010 +0200 +++ b/hedgewars/uLandObjects.pas Sun Jun 20 18:26:49 2010 -0400 @@ -211,23 +211,27 @@ end; function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean; -var i: LongInt; +var i, tmpx, tmpy, 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} -while (i <= rect.w) and bRes do +tmpx:= rect.x; +while (tmpx <= bx) and bRes do begin - bRes:= (Land[rect.y, rect.x + i] = Color) and (Land[rect.y + rect.h, rect.x + i] = Color); - inc(i) + bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color); + inc(tmpx) end; i:= 0; -while (i <= rect.h) and bRes do +tmpy:= rect.y; +while (tmpy <= by) and bRes do begin - bRes:= (Land[rect.y + i, rect.x] = Color) and (Land[rect.y + i, rect.x + rect.w] = Color); - inc(i) + bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color); + inc(tmpy) end; {$WARNINGS ON} CheckLand:= bRes;