hedgewars/uGearsUtils.pas
changeset 6490 531bf083e8db
parent 6468 da1e7fe7cff7
child 6498 5678806aafca
equal deleted inserted replaced
6489:e1f0058cfedd 6490:531bf083e8db
   420         gear^.State := gstWait;
   420         gear^.State := gstWait;
   421     end;
   421     end;
   422     RecountTeamHealth(tempTeam);
   422     RecountTeamHealth(tempTeam);
   423 end;
   423 end;
   424 
   424 
       
   425 function CountNonZeroz(x, y, r, c: LongInt): LongInt;
       
   426 var i: LongInt;
       
   427     count: LongInt = 0;
       
   428 begin
       
   429 if (y and LAND_HEIGHT_MASK) = 0 then
       
   430     for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do
       
   431         if Land[y, i] <> 0 then
       
   432             begin
       
   433             inc(count);
       
   434             if count = c then exit(count)
       
   435             end;
       
   436 CountNonZeroz:= count;
       
   437 end;
   425 
   438 
   426 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean);
   439 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean);
   427 
       
   428     function CountNonZeroz(x, y, r, c: LongInt): LongInt;
       
   429     var i: LongInt;
       
   430         count: LongInt = 0;
       
   431     begin
       
   432     if (y and LAND_HEIGHT_MASK) = 0 then
       
   433         for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do
       
   434             if Land[y, i] <> 0 then
       
   435                begin
       
   436                inc(count);
       
   437                if count = c then exit(count)
       
   438                end;
       
   439     CountNonZeroz:= count;
       
   440     end;
       
   441 
       
   442 var x: LongInt;
   440 var x: LongInt;
   443     y, sy: LongInt;
   441     y, sy: LongInt;
   444     ar: array[0..511] of TPoint;
   442     ar: array[0..511] of TPoint;
   445     ar2: array[0..1023] of TPoint;
   443     ar2: array[0..1023] of TPoint;
   446     cnt, cnt2: Longword;
   444     cnt, cnt2: Longword;