diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index 47fbcfb50..d0cdb6a54 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -455,7 +455,6 @@ void ClientLobby::displayPlayerVote(Event* event) std::string player_name; data.decodeString(&player_name); uint32_t host_id = data.getUInt32(); - player_name += ": "; std::string track_name; data.decodeString(&track_name); Track* track = track_manager->getTrack(track_name); @@ -502,7 +501,7 @@ void ClientLobby::displayPlayerVote(Event* event) vote_msg = _("Track: %s,\nlaps: %d, reversed: %s", track_readable, lap, rev == 1 ? yes : no); } - vote_msg = StringUtils::utf8ToWide(player_name) + vote_msg; + vote_msg = StringUtils::utf8ToWide(player_name) + L": " + vote_msg; TracksScreen::getInstance()->addVoteMessage(player_name + StringUtils::toString(host_id), vote_msg); } // displayPlayerVote @@ -527,11 +526,15 @@ void ClientLobby::disconnectedPlayer(Event* event) unsigned disconnected_player_count = data.getUInt8(); for (unsigned i = 0; i < disconnected_player_count; i++) { - core::stringw player_name; - data.decodeStringW(&player_name); + std::string name; + data.decodeString(&name); + core::stringw player_name = StringUtils::utf8ToWide(name); core::stringw msg = _("%s disconnected.", player_name); + uint32_t host_id = data.getUInt32(); // Use the friend icon to avoid an error-like message MessageQueue::add(MessageQueue::MT_FRIEND, msg); + TracksScreen::getInstance()->removeVote( + name + StringUtils::toString(host_id)); } } // disconnectedPlayer diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 1ac1a1511..b6c38eb15 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -1406,7 +1406,7 @@ void ServerLobby::clientDisconnected(Event* event) for (auto p : players_on_peer) { std::string name = StringUtils::wideToUtf8(p->getName()); - msg->encodeString(name); + msg->encodeString(name).addUInt32(event->getPeer()->getHostId()); Log::info("ServerLobby", "%s disconnected", name.c_str()); } diff --git a/src/states_screens/online/tracks_screen.hpp b/src/states_screens/online/tracks_screen.hpp index 1942ff5f7..137ef5966 100644 --- a/src/states_screens/online/tracks_screen.hpp +++ b/src/states_screens/online/tracks_screen.hpp @@ -112,10 +112,14 @@ public: void setVoteTimeout(float timeout); - void addVoteMessage(const std::string& user, + void addVoteMessage(const std::string& user_host_id, const irr::core::stringw& message) { - m_vote_messages[user] = message; + m_vote_messages[user_host_id] = message; + } + void removeVote(const std::string& user_host_id) + { + m_vote_messages.erase(user_host_id); } };