From aa03b6b51ec673bcf5b7d9dda11161701c3de836 Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Fri, 3 Nov 2023 16:29:27 -0500 Subject: [PATCH] Fix custom procedural crash --- sp/src/game/server/entitylist.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sp/src/game/server/entitylist.cpp b/sp/src/game/server/entitylist.cpp index 55d5614b..29d87f50 100644 --- a/sp/src/game/server/entitylist.cpp +++ b/sp/src/game/server/entitylist.cpp @@ -736,6 +736,12 @@ CBaseEntity *CGlobalEntityList::FindEntityCustomProcedural( CBaseEntity *pStartE g_pScriptVM->ExecuteFunction( g_CustomProcedurals[i].hFunc, args, 5, &functionReturn, NULL, true ); + if (pStartEntity && ToEnt( functionReturn.m_hScript ) == pStartEntity) + { + Warning( "WARNING: Custom procedural %s returned entity identical to start entity (%s), returning null\n", g_CustomProcedurals[i].szName, pStartEntity->GetDebugName() ); + return NULL; + } + return ToEnt( functionReturn.m_hScript ); } }