Fixed disconnecting of a client.

This commit is contained in:
hiker 2015-12-01 08:19:48 +11:00
parent bcfec98fa2
commit c9a23bcbb7
2 changed files with 3 additions and 1 deletions

View File

@ -138,6 +138,7 @@ void ClientLobbyRoomProtocol::voteLaps(uint8_t laps, uint8_t track_nb)
void ClientLobbyRoomProtocol::leave()
{
m_server->disconnect();
STKHost::get()->removePeer(m_server);
m_server_address.clear();
} // leave
@ -364,6 +365,7 @@ void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
Log::error("ClientLobbyRoomProtocol",
"The disconnected peer wasn't known.");
}
STKHost::get()->removePeer(event->getPeer());
} // disconnectedPlayer
//-----------------------------------------------------------------------------

View File

@ -398,9 +398,9 @@ void ServerLobbyRoomProtocol::kartDisconnected(Event* event)
sendMessage(msg);
Log::info("ServerLobbyRoomProtocol", "Player disconnected : id %d",
peer->getPlayerProfile()->getPlayerID());
m_setup->removePlayer(peer->getPlayerProfile());
// Remove the profile from the peer (to avoid double free)
peer->setPlayerProfile(NULL);
m_setup->removePlayer(peer->getPlayerProfile());
STKHost::get()->removePeer(peer);
}
else