diff --git a/src/network/protocols/client_lobby_room_protocol.cpp b/src/network/protocols/client_lobby_room_protocol.cpp index da45535d5..5e8afc847 100644 --- a/src/network/protocols/client_lobby_room_protocol.cpp +++ b/src/network/protocols/client_lobby_room_protocol.cpp @@ -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 //----------------------------------------------------------------------------- diff --git a/src/network/protocols/server_lobby_room_protocol.cpp b/src/network/protocols/server_lobby_room_protocol.cpp index 5243602b4..78dfc33e3 100644 --- a/src/network/protocols/server_lobby_room_protocol.cpp +++ b/src/network/protocols/server_lobby_room_protocol.cpp @@ -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