summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2020-03-29 22:58:19 +0200
committerGitHub <noreply@github.com>2020-03-29 22:58:19 +0200
commit6116f899dee33a6d7bd887f7a57ace17df2ab94f (patch)
tree22dd17be6dd84e416124d6a3540feffd81613661 /src
parentCorrectly pass cache arguments to cmake in Jenkins build script (diff)
downloadcuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.tar
cuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.tar.gz
cuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.tar.bz2
cuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.tar.lz
cuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.tar.xz
cuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.tar.zst
cuberite-6116f899dee33a6d7bd887f7a57ace17df2ab94f.zip
Diffstat (limited to 'src')
-rw-r--r--src/ClientHandle.cpp6
-rw-r--r--src/World.cpp8
2 files changed, 9 insertions, 5 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 3a0eb1edd..40107153b 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -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
}
diff --git a/src/World.cpp b/src/World.cpp
index 2d0dfca9f..a08c269d8 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -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;
+ }
}
{