mirror of
https://github.com/wiremod/wire.git
synced 2025-03-04 03:03:04 -05:00
Fix e2 soundcore & sound emitter from not playing soundscripts & sounds with sound characters. (#3125)
* fix soundcore * no longer necessary * fix sound emitter also * match all symbols at the beginning * Update SoundExists to sanitize sound paths --------- Co-authored-by: thegrb93 <grbrown93@sbcglobal.net>
This commit is contained in:
parent
cc56ea8267
commit
5c5f3ddab4
@ -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
|
||||
|
||||
|
@ -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()
|
||||
@ -167,15 +166,15 @@ 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
|
||||
@ -183,7 +182,7 @@ function ENT:SetSound(soundName)
|
||||
WireLib.TriggerOutput(self, "Properties", {})
|
||||
end
|
||||
|
||||
self:SetOverlayText( soundName:gsub("[/\\]+","/") )
|
||||
self:SetOverlayText(soundName)
|
||||
end
|
||||
|
||||
function ENT:StartSounds()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user