Skip to content

Commit

Permalink
physenv: testing a fix for another crash
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed Nov 19, 2024
1 parent 5a9cd8e commit c80ce09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions source/modules/physenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c80ce09

Please sign in to comment.