Extend thread check to all sdkhooks (#2534)

This commit is contained in:
Benoist
2026-09-04 09:25:30 -04:00
committed by GitHub
parent bea10f0fb1
commit f7fd4fe4a7
+5 -5
View File
@@ -499,6 +499,11 @@ FeatureStatus SDKHooks::GetFeatureStatus(FeatureType type, const char *name)
static void PopulateCallbackList(const std::vector<HookList> &source, std::vector<IPluginFunction *> &destination, int entity)
{
// SourcePawn cannot be called from worker threads. This can happen on some
// engine variants, where the engine invokes ShouldCollide off-thread.
if (g_MainThreadId != std::this_thread::get_id())
return;
destination.reserve(8);
for (size_t iter = 0; iter < source.size(); ++iter)
{
@@ -1386,11 +1391,6 @@ void SDKHooks::Hook_SetTransmit(CCheckTransmitInfo *pInfo, bool bAlways)
bool SDKHooks::Hook_ShouldCollide(int collisionGroup, int contentsMask)
{
// SourcePawn cannot be called from worker threads. This can happen on some
// engine variants, where the engine invokes ShouldCollide off-thread.
if (g_MainThreadId != std::this_thread::get_id())
RETURN_META_VALUE(MRES_IGNORED, false);
CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity);
CVTableHook vhook(pEntity);