hedgewars/uLandObjects.pas
changeset 3521 96a502730e81
parent 3519 56cbc035b74b
child 3524 8d0783d2a0ff
equal deleted inserted replaced
3520:c3dcb80bdb1d 3521:96a502730e81
   209 
   209 
   210 AddGirder:= bRes;
   210 AddGirder:= bRes;
   211 end;
   211 end;
   212 
   212 
   213 function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean;
   213 function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean;
   214 var i: LongInt;
   214 var i, tmpx, tmpy, bx, by: LongInt;
   215     bRes: boolean = true;
   215     bRes: boolean = true;
   216 begin
   216 begin
   217 inc(rect.x, dX);
   217 inc(rect.x, dX);
   218 inc(rect.y, dY);
   218 inc(rect.y, dY);
       
   219 bx:= rect.x + rect.w;
       
   220 by:= rect.y + rect.h;
   219 i:= 0;
   221 i:= 0;
   220 {$WARNINGS OFF}
   222 {$WARNINGS OFF}
   221 while (i <= rect.w) and bRes do
   223 tmpx:= rect.x;
       
   224 while (tmpx <= bx) and bRes do
   222       begin
   225       begin
   223       bRes:= (Land[rect.y, rect.x + i] = Color) and (Land[rect.y + rect.h, rect.x + i] = Color);
   226       bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color);
   224       inc(i)
   227       inc(tmpx)
   225       end;
   228       end;
   226 i:= 0;
   229 i:= 0;
   227 while (i <= rect.h) and bRes do
   230 tmpy:= rect.y;
       
   231 while (tmpy <= by) and bRes do
   228       begin
   232       begin
   229       bRes:= (Land[rect.y + i, rect.x] = Color) and (Land[rect.y + i, rect.x + rect.w] = Color);
   233       bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color);
   230       inc(i)
   234       inc(tmpy)
   231       end;
   235       end;
   232 {$WARNINGS ON}
   236 {$WARNINGS ON}
   233 CheckLand:= bRes;
   237 CheckLand:= bRes;
   234 end;
   238 end;
   235 
   239