Skip to content

Commit

Permalink
Add Ballistics.CreateBullet required properties
Browse files Browse the repository at this point in the history
This should help us catch these issues easier
  • Loading branch information
marchc1 committed Mar 1, 2025
1 parent 96832fa commit 308b008
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/acf/ballistics/ballistics_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ function Ballistics.IterateBullets()
end
end

local RequiredBulletDataProperties = {"Pos", "Flight"}
function Ballistics.CreateBullet(BulletData)
-- Validate BulletData, so we can catch these problems easier

for _, RequiredProp in ipairs(RequiredBulletDataProperties) do
if not BulletData[RequiredProp] then
error(("Ballistics.CreateBullet: Expected '%s' to be present in BulletData, got nil!"):format(RequiredProp))
end
end

local Index = Ballistics.GetBulletIndex()

if not Index then return end -- Too many bullets in the air
Expand Down

0 comments on commit 308b008

Please sign in to comment.