Skip to content

Commit

Permalink
Improved load times on some cases and updated wirelink support
Browse files Browse the repository at this point in the history
- Removed `collectgarbage( "collect" )` calls to improve load times on some cases.
- Updated Wirelink detection to upcomming Wiremod changes.
  • Loading branch information
Grocel committed Dec 30, 2023
1 parent 296ed5c commit cca3c64
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 21 deletions.
2 changes: 0 additions & 2 deletions addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"*.html",
"*.gma",
"*.zip",
"bin/*",
"bin/*",
"noupload/*",
"*.md",
"LICENSE",
Expand Down
2 changes: 0 additions & 2 deletions lua/autorun/streamradio_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions lua/entities/base_streamradio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions lua/streamradio_core/classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down
2 changes: 0 additions & 2 deletions lua/streamradio_core/filesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ function LIB.Load()
end

StreamRadioLib.VALID_FORMATS_EXTENSIONS_LIST = table.concat(formats, ", ")

collectgarbage("collect")
end

function LIB.FilterInvalidFilesnames(filenames)
Expand Down
29 changes: 25 additions & 4 deletions lua/streamradio_core/hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions lua/streamradio_core/interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ function LIB.Load()
end

table.SortByMember(g_intefaces, "priority", false)

collectgarbage("collect")
end

function LIB.GetInterface(name)
Expand Down
3 changes: 0 additions & 3 deletions lua/streamradio_core/models.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ local function AddMultiModels(script, modellist)
RADIOMDL = nil
end

collectgarbage( "collect" )
return true
end

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions materials/3dstreamradio/_data/version.vmt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
438
1700864709
439
1703906732

0 comments on commit cca3c64

Please sign in to comment.