Skip to content

Commit

Permalink
Fixed this time
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 committed Aug 29, 2023
1 parent 8bc7232 commit e9edf4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lua/starfall/libs_sv/navmesh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SF.RegisterLibrary("navmesh")
SF.RegisterType("NavArea", true, false, nil, "LockedNavArea")
SF.RegisterType("LockedNavArea", true, false) -- NavArea that can't be modified.

local entList = SF.EntManager("navareas", "navareas", 40, "The number of CNavAreas allowed to spawn via Starfall")
local entList = SF.EntManager("navareas", "navareas", 40, "The number of CNavAreas allowed to spawn via Starfall", 1, true)

return function(instance)
local checkpermission = instance.player ~= SF.Superuser and SF.Permissions.check or function() end
Expand Down
27 changes: 13 additions & 14 deletions lua/starfall/sflib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,26 +290,24 @@ setmetatable(SF.LimitObject, SF.LimitObject)
SF.EntManager = {
__index = {
register = function(self, instance, ent)
local function sf_on_remove() self:onremove(instance, ent) end
ent.sf_on_remove = sf_on_remove

local callOnRemove = ent.CallOnRemove
if callOnRemove then
callOnRemove(ent, "starfall_entity_onremove", sf_on_remove)
if not self.nocallonremove then
local function sf_on_remove() self:onremove(instance, ent) end
ent.sf_on_remove = sf_on_remove
ent:CallOnRemove("starfall_entity_onremove", sf_on_remove)
end

self.entsByInstance[instance][ent] = true
self:free(instance.player, -1)
end,
remove = function(self, instance, ent)
if ent:IsValid() then
-- The die function is called the next frame after 'Remove' which is too slow so call it ourself
local removeCallOnRemove = ent.RemoveCallOnRemove
if removeCallOnRemove then
removeCallOnRemove(ent, "starfall_entity_onremove")
if self.nocallonremove then
self:onremove(instance, ent)
else
-- The die function is called the next frame after 'Remove' which is too slow so call it ourself
ent:RemoveCallOnRemove("starfall_entity_onremove")
ent.sf_on_remove()
end
ent.sf_on_remove()

ent:Remove()
end
end,
Expand All @@ -329,8 +327,9 @@ SF.EntManager = {
self.entsByInstance[instance] = nil
end
},
__call = function(p, ...)
local t = SF.LimitObject(...)
__call = function(p, cvarname, limitname, max, maxhelp, scale, nocallonremove)
local t = SF.LimitObject(cvarname, limitname, max, maxhelp, scale)
t.nocallonremove = nocallonremove or false
t.entsByInstance = setmetatable({},{__index = function(t,k) local r = {} t[k]=r return r end})
return setmetatable(t, p)
end
Expand Down

0 comments on commit e9edf4b

Please sign in to comment.