diff options
| author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-01-19 13:21:39 +0100 |
|---|---|---|
| committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-02-09 12:50:15 +0100 |
| commit | 684752e75bdeb58727c2d9b0ff0265d7fcd47de0 (patch) | |
| tree | 4fc57e9d0738021b8b31699a6339275347e38ec0 /modules/multiplayer | |
| parent | 94dbf69f5d6b7d2fd9561692df2e71557607fddc (diff) | |
| download | redot-engine-684752e75bdeb58727c2d9b0ff0265d7fcd47de0.tar.gz | |
Replace error checks against `size` with `is_empty`
Diffstat (limited to 'modules/multiplayer')
| -rw-r--r-- | modules/multiplayer/multiplayer_debugger.cpp | 6 | ||||
| -rw-r--r-- | modules/multiplayer/scene_multiplayer.cpp | 4 | ||||
| -rw-r--r-- | modules/multiplayer/scene_replication_interface.cpp | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/modules/multiplayer/multiplayer_debugger.cpp b/modules/multiplayer/multiplayer_debugger.cpp index a4d2aed2d6..c816bd3b6b 100644 --- a/modules/multiplayer/multiplayer_debugger.cpp +++ b/modules/multiplayer/multiplayer_debugger.cpp @@ -89,7 +89,7 @@ Error MultiplayerDebugger::_capture(void *p_user, const String &p_msg, const Arr // BandwidthProfiler int MultiplayerDebugger::BandwidthProfiler::bandwidth_usage(const Vector<BandwidthFrame> &p_buffer, int p_pointer) { - ERR_FAIL_COND_V(p_buffer.size() == 0, 0); + ERR_FAIL_COND_V(p_buffer.is_empty(), 0); int total_bandwidth = 0; uint64_t timestamp = OS::get_singleton()->get_ticks_msec(); @@ -174,7 +174,7 @@ Array MultiplayerDebugger::RPCFrame::serialize() { } bool MultiplayerDebugger::RPCFrame::deserialize(const Array &p_arr) { - ERR_FAIL_COND_V(p_arr.size() < 1, false); + ERR_FAIL_COND_V(p_arr.is_empty(), false); uint32_t size = p_arr[0]; ERR_FAIL_COND_V(size % 6, false); ERR_FAIL_COND_V((uint32_t)p_arr.size() != size + 1, false); @@ -279,7 +279,7 @@ Array MultiplayerDebugger::ReplicationFrame::serialize() { } bool MultiplayerDebugger::ReplicationFrame::deserialize(const Array &p_arr) { - ERR_FAIL_COND_V(p_arr.size() < 1, false); + ERR_FAIL_COND_V(p_arr.is_empty(), false); uint32_t size = p_arr[0]; ERR_FAIL_COND_V(size % 7, false); ERR_FAIL_COND_V((uint32_t)p_arr.size() != size + 1, false); diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp index 665b246bc5..5655467df7 100644 --- a/modules/multiplayer/scene_multiplayer.cpp +++ b/modules/multiplayer/scene_multiplayer.cpp @@ -440,7 +440,7 @@ void SceneMultiplayer::disconnect_peer(int p_id) { } Error SceneMultiplayer::send_bytes(Vector<uint8_t> p_data, int p_to, MultiplayerPeer::TransferMode p_mode, int p_channel) { - ERR_FAIL_COND_V_MSG(p_data.size() < 1, ERR_INVALID_DATA, "Trying to send an empty raw packet."); + ERR_FAIL_COND_V_MSG(p_data.is_empty(), ERR_INVALID_DATA, "Trying to send an empty raw packet."); ERR_FAIL_COND_V_MSG(!multiplayer_peer.is_valid(), ERR_UNCONFIGURED, "Trying to send a raw packet while no multiplayer peer is active."); ERR_FAIL_COND_V_MSG(multiplayer_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a multiplayer peer which is not connected."); @@ -460,7 +460,7 @@ Error SceneMultiplayer::send_bytes(Vector<uint8_t> p_data, int p_to, Multiplayer Error SceneMultiplayer::send_auth(int p_to, Vector<uint8_t> p_data) { ERR_FAIL_COND_V(multiplayer_peer.is_null() || multiplayer_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED); ERR_FAIL_COND_V(!pending_peers.has(p_to), ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_data.is_empty(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(pending_peers[p_to].local, ERR_FILE_CANT_WRITE, "The authentication session was previously marked as completed, no more authentication data can be sent."); ERR_FAIL_COND_V_MSG(pending_peers[p_to].remote, ERR_FILE_CANT_WRITE, "The remote peer notified that the authentication session was completed, no more authentication data can be sent."); diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp index 35ff62dd06..b61cf0bf1d 100644 --- a/modules/multiplayer/scene_replication_interface.cpp +++ b/modules/multiplayer/scene_replication_interface.cpp @@ -783,7 +783,7 @@ Error SceneReplicationInterface::on_delta_receive(int p_from, const uint8_t *p_b ERR_CONTINUE_MSG(true, "Ignoring delta for non-authority or invalid synchronizer."); } List<NodePath> props = sync->get_delta_properties(indexes); - ERR_FAIL_COND_V(props.size() == 0, ERR_INVALID_DATA); + ERR_FAIL_COND_V(props.is_empty(), ERR_INVALID_DATA); Vector<Variant> vars; vars.resize(props.size()); int consumed = 0; |
