diff options
author | Kyle <eichlinkyle@gmail.com> | 2021-03-01 08:25:07 -0500 |
---|---|---|
committer | Kyle <eichlinkyle@gmail.com> | 2021-03-01 08:25:07 -0500 |
commit | 74379b15ff7f534730557836be901e3c8a3cd2f8 (patch) | |
tree | ec664ba934f402b82a213718abe56ac4773af3a7 /core/io | |
parent | bd42a6c51e384f55bbfda9ce64f85b471dbabda6 (diff) |
MultiplayerAPI is_network_server Fails Silently
Removes the error message when the network peer is not valid and returns false instead.
This makes it simpler to make games that are both on/offline by replacing server checks of
'''
if is_instance_valid(get_tree().network_peer) and get_tree().is_network_server():
# Do server things
'''
with
'''
if get_tree().is_network_server():
# Do server things
'''
Requires no changes to the docs because both the MultiplayerAPI and SceneTree docs don't mention the error.
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/multiplayer_api.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 6b550e69c8..90831dbf9b 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -1170,9 +1170,7 @@ int MultiplayerAPI::get_network_unique_id() const { } bool MultiplayerAPI::is_network_server() const { - // XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier? - ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. I can't be a server."); - return network_peer->is_server(); + return network_peer.is_valid() && network_peer->is_server(); } void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) { |