Skip to content

Commit f9c8119

Browse files
committed
voicechat: push this
1 parent fdf2b55 commit f9c8119

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

source/modules/voicechat.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,33 @@ static void hook_SV_BroadcastVoiceData(IClient* pClient, int nBytes, char* data,
231231

232232
Util::Push_Entity((CBaseEntity*)Util::GetPlayerByClient((CBaseClient*)pClient));
233233
Push_VoiceData(pVoiceData);
234+
g_Lua->Push(-1);
235+
int iReference = g_Lua->ReferenceCreate();
234236
bool bHandled = false;
235237
if (g_Lua->CallFunctionProtected(3, 1, true))
236238
{
237239
bHandled = g_Lua->GetBool(-1);
238240
g_Lua->Pop(1);
239241
}
240242

243+
/*
244+
* What are we doing down there? Were calling the __gc method on the VoiceData to NULL it.
245+
* Why? because else we would inflate the debug registry(& it never shrinks) as the GC won't be fast enouth to clean all the created VoiceData.
246+
*/
247+
248+
g_Lua->PushString("__gc");
249+
g_Lua->ReferencePush(iReference);
250+
g_Lua->ReferenceFree(iReference);
251+
if (g_Lua->FindOnObjectsMetaTable(-1, -2))
252+
{
253+
g_Lua->Push(-2);
254+
g_Lua->CallFunctionProtected(1, 0, true);
255+
} else {
256+
Warning("holylib: Failed to find VoiceData:__gc!\n");
257+
}
258+
259+
g_Lua->Pop(2);
260+
241261
if (bHandled)
242262
return;
243263
}

0 commit comments

Comments
 (0)