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.
This commit is contained in:
Grocel 2023-12-30 04:25:31 +01:00
parent 296ed5cd7b
commit cca3c64aa8
9 changed files with 29 additions and 21 deletions

View File

@ -16,8 +16,6 @@
"*.html",
"*.gma",
"*.zip",
"bin/*",
"bin/*",
"noupload/*",
"*.md",
"LICENSE",

View File

@ -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.

View File

@ -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

View File

@ -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, ...)

View File

@ -329,8 +329,6 @@ function LIB.Load()
end
StreamRadioLib.VALID_FORMATS_EXTENSIONS_LIST = table.concat(formats, ", ")
collectgarbage("collect")
end
function LIB.FilterInvalidFilesnames(filenames)

View File

@ -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)

View File

@ -79,8 +79,6 @@ function LIB.Load()
end
table.SortByMember(g_intefaces, "priority", false)
collectgarbage("collect")
end
function LIB.GetInterface(name)

View File

@ -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)

View File

@ -1,2 +1,2 @@
438
1700864709
439
1703906732