Skip to content

Commit

Permalink
Add rendergroup check to network func
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Oct 28, 2024
1 parent a11cf00 commit 348868c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 9 additions & 0 deletions lua/entities/starfall_hologram/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,16 @@ function ENT:OnCullModeChanged()
self.renderstack:makeDirty()
end

SF.allowedRenderGroups = {
[RENDERGROUP_OPAQUE]=true,
[RENDERGROUP_TRANSLUCENT]=true,
[RENDERGROUP_BOTH]=true,
[RENDERGROUP_VIEWMODEL]=true,
[RENDERGROUP_VIEWMODEL_TRANSLUCENT]=true,
[RENDERGROUP_OPAQUE_BRUSH]=true,
}
function ENT:OnRenderGroupChanged(name, old, group)
if not SF.allowedRenderGroups[group] then return end
if group == -1 then
self.RenderGroup = nil
else
Expand Down
11 changes: 2 additions & 9 deletions lua/starfall/libs_sh/hologram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -500,14 +500,7 @@ function hologram_methods:setCullMode(mode)
holo:SetCullMode(mode==1)
end

local allowedRenderGroups = {
[RENDERGROUP_OPAQUE]=true,
[RENDERGROUP_TRANSLUCENT]=true,
[RENDERGROUP_BOTH]=true,
[RENDERGROUP_VIEWMODEL]=true,
[RENDERGROUP_VIEWMODEL_TRANSLUCENT]=true,
[RENDERGROUP_OPAQUE_BRUSH]=true,
}

--- Set the render group for a hologram.
-- @shared
-- @param number|nil group Render group. If unset, the engine will decide the render group based on the entity's materials. Can be RENDERGROUP.OPAQUE RENDERGROUP.TRANSLUCENT RENDERGROUP.BOTH RENDERGROUP.VIEWMODEL RENDERGROUP.VIEWMODEL.TRANSLUCENT RENDERGROUP.OPAQUE.BRUSH
Expand All @@ -517,7 +510,7 @@ function hologram_methods:setRenderGroup(group)

if group then
checkluatype(group, TYPE_NUMBER)
if not allowedRenderGroups[group] then SF.Throw("Invalid rendergroup!") end
if not SF.allowedRenderGroups[group] then SF.Throw("Invalid rendergroup!") end
holo:SetRenderGroupInternal(group)
else
holo:SetRenderGroupInternal(-1)
Expand Down

0 comments on commit 348868c

Please sign in to comment.