# HG changeset patch # User nemo # Date 1313380365 14400 # Node ID 8313952b281119cf78ff5d05d7e0ad42edbeaa67 # Parent badaac85f9d492e9547c09eed756609f813166af suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes). diff -r badaac85f9d4 -r 8313952b2811 hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Sun Aug 14 23:06:00 2011 -0400 +++ b/hedgewars/uCollisions.pas Sun Aug 14 23:52:45 2011 -0400 @@ -53,7 +53,7 @@ function calcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean; implementation -uses uConsts, uLandGraphics, uVariables, uDebug; +uses uConsts, uLandGraphics, uVariables, uDebug, uGears; type TCollisionEntry = record X, Y, Radius: LongInt; @@ -66,6 +66,7 @@ ga: TGearArray; procedure AddGearCI(Gear: PGear); +var t: PGear; begin if Gear^.CollisionIndex >= 0 then exit; TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); @@ -78,7 +79,14 @@ cGear:= Gear end; Gear^.CollisionIndex:= Count; -inc(Count) +inc(Count); +// mines are the easiest way to overflow collision +if (Count > (MAXRECTSINDEX-20)) then + begin + t:= GearsList; + while (t <> nil) and (t^.Kind <> gtMine) do t:= t^.NextGear; + if (t <> nil) and (t^.Kind = gtMine) then DeleteGear(t) + end; end; procedure DeleteCI(Gear: PGear);