Skip to content

Commit 3dfa55e

Browse files
committed
fixes
1 parent 483b62c commit 3dfa55e

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

[gameplay]/internetradio/logic/handle_radio/CHandleRadio.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ function setPlayerSpeakerVolume(playerElement, volume)
230230
end
231231

232232
setSoundVolume(speakerSound, volume)
233+
233234
return true
234235
end
235236

[gameplay]/internetradio/logic/handle_radio/SHandleRadio.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ function onServerCreateSpeaker(streamURL, volume)
102102
return false
103103
end
104104

105+
local validVolume = verifyRadioVolume(volume)
106+
107+
if (not validVolume) then
108+
return false
109+
end
110+
105111
clearPlayerSpeaker(client, true)
106112

107113
local playerPosX, playerPosY, playerPosZ = getElementPosition(client)
@@ -147,9 +153,15 @@ function onServerEditVolume(volume)
147153
return false
148154
end
149155

156+
local validVolume = verifyRadioVolume(volume)
157+
158+
if (not validVolume) then
159+
return false
160+
end
161+
150162
local speakerData = playerSpeakers[client]
151163

152-
if (not speakerData or not speakerData.speakerBox) then
164+
if (not speakerData) then
153165
return false
154166
end
155167

[gameplay]/internetradio/logic/handle_radio/ShHandleRadio.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,19 @@ end
127127
function clearPlayersDelay()
128128
playerDelays[source] = nil
129129
end
130-
addEventHandler(isServer and "onPlayerQuit" or "onClientPlayerQuit", root, clearPlayersDelay)
130+
addEventHandler(isServer and "onPlayerQuit" or "onClientPlayerQuit", root, clearPlayersDelay)
131+
132+
function verifyRadioVolume(radioVolume)
133+
local radioVolumeType = type(radioVolume)
134+
local radioVolumeNumber = (radioVolumeType == "number")
135+
136+
if (not radioVolumeNumber) then
137+
return false
138+
end
139+
140+
local radioVolumeMin = 0
141+
local radioVolumeMax = 1
142+
local radioVolumeInRange = (radioVolume >= radioVolumeMin) and (radioVolume <= radioVolumeMax)
143+
144+
return radioVolumeInRange
145+
end

0 commit comments

Comments
 (0)