From be6dfc630985e075fe5378d29ea6fe64669c9c80 Mon Sep 17 00:00:00 2001 From: Dragos Daian Date: Thu, 19 Dec 2024 16:58:55 +0100 Subject: [PATCH] lobby client fix peer named event not called when self name --- .../lobby/authoritative_lobby_client.cpp | 24 +++++++++++-------- modules/blazium_sdk/lobby/lobby_client.cpp | 24 +++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp b/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp index ea935a35bb70..59ce1486a55e 100644 --- a/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp +++ b/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp @@ -555,17 +555,21 @@ void AuthoritativeLobbyClient::_receive_data(const Dictionary &p_dict) { String peer_name = data_dict.get("name", ""); if (peer->get_id() == peer_id) { peer->set_peer_name(peer_name); - } - for (int i = 0; i < peers.size(); ++i) { - Ref updated_peer = peers[i]; - if (updated_peer->get_id() == peer_id) { - updated_peer->set_peer_name(peer_name); - // if the named peer is the host, update the host name - if (updated_peer->get_id() == lobby->get_host()) { - lobby->set_host_name(peer_name); + // notify self + emit_signal("peer_named", peer); + } else { + // another peer got named + for (int i = 0; i < peers.size(); ++i) { + Ref updated_peer = peers[i]; + if (updated_peer->get_id() == peer_id) { + updated_peer->set_peer_name(peer_name); + // if the named peer is the host, update the host name + if (updated_peer->get_id() == lobby->get_host()) { + lobby->set_host_name(peer_name); + } + emit_signal("peer_named", updated_peer); + break; } - emit_signal("peer_named", updated_peer); - break; } } } else if (command == "peer_ready") { diff --git a/modules/blazium_sdk/lobby/lobby_client.cpp b/modules/blazium_sdk/lobby/lobby_client.cpp index 16fddfd068df..a7d3bd479ef4 100644 --- a/modules/blazium_sdk/lobby/lobby_client.cpp +++ b/modules/blazium_sdk/lobby/lobby_client.cpp @@ -736,17 +736,21 @@ void LobbyClient::_receive_data(const Dictionary &p_dict) { String peer_name = data_dict.get("name", ""); if (peer->get_id() == peer_id) { peer->set_peer_name(peer_name); - } - for (int i = 0; i < peers.size(); ++i) { - Ref updated_peer = peers[i]; - if (updated_peer->get_id() == peer_id) { - updated_peer->set_peer_name(peer_name); - // if the named peer is the host, update the host name - if (updated_peer->get_id() == lobby->get_host()) { - lobby->set_host_name(peer_name); + // notify self + emit_signal("peer_named", peer); + } else { + // another peer got named + for (int i = 0; i < peers.size(); ++i) { + Ref updated_peer = peers[i]; + if (updated_peer->get_id() == peer_id) { + updated_peer->set_peer_name(peer_name); + // if the named peer is the host, update the host name + if (updated_peer->get_id() == lobby->get_host()) { + lobby->set_host_name(peer_name); + } + emit_signal("peer_named", updated_peer); + break; } - emit_signal("peer_named", updated_peer); - break; } } } else if (command == "peer_ready") {