Skip to content
Permalink
Browse files

Reset local player in CClientGame in CClientPlayer destructor

Solves crash offset 0005973b
  • Loading branch information...
botder committed Sep 25, 2019
1 parent 19d0895 commit 381d74d908c0ba68672d1437dee648628b7d8867
Showing with 15 additions and 1 deletion.
  1. +4 −1 Client/mods/deathmatch/logic/CClientGame.h
  2. +11 −0 Client/mods/deathmatch/logic/CClientPlayer.cpp
@@ -282,10 +282,13 @@ class CClientGame

CBlendedWeather* GetBlendedWeather() { return m_pBlendedWeather; };
CNetAPI* GetNetAPI() { return m_pNetAPI; };
CClientPlayer* GetLocalPlayer() { return m_pLocalPlayer; };
CRadarMap* GetRadarMap() { return m_pRadarMap; };
CMovingObjectsManager* GetMovingObjectsManager() { return m_pMovingObjectsManager; }

CClientPlayer* GetLocalPlayer() { return m_pLocalPlayer; }
const CClientPlayer* GetLocalPlayer() const { return m_pLocalPlayer; }
void ResetLocalPlayer() { m_pLocalPlayer = nullptr; }

CUnoccupiedVehicleSync* GetUnoccupiedVehicleSync() { return m_pUnoccupiedVehicleSync; }
CPedSync* GetPedSync() { return m_pPedSync; }
#ifdef WITH_OBJECT_SYNC
@@ -89,6 +89,17 @@ CClientPlayer::CClientPlayer(CClientManager* pManager, ElementID ID, bool bIsLoc

CClientPlayer::~CClientPlayer()
{
if (m_bIsLocalPlayer)
{
CClientPlayerManager* playerManager = m_pManager->GetPlayerManager();

if (playerManager->GetLocalPlayer() == this)
{
playerManager->SetLocalPlayer(nullptr);
g_pClientGame->ResetLocalPlayer();
}
}

// Remove us from the team
if (m_pTeam)
m_pTeam->RemovePlayer(this);

0 comments on commit 381d74d

Please sign in to comment.
You can’t perform that action at this time.