1
0
Fork 0

Fix client disconnect assert (#4579)

This commit is contained in:
peterbell10 2020-03-29 21:58:19 +01:00 committed by GitHub
parent 1e4cf9ce48
commit 6116f899de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -163,8 +163,8 @@ void cClientHandle::Destroy(void)
LOGD("%s: destroying client %p, \"%s\" @ %s", __FUNCTION__, static_cast<void *>(this), m_Username.c_str(), m_IPString.c_str());
auto player = m_Player;
m_Self.reset();
SetState(csDestroyed); // Tick thread is allowed to call destructor async at any time after this
auto Self = std::move(m_Self); // Keep ourself alive for at least as long as this function
SetState(csDestroyed);
if (player == nullptr)
{
@ -3350,7 +3350,7 @@ void cClientHandle::SetSelf(cClientHandlePtr a_Self)
bool cClientHandle::SetState(eState a_NewState)
{
cCSLock Lock(m_CSState);
if (a_NewState < m_State)
if (a_NewState <= m_State)
{
return false; // Can only advance the state machine
}

View File

@ -2543,9 +2543,13 @@ std::unique_ptr<cPlayer> cWorld::RemovePlayer(cPlayer & a_Player)
#ifdef _DEBUG
bool cWorld::IsPlayerReferencedInWorldOrChunk(cPlayer & a_Player)
{
if (m_ChunkMap->RemoveEntity(a_Player) != nullptr)
{
return true;
cLock lock(*this);
auto * Chunk = a_Player.GetParentChunk();
if (Chunk && Chunk->HasEntity(a_Player.GetUniqueID()))
{
return true;
}
}
{