Fixed crashing bug in cClientHandle::~cClientHandle
When there are players in the server, and a client connects as far as the handshake and then disconnects, the server crashed. This is because there is no m_Player yet after the handshake, and the destructor uses m_Player without checking if it exists git-svn-id: http://mc-server.googlecode.com/svn/trunk@163 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
ac63775297
commit
f47c852186
@ -183,12 +183,14 @@ 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(m_Player->GetColor() + GetUsername(), false, (short)9999);
|
||||
std::string NameColor = ( m_Player ? m_Player->GetColor() : "" );
|
||||
cPacket_PlayerListItem PlayerList(NameColor + GetUsername(), false, (short)9999);
|
||||
(*itr)->GetClientHandle()->Send( PlayerList );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user