From a8a4700bddd2869621d7f9e9a4f3bf94553f5813 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Sat, 26 Aug 2023 16:57:52 -0400 Subject: [PATCH] Fixes --- lua/starfall/libs_sh/hologram.lua | 2 +- lua/starfall/libs_sv/navmesh.lua | 2 -- lua/starfall/libs_sv/nextbot.lua | 12 +++++------- lua/starfall/sflib.lua | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lua/starfall/libs_sh/hologram.lua b/lua/starfall/libs_sh/hologram.lua index 981ca4088..734c044b6 100644 --- a/lua/starfall/libs_sh/hologram.lua +++ b/lua/starfall/libs_sh/hologram.lua @@ -463,7 +463,7 @@ function hologram_methods:removeEffects(effect) holo:RemoveEffects(effect) end ---- Removes all holograms created by the calling chip +--- Removes a hologram -- @shared function hologram_methods:remove() if CLIENT and instance.data.render.isRendering then SF.Throw("Cannot remove while in rendering hook!", 2) end diff --git a/lua/starfall/libs_sv/navmesh.lua b/lua/starfall/libs_sv/navmesh.lua index 8ebab80f5..88e124804 100644 --- a/lua/starfall/libs_sv/navmesh.lua +++ b/lua/starfall/libs_sv/navmesh.lua @@ -639,7 +639,6 @@ return function(instance) return lnavunwrap(self):PlaceOnGround(corner) end - --- Removes a CNavArea from the Open List with the lowest cost to traverse to from the starting node, and returns it. -- Requires the `navarea.openlist` permission -- @return NavArea The CNavArea from the Open List with the lowest cost to traverse to from the starting node. @@ -649,7 +648,6 @@ return function(instance) return lnavwrap( lnavunwrap(self):PopOpenList() ) end - --- Removes the given NavArea. function navarea_methods:remove() local nav = navunwrap(self) diff --git a/lua/starfall/libs_sv/nextbot.lua b/lua/starfall/libs_sv/nextbot.lua index 08e6eb5b7..aa80fb07c 100644 --- a/lua/starfall/libs_sv/nextbot.lua +++ b/lua/starfall/libs_sv/nextbot.lua @@ -17,6 +17,7 @@ SF.RegisterType("NextBot", false, true, debug.getregistry().NextBot, "Entity") SF.RegisterLibrary("nextbot") registerprivilege("nextbot.create", "Create nextbot", "Allows the user to create nextbots.") +registerprivilege("nextbot.remove", "Remove a nextbot", "Allows the user to remove a nextbot.", {entites = {}}) registerprivilege("nextbot.setGotoPos", "Set nextbot goto pos", "Allows the user to set a vector pos for the nextbot to try and go to.", {entites = {}}) registerprivilege("nextbot.removeGotoPos", "Remove nextbot goto pos", "Allows the user to remove the goto pos from a nextbot.", {entites = {}}) registerprivilege("nextbot.playSequence", "Play nextbot sequence", "Allows the user to set an animation for the nextbot to play.", {entites = {}}) @@ -101,13 +102,10 @@ function nextbot_library.create(pos, mdl) end --- Removes the given nextbot. -function navarea_methods:remove() - local nav = navunwrap(self) - entList:remove(instance, nav) - - local sensitive2sf, sf2sensitive = navarea_meta.sensitive2sf, navarea_meta.sf2sensitive - sensitive2sf[nav] = nil - sf2sensitive[self] = nil +function nextbot_library:remove() + local nb = nbunwrap(self) + checkpermission(instance, nb, "nextbot.remove") + entList:remove(instance, nb) end --- Checks if a user can spawn anymore nextbots. diff --git a/lua/starfall/sflib.lua b/lua/starfall/sflib.lua index 194e6f338..659f88a80 100644 --- a/lua/starfall/sflib.lua +++ b/lua/starfall/sflib.lua @@ -292,7 +292,7 @@ SF.EntManager = { register = function(self, instance, ent) ent:CallOnRemove("starfall_entity_onremove", self.onremove, self, instance) self.entsByInstance[instance][ent] = true - self.limit:free(instance.player, -1) + self:free(instance.player, -1) end, remove = function(self, instance, ent) if ent:IsValid() then @@ -305,7 +305,7 @@ SF.EntManager = { end, onremove = function(ent, self, instance) self.entsByInstance[instance][ent] = nil - self.limit:free(instance.player, 1) + self:free(instance.player, 1) end, clear = function(self, instance) for ent in pairs(self.entsByInstance[instance]) do