Skip to content

Commit

Permalink
Use 8 bits for volume
Browse files Browse the repository at this point in the history
7 was not enough and was causing weird volume issues
  • Loading branch information
thecraftianman committed Feb 29, 2024
1 parent 62886a5 commit 8a3bd81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lua/acf/core/utilities/sounds/sounds_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ do -- Playing regular sounds
local Path = net.ReadString()
local Level = net.ReadUInt(7)
local Pitch = net.ReadUInt(8)
local Volume = net.ReadUInt(7) / 100
local Volume = net.ReadUInt(8) / 100

if not Sounds.IsValidSound(Path) then return end

Expand Down Expand Up @@ -97,7 +97,7 @@ do -- Processing adjustable sounds (for example, engine noises)
Sounds.DestroyAdjustableSound(Origin)
else
local Pitch = net.ReadUInt(8)
local Volume = net.ReadUInt(7) / 100
local Volume = net.ReadUInt(8) / 100

Sounds.UpdateAdjustableSound(Origin, Pitch, Volume)
end
Expand Down
4 changes: 2 additions & 2 deletions lua/acf/core/utilities/sounds/sounds_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Sounds.SendSound(Origin, Path, Level, Pitch, Volume)
net.WriteString(Path)
net.WriteUInt(Level, 7)
net.WriteUInt(Pitch, 8)
net.WriteUInt(Volume * 100, 7)
net.WriteUInt(Volume * 100, 8)
net.SendPAS(Pos)
end

Expand Down Expand Up @@ -57,7 +57,7 @@ function Sounds.SendAdjustableSound(Origin, ShouldStop, Pitch, Volume)
net.WriteUInt(Pitch, 8)

Volume = Volume * 100 -- Sending the approximate volume as an int to reduce message size
net.WriteUInt(Volume, 7)
net.WriteUInt(Volume, 8)
end
net.SendPAS(Origin:GetPos())
Origin.ACF.SoundTimer = Time + 0.1
Expand Down

0 comments on commit 8a3bd81

Please sign in to comment.