diff --git a/lua/entities/gmod_wire_expression2/core/sound.lua b/lua/entities/gmod_wire_expression2/core/sound.lua index 05b686ec84..398a209429 100644 --- a/lua/entities/gmod_wire_expression2/core/sound.lua +++ b/lua/entities/gmod_wire_expression2/core/sound.lua @@ -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 diff --git a/lua/entities/gmod_wire_soundemitter.lua b/lua/entities/gmod_wire_soundemitter.lua index 3e915965ca..fee919bb4d 100644 --- a/lua/entities/gmod_wire_soundemitter.lua +++ b/lua/entities/gmod_wire_soundemitter.lua @@ -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() diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 7f332b1788..f4c7fb2a29 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -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