From 0321819ce83e4ef3fae25ade4256a3a3229d1821 Mon Sep 17 00:00:00 2001 From: "mtilden@gmail.com" Date: Mon, 26 Dec 2011 02:46:53 +0000 Subject: - Scoreboard deleting moved to cClientHandle::~cClientHandle() with checks. Please test this every way you can with clients disconnecting from the internet, crashing, etc. It should work on all cases as every client gets called in this part to be 'Deleted' git-svn-id: http://mc-server.googlecode.com/svn/trunk@118 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 66d343784..05bdec249 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -178,6 +178,16 @@ cClientHandle::~cClientHandle() if( m_LoadedChunks[i] ) m_LoadedChunks[i]->RemoveClient( this ); } + cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers(); + for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr ) + { + if ((*itr) && (*itr)->GetClientHandle() && strlen(GetUsername()) > 0) + { + cPacket_PlayerListItem *PlayerList = new cPacket_PlayerListItem(m_Player->GetColor() + GetUsername(), false, (short)9999); + (*itr)->GetClientHandle()->Send( *PlayerList ); + } + } + // First stop sending thread m_bKeepThreadGoing = false; @@ -1162,12 +1172,6 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) { cPacket_Chat DisconnectMessage( m_pState->Username + " disconnected: " + PacketData->m_Reason ); cRoot::Get()->GetServer()->Broadcast( DisconnectMessage ); - cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers(); - for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr ) - { - cPacket_PlayerListItem *PlayerList = new cPacket_PlayerListItem(m_Player->GetColor() + GetUsername(), false, (short)9999); - (*itr)->GetClientHandle()->Send( *PlayerList ); - } } Destroy(); return; -- cgit v1.2.3