Replace error checks against size with is_empty
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.");
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user