Skip to content

Commit 43decbd

Browse files
authored
Use EntityTable instead of EntTable for perm cache (#2240)
1 parent a3350dd commit 43decbd

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lua/starfall/permissions/providers_sh/entity.lua

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,13 @@ setmetatable(EntityPermissionCache, EntityPermissionCache)
195195

196196
local cacheMeta = {__mode="k", __index = function(t,k) local r=EntityPermissionCache() t[k]=r return r end}
197197

198-
local function getEntPermCache(ent_tbl, instance)
199-
local cache = ent_tbl.SF_EntPermCache
200-
if not cache then
201-
cache = setmetatable({}, cacheMeta)
202-
ent_tbl.SF_EntPermCache = cache
203-
end
204-
return cache[instance]
205-
end
206-
SF.GetEntPermCache = getEntPermCache
198+
local entPermCaches = SF.EntityTable("entPermCache")
199+
getmetatable(entPermCaches).__index = function(t, k) local r=setmetatable({}, cacheMeta) t[k]=r return r end
207200

208201
local function check(instance, ent, checkfunc)
209-
local ent_tbl = Ent_GetTable(ent)
210-
if not ent_tbl then return false, "Entity is invalid" end
202+
if not Ent_IsValid(ent) then return false, "Entity is invalid" end
211203
if Ply_IsSuperAdmin(instance.player) then return true end
212-
return getEntPermCache(ent_tbl, instance):check(instance, ent, checkfunc)
204+
return entPermCaches[ent][instance]:check(instance, ent, checkfunc)
213205
end
214206

215207
SF.Permissions.registerProvider({

0 commit comments

Comments
 (0)