From e36c100365e02367ec119eea5b6aef35d151de5f Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 23 Jul 2020 10:38:48 +0200 Subject: [PATCH] Fix crash in ENet changing refuse_new_connections When the host is not started. (cherry picked from commit e5f3159a2323d1b5da19ee77936c40e04ef776df) --- modules/enet/networked_multiplayer_enet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 59b4c0b99fb..121c287268c 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -110,6 +110,7 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int if (dtls_enabled) { enet_host_dtls_server_setup(host, dtls_key.ptr(), dtls_cert.ptr()); } + enet_host_refuse_new_connections(host, refuse_connections); #endif _setup_compressor(); @@ -166,6 +167,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por if (dtls_enabled) { enet_host_dtls_client_setup(host, dtls_cert.ptr(), dtls_verify, p_address.utf8().get_data()); } + enet_host_refuse_new_connections(host, refuse_connections); #endif _setup_compressor(); @@ -669,7 +671,9 @@ void NetworkedMultiplayerENet::set_refuse_new_connections(bool p_enable) { refuse_connections = p_enable; #ifdef GODOT_ENET - enet_host_refuse_new_connections(host, p_enable); + if (active) { + enet_host_refuse_new_connections(host, p_enable); + } #endif }