From cca3c64aa840ae125ee9cf0b31ff95ff7421f263 Mon Sep 17 00:00:00 2001 From: Grocel Date: Sat, 30 Dec 2023 04:25:31 +0100 Subject: [PATCH] Improved load times on some cases and updated wirelink support - Removed `collectgarbage( "collect" )` calls to improve load times on some cases. - Updated Wirelink detection to upcomming Wiremod changes. --- addon.json | 2 -- lua/autorun/streamradio_loader.lua | 2 -- lua/entities/base_streamradio.lua | 4 ++-- lua/streamradio_core/classes.lua | 2 -- lua/streamradio_core/filesystem.lua | 2 -- lua/streamradio_core/hook.lua | 29 +++++++++++++++++++---- lua/streamradio_core/interface.lua | 2 -- lua/streamradio_core/models.lua | 3 --- materials/3dstreamradio/_data/version.vmt | 4 ++-- 9 files changed, 29 insertions(+), 21 deletions(-) diff --git a/addon.json b/addon.json index 1cc4f32..f966d69 100644 --- a/addon.json +++ b/addon.json @@ -16,8 +16,6 @@ "*.html", "*.gma", "*.zip", - "bin/*", - "bin/*", "noupload/*", "*.md", "LICENSE", diff --git a/lua/autorun/streamradio_loader.lua b/lua/autorun/streamradio_loader.lua index 56ca817..d284cd6 100644 --- a/lua/autorun/streamradio_loader.lua +++ b/lua/autorun/streamradio_loader.lua @@ -142,8 +142,6 @@ do _G.StreamRadioLib.Loaded = nil end - collectgarbage( "collect" ) - if errorString == g_addonBrokenError then -- something went horribly wrong, so tell the user about it. diff --git a/lua/entities/base_streamradio.lua b/lua/entities/base_streamradio.lua index 23873df..abf9d26 100644 --- a/lua/entities/base_streamradio.lua +++ b/lua/entities/base_streamradio.lua @@ -882,8 +882,8 @@ else WireLib.TriggerOutput(self, name, value) end - function ENT:TriggerInput(name, value) - local wired = self:IsConnectedInputWire(name) or self:IsConnectedWirelink() + function ENT:TriggerInput(name, value, ext) + local wired = self:IsConnectedInputWire(name) or self:IsConnectedWirelink() or istable(ext) and ext.wirelink self:OnWireInputTrigger(name, value, wired) end diff --git a/lua/streamradio_core/classes.lua b/lua/streamradio_core/classes.lua index 00736f3..6fb9acf 100644 --- a/lua/streamradio_core/classes.lua +++ b/lua/streamradio_core/classes.lua @@ -222,8 +222,6 @@ function StreamRadioLib.ReloadClasses() AddClass("rendertarget", "base_listener") AddClass("stream", "base_listener") AddClass("clientconvar", "base_listener") - - collectgarbage( "collect" ) end function StreamRadioLib.CreateOBJ(name, ...) diff --git a/lua/streamradio_core/filesystem.lua b/lua/streamradio_core/filesystem.lua index 3164db8..2e1d0db 100644 --- a/lua/streamradio_core/filesystem.lua +++ b/lua/streamradio_core/filesystem.lua @@ -329,8 +329,6 @@ function LIB.Load() end StreamRadioLib.VALID_FORMATS_EXTENSIONS_LIST = table.concat(formats, ", ") - - collectgarbage("collect") end function LIB.FilterInvalidFilesnames(filenames) diff --git a/lua/streamradio_core/hook.lua b/lua/streamradio_core/hook.lua index 9be3ced..14a7e44 100644 --- a/lua/streamradio_core/hook.lua +++ b/lua/streamradio_core/hook.lua @@ -15,13 +15,13 @@ function LIB.GetMainHookIdentifier(eventName) end local function CallHooks(hookData, ...) - -- Called by all hooks the addon adds the game, including think and tick. + -- Called by all hooks the addon adds to the game, including think and tick. -- It is a proxy that distribute calls to all internal addon hooks. -- This reduces overhead from the native hook library. -- Prevent error spams when the addon is not completely loaded - if not StreamRadioLib then return end - if not StreamRadioLib.Loaded then return end + if not StreamRadioLib then return nil end + if not StreamRadioLib.Loaded then return nil end local byOrder = hookData.byOrder if not byOrder then @@ -81,6 +81,27 @@ local function BuildOrder(hookData) hookData.byOrder = byOrder end +function LIB.Has(eventName, identifier) + identifier = tostring(identifier or "") + eventName = tostring(eventName or "") + + local hookData = g_hooks[eventName] + if not hookData then + return false + end + + local byName = hookData.byName + if not byName then + return false + end + + if not byName[identifier] then + return false + end + + return true +end + function LIB.Add(eventName, identifier, func, order) if not isfunction(func) then return end @@ -108,7 +129,7 @@ function LIB.Add(eventName, identifier, func, order) } hookData.benchmark = hookData.benchmark or 0 - hookData.benchmarkAvg = hookData.benchmark or 0 + hookData.benchmarkAvg = hookData.benchmarkAvg or 0 BuildOrder(hookData) diff --git a/lua/streamradio_core/interface.lua b/lua/streamradio_core/interface.lua index fe81994..9c119e6 100644 --- a/lua/streamradio_core/interface.lua +++ b/lua/streamradio_core/interface.lua @@ -79,8 +79,6 @@ function LIB.Load() end table.SortByMember(g_intefaces, "priority", false) - - collectgarbage("collect") end function LIB.GetInterface(name) diff --git a/lua/streamradio_core/models.lua b/lua/streamradio_core/models.lua index a2201d2..2949033 100644 --- a/lua/streamradio_core/models.lua +++ b/lua/streamradio_core/models.lua @@ -133,7 +133,6 @@ local function AddMultiModels(script, modellist) RADIOMDL = nil end - collectgarbage( "collect" ) return true end @@ -158,8 +157,6 @@ function LIB.LoadModelSettings() if not IsValid(ent) then continue end ent:SetUpModel() end - - collectgarbage( "collect" ) end function LIB.GetModelSettings(model, setting) diff --git a/materials/3dstreamradio/_data/version.vmt b/materials/3dstreamradio/_data/version.vmt index 1355e8c..7c69ead 100644 --- a/materials/3dstreamradio/_data/version.vmt +++ b/materials/3dstreamradio/_data/version.vmt @@ -1,2 +1,2 @@ -438 -1700864709 +439 +1703906732