summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-29 09:40:15 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-29 09:40:15 +0100
commit94132159be14774d56392136c10b908cb89cd33d (patch)
treebf80b16a3f33a2a795474700d1931b346c975314
parentImproved threading performance by reducing thread-hopping in queue locks (cs unlocked before event set) (diff)
downloadcuberite-94132159be14774d56392136c10b908cb89cd33d.tar
cuberite-94132159be14774d56392136c10b908cb89cd33d.tar.gz
cuberite-94132159be14774d56392136c10b908cb89cd33d.tar.bz2
cuberite-94132159be14774d56392136c10b908cb89cd33d.tar.lz
cuberite-94132159be14774d56392136c10b908cb89cd33d.tar.xz
cuberite-94132159be14774d56392136c10b908cb89cd33d.tar.zst
cuberite-94132159be14774d56392136c10b908cb89cd33d.zip
-rw-r--r--source/cPlayer.cpp8
-rw-r--r--source/cWorld.cpp8
2 files changed, 12 insertions, 4 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 7899fdc97..c71f04d33 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -124,7 +124,12 @@ void cPlayer::Initialize( cWorld* a_World )
cPlayer::~cPlayer(void)
{
+ LOG("Deleting cPlayer \"%s\" @ %p", m_pState->PlayerName.c_str(), this);
+
SaveToDisk();
+
+ m_World->RemovePlayer( this );
+
m_ClientHandle = NULL;
CloseWindow(-1);
@@ -134,7 +139,8 @@ cPlayer::~cPlayer(void)
delete m_CreativeInventory;
delete m_pState;
- m_World->RemovePlayer( this );
+
+ LOG("Player %p deleted", this);
}
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index cc7f0b88b..85faa72e0 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -905,12 +905,13 @@ const double & cWorld::GetSpawnY(void)
-void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude)
+void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- if (((*itr)->GetClientHandle() == a_Exclude) || !(*itr)->GetClientHandle()->IsLoggedIn() )
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch == a_Exclude) || (ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
{
continue;
}
@@ -1187,7 +1188,8 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
cCSLock Lock(m_CSPlayers);
for ( cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- if (((*itr)->GetClientHandle() != NULL) && !((*itr)->GetClientHandle()->IsDestroyed()))
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch != NULL) && !ch->IsDestroyed())
{
cPacket_PlayerListItem PlayerListItem((*itr)->GetColor() + (*itr)->GetName(), true, (*itr)->GetClientHandle()->GetPing());
a_DestPlayer->GetClientHandle()->Send( PlayerListItem );