Fix crash in ENet changing refuse_new_connections

When the host is not started.

(cherry picked from commit e5f3159a23)
This commit is contained in:
Fabio Alessandrelli 2020-07-23 10:38:48 +02:00 committed by Rémi Verschelde
parent 4a0568b609
commit e36c100365
1 changed files with 5 additions and 1 deletions

View File

@ -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
}