diff --git a/source/modules/physenv.cpp b/source/modules/physenv.cpp index 8c1616a..5feba2e 100644 --- a/source/modules/physenv.cpp +++ b/source/modules/physenv.cpp @@ -301,11 +301,11 @@ static Push_LuaClass(Vector, GarrysMod::Lua::Type::Vector) inline IPhysicsEnvironment* GetPhysicsEnvironment(int iStackPos, bool bError) { - ILuaPhysicsEnvironment* pEnvironment = Get_ILuaPhysicsEnvironment(iStackPos, bError); - if (!pEnvironment->pEnvironment && bError) + ILuaPhysicsEnvironment* pLuaEnv = Get_ILuaPhysicsEnvironment(iStackPos, bError); + if (!pLuaEnv->pEnvironment && bError) g_Lua->ThrowError(triedNull_ILuaPhysicsEnvironment.c_str()); - return pEnvironment->pEnvironment; + return pLuaEnv->pEnvironment; } LUA_FUNCTION_STATIC(physenv_CreateEnvironment) @@ -390,11 +390,12 @@ LUA_FUNCTION_STATIC(physenv_DestroyEnvironment) CBaseEntity* pEntity = (CBaseEntity*)pObject->GetGameData(); if (pEntity) { - + pEntity->VPhysicsUpdate(NULL); // Since the vtables are broken since ~4 functions were removed, this should currently call VPhysicsDestroyObject } } physics->DestroyEnvironment(pEnvironment); + pLuaEnv->pEnvironment = NULL; } Delete_ILuaPhysicsEnvironment(pLuaEnv); diff --git a/source/util.h b/source/util.h index e725556..4210c99 100644 --- a/source/util.h +++ b/source/util.h @@ -196,7 +196,7 @@ struct LuaUserData { // ToDo: Maybe implement this also for other things? int iReference = -1; int iTableReference = -1; - int pAdditionalData = -1; // Used by HLTVClient. + int pAdditionalData = NULL; // Used by HLTVClient. }; // This one is special