Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error if holo index is NaN #3135

Merged
merged 8 commits into from
Sep 9, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lua/entities/gmod_wire_expression2/core/hologram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,10 @@ end

-- Returns the hologram with the given index or nil if it doesn't exist.
-- if shouldbenil is nil or false, assert that the hologram exists on @strict with an error. Otherwise, don't check (for holo creation, etc)
local MAX_INDEX = 2 ^ 31
Zvbhrf marked this conversation as resolved.
Show resolved Hide resolved
local function CheckIndex(self, index, shouldbenil)
index = math.Clamp(math.floor(index), -2^31, 2^31)
if index ~= index then return self:throw("holo index is NaN!", nil) end
index = math.Clamp(math.floor(index), -MAX_INDEX, MAX_INDEX)
Zvbhrf marked this conversation as resolved.
Show resolved Hide resolved
local Holo
if index<0 then
Holo = E2HoloRepo[self.uid][-index]
Expand Down
Loading