Skip to content

Commit

Permalink
Merge pull request #203 from Ughuuu/lobby-client-fix-peer-named
Browse files Browse the repository at this point in the history
lobby client fix peer named event not called when self name
  • Loading branch information
Bioblaze authored Dec 20, 2024
2 parents 5a06a33 + be6dfc6 commit 94b0deb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
24 changes: 14 additions & 10 deletions modules/blazium_sdk/lobby/authoritative_lobby_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LobbyPeer> 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<LobbyPeer> 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") {
Expand Down
24 changes: 14 additions & 10 deletions modules/blazium_sdk/lobby/lobby_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LobbyPeer> 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<LobbyPeer> 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") {
Expand Down

0 comments on commit 94b0deb

Please sign in to comment.