Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix e2 soundcore & sound emitter from not playing soundscripts & sounds with sound characters. #3125

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lua/entities/gmod_wire_expression2/core/sound.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ local function soundStop(self, index, fade)
timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index )
end

local function soundCreate(self, entity, index, time, path, fade)
path = string.Trim(string.sub(path, 1, 260))
if path:match('["?]') then return end

if not file.Exists("sound/" .. path, "GAME") then return end
local function soundCreate(self, entity, index, time, path, fade)
path = WireLib.SoundExists(path)
if not path then return end
local data = self.data.sound_data
if not isAllowed( self ) then return end

Expand Down
13 changes: 6 additions & 7 deletions lua/entities/gmod_wire_soundemitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ end

function ENT:UpdateSound()
if self.NeedsRefresh or self.sound ~= self.ActiveSample then
if not file.Exists("sound/" .. self.sound, "GAME") then return end

self.NeedsRefresh = nil
local filter = RecipientFilter()
Expand Down Expand Up @@ -167,23 +166,23 @@ end
function ENT:SetSound(soundName)
self:StopSounds()

soundName = string.Trim(string.sub(soundName, 1, 260))
if soundName:match('["?]') then return end
util.PrecacheSound(soundName)
soundName = WireLib.SoundExists(soundName)
if not soundName then return end

util.PrecacheSound(soundName)
self.sound = soundName

self.SoundProperties = sound.GetProperties(self.sound)
self.SoundProperties = sound.GetProperties(soundName)
if self.SoundProperties then
WireLib.TriggerOutput(self, "Duration", SoundDuration(self.sound))
WireLib.TriggerOutput(self, "Duration", SoundDuration(soundName))
WireLib.TriggerOutput(self, "Property Sound", 1)
WireLib.TriggerOutput(self, "Properties", self.SoundProperties)
else
WireLib.TriggerOutput(self, "Property Sound", 0)
WireLib.TriggerOutput(self, "Properties", {})
end

self:SetOverlayText( soundName:gsub("[/\\]+","/") )
self:SetOverlayText(soundName)
end

function ENT:StartSounds()
Expand Down
7 changes: 7 additions & 0 deletions lua/wire/server/wirelib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,13 @@ if not WireLib.PatchedDuplicator then
end
end

function WireLib.SoundExists(path)
path = string.GetNormalizedFilepath(string.gsub(string.sub(path, 1, 260), '["?]', ''))
if istable(sound.GetProperties(path)) or file.Exists("sound/" .. path, "GAME") then
return path
end
end

-- Notify --

local triv_start = WireLib.Net.Trivial.Start
Expand Down
Loading