You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Replace error checks against size with is_empty
This commit is contained in:
@@ -40,20 +40,20 @@ void ENetMultiplayerPeer::set_target_peer(int p_peer) {
|
||||
|
||||
int ENetMultiplayerPeer::get_packet_peer() const {
|
||||
ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active.");
|
||||
ERR_FAIL_COND_V(incoming_packets.size() == 0, 1);
|
||||
ERR_FAIL_COND_V(incoming_packets.is_empty(), 1);
|
||||
|
||||
return incoming_packets.front()->get().from;
|
||||
}
|
||||
|
||||
MultiplayerPeer::TransferMode ENetMultiplayerPeer::get_packet_mode() const {
|
||||
ERR_FAIL_COND_V_MSG(!_is_active(), TRANSFER_MODE_RELIABLE, "The multiplayer instance isn't currently active.");
|
||||
ERR_FAIL_COND_V(incoming_packets.size() == 0, TRANSFER_MODE_RELIABLE);
|
||||
ERR_FAIL_COND_V(incoming_packets.is_empty(), TRANSFER_MODE_RELIABLE);
|
||||
return incoming_packets.front()->get().transfer_mode;
|
||||
}
|
||||
|
||||
int ENetMultiplayerPeer::get_packet_channel() const {
|
||||
ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active.");
|
||||
ERR_FAIL_COND_V(incoming_packets.size() == 0, 1);
|
||||
ERR_FAIL_COND_V(incoming_packets.is_empty(), 1);
|
||||
int ch = incoming_packets.front()->get().channel;
|
||||
if (ch >= SYSCH_MAX) { // First 2 channels are reserved.
|
||||
return ch - SYSCH_MAX + 1;
|
||||
@@ -321,7 +321,7 @@ int ENetMultiplayerPeer::get_available_packet_count() const {
|
||||
}
|
||||
|
||||
Error ENetMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
|
||||
ERR_FAIL_COND_V_MSG(incoming_packets.size() == 0, ERR_UNAVAILABLE, "No incoming packets available.");
|
||||
ERR_FAIL_COND_V_MSG(incoming_packets.is_empty(), ERR_UNAVAILABLE, "No incoming packets available.");
|
||||
|
||||
_pop_current_packet();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user