diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-16 23:12:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-16 23:12:40 +0100 |
commit | 4c99301d69d66a6988134ad76647311fc94122b7 (patch) | |
tree | 726a84541e497ec3892ea04d57fa00d245cb944a | |
parent | 05e042b06f221680cef7c79d5fe038ddcde9c25b (diff) | |
parent | ce47d5af7754f24fcb66876e19c25425ef2ecaf6 (diff) |
Merge pull request #34789 from Faless/enet/disconnect_relay
ENet optional server_relay when disconnecting peer
-rw-r--r-- | modules/enet/networked_multiplayer_enet.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 61fc7688c5..21dd758391 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -479,23 +479,23 @@ void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) { ERR_FAIL_COND(!peer_map.has(p_peer)); if (now) { + int *id = (int *)peer_map[p_peer]->data; enet_peer_disconnect_now(peer_map[p_peer], 0); // enet_peer_disconnect_now doesn't generate ENET_EVENT_TYPE_DISCONNECT, // notify everyone else, send disconnect signal & remove from peer_map like in poll() + if (server_relay) { + for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - int *id = NULL; - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { + if (E->key() == p_peer) { + continue; + } - if (E->key() == p_peer) { - id = (int *)(E->get()->data); - continue; + ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE); + encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); + encode_uint32(p_peer, &packet->data[4]); + enet_peer_send(E->get(), SYSCH_CONFIG, packet); } - - ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE); - encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); - encode_uint32(p_peer, &packet->data[4]); - enet_peer_send(E->get(), SYSCH_CONFIG, packet); } if (id) |