Skip to content

Commit

Permalink
sourcetv: try to fix a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed Nov 19, 2024
1 parent a859cdb commit 370f45b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,10 @@ Returns `IPhysicsEnvironment [NULL]` if invalid.
Else it returns `IPhysicsEnvironment`.

#### bool IPhysicsEnvironment:TransferObject(IPhysicsObject obj, IPhysicsEnvironment newEnvironment)
Transfers the physics object from this environment to the new environment.
Transfers the physics object from this environment to the new environment. #

> [!WARNING]
> You shouldn't transfer players or vehicles.
#### IPhysicsEnvironment:SetGravity(Vector newGravity)
Sets the new gravity in `source_unit/s^2`
Expand Down
11 changes: 10 additions & 1 deletion source/modules/sourcetv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ static void hook_CSteam3Server_NotifyClientDisconnect(void* pServer, IClient* pC
{
VPROF_BUDGET("HolyLib - CSteam3Server::NotifyClientDisconnect", VPROF_BUDGETGROUP_HOLYLIB);

if (pClient->GetServer()->IsHLTV())
if (!hltv)
{
detour_CSteam3Server_NotifyClientDisconnect.GetTrampoline<Symbols::CSteam3Server_NotifyClientDisconnect>()(pServer, pClient);
return;
}

Msg("HLTV: %s\n", pClient->IsHLTV() ? "true" : "false");
Msg("Server: %p - %p\n", pClient->GetServer(), hltv);

if (pClient->IsHLTV()) // pClient->GetServer()->IsHLTV() crashes... Why.
{
if (Lua::PushHook("HolyLib:OnSourceTVClientDisconnect"))
{
Expand Down

0 comments on commit 370f45b

Please sign in to comment.