diff options
Diffstat (limited to 'modules/enet/networked_multiplayer_enet.cpp')
-rw-r--r-- | modules/enet/networked_multiplayer_enet.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 2f5307d041..21dd758391 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -75,7 +75,7 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int ERR_FAIL_COND_V(active, ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(p_max_clients < 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_max_clients < 1 || p_max_clients > 4095, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_in_bandwidth < 0, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_out_bandwidth < 0, ERR_INVALID_PARAMETER); @@ -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) |