You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add liveatc and fix webaudio counter not decreasing w/ client errors
Fixes#52
Resolved an error where a client having an error sending the error to the server would not decrease the webaudio counter, leaving players without any slots left to use webaudio without rejoining.
Copy file name to clipboardExpand all lines: lua/autorun/webaudio.lua
+59-58Lines changed: 59 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,7 @@
3
3
(part 1)
4
4
]]
5
5
6
-
--- x86 branch is on an outdated luajit that doesn't support binary literals. Woo
7
-
-- i love the game "garry's mod" created by Garry Newman as a mod for Valve's Source game engine and released in December 2004, before being expanded into a standalone release that was published by Valve in November 2006.
6
+
--- x86 branch is on LuaJIT 2.0.4 which doesn't support binary literals
8
7
localfunctionb(s)
9
8
returntonumber(s, 2)
10
9
end
@@ -133,6 +132,7 @@ end
133
132
---@fieldidinteger # Custom ID for webaudio stream allocated between 0-MAX
134
133
---@fieldignoredGCRecipientFilter # Players to ignore when sending net messages.
135
134
---@fieldmodeWebAudioMode
135
+
---@fieldhook_destroytable<fun(self: WebAudio), boolean> # SHARED. Hooks to run before/when the stream is destroyed.
136
136
_G.WebAudio= {}
137
137
WebAudio.__index=WebAudio
138
138
@@ -203,12 +203,22 @@ function WebAudio:IsDestroyed()
203
203
returnself.destroyed
204
204
end
205
205
206
+
--- Calls the given function right before webaudio destruction.
207
+
---@paramfunfun(self: WebAudio)
208
+
functionWebAudio:OnDestroy(fun)
209
+
self.hook_destroy[fun] =true
210
+
end
211
+
206
212
--- Destroys a webaudio object and makes it the same (value wise) as WebAudio.getNULL()
207
213
--- @paramtransmitboolean? If SERVER, should we transmit the destruction to the client? Default true
208
214
functionWebAudio:Destroy(transmit)
209
215
ifself:IsDestroyed() thenreturnend
210
216
iftransmit==nilthentransmit=trueend
211
217
218
+
forcallbackinpairs(self.hook_destroy) do
219
+
callback(self)
220
+
end
221
+
212
222
ifCLIENTandself.bassthen
213
223
self.bass:Stop()
214
224
elseiftransmitthen
@@ -394,30 +404,9 @@ end
394
404
395
405
--- Used internally. Should be called both server and client as it doesn't send any net messages to destroy the ids to the client.
396
406
-- Called on WebAudio reload to stop all streams
397
-
ifCLIENTthen
398
-
functionWebAudioStatic.disassemble()
399
-
for_, streaminWebAudio.getIterator() do
400
-
stream:Destroy(false)
401
-
end
402
-
end
403
-
else
404
-
functionWebAudioStatic.disassemble()
405
-
-- Todo: This is a dumb hack. There should be a hook mechanism so that the E2 core doesn't need special treatment in webaudio.
406
-
localE2StreamCounter=WebAudio.E2StreamCounter
407
-
408
-
ifE2StreamCounterthen
409
-
for_, streaminWebAudio.getIterator() do
410
-
ifstream.ownerandE2StreamCounter[stream.owner] then
0 commit comments