Skip to content

Commit

Permalink
Avoid range check error when inserting last sprite in `TBullet.Filter…
Browse files Browse the repository at this point in the history
…SpritesByDistance`.
  • Loading branch information
BranDougherty committed Oct 29, 2022
1 parent 80463ce commit 2863107
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions shared/mechanics/Bullets.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2721,10 +2721,14 @@ function TBullet.FilterSpritesByDistance(var SpriteIndexes: TSpriteIndexes): Int

while (j > 1) and (RoughDistance < Distances[j - 1]) do
j := j - 1;
Move(Distances[j], Distances[j + 1], (SpriteCount - j) * SizeOf(Single));
Distances[j] := RoughDistance;

Move(SpriteIndexes[j], SpriteIndexes[j + 1], (SpriteCount - j) * SizeOf(Integer));
if (SpriteCount - j) > 0 then
begin
Move(Distances[j], Distances[j + 1], (SpriteCount - j) * SizeOf(Single));
Move(SpriteIndexes[j], SpriteIndexes[j + 1], (SpriteCount - j) * SizeOf(Integer));
end;

Distances[j] := RoughDistance;
SpriteIndexes[j] := i;
end;
end;
Expand Down

0 comments on commit 2863107

Please sign in to comment.