diff options
Diffstat (limited to 'modules/enet/enet_connection.cpp')
-rw-r--r-- | modules/enet/enet_connection.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp index 0ace89caa5..94473c76c0 100644 --- a/modules/enet/enet_connection.cpp +++ b/modules/enet/enet_connection.cpp @@ -37,7 +37,7 @@ #include "core/variant/typed_array.h" void ENetConnection::broadcast(enet_uint8 p_channel, ENetPacket *p_packet) { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_MSG(p_channel >= host->channelLimit, vformat("Unable to send packet on channel %d, max channels: %d", p_channel, (int)host->channelLimit)); enet_host_broadcast(host, p_channel, p_packet); } @@ -71,7 +71,7 @@ Error ENetConnection::create_host(int p_max_peers, int p_max_channels, int p_in_ } void ENetConnection::destroy() { - ERR_FAIL_COND_MSG(!host, "Host already destroyed"); + ERR_FAIL_NULL_MSG(host, "Host already destroyed."); for (List<Ref<ENetPacketPeer>>::Element *E = peers.front(); E; E = E->next()) { E->get()->_on_disconnect(); } @@ -82,7 +82,7 @@ void ENetConnection::destroy() { Ref<ENetPacketPeer> ENetConnection::connect_to_host(const String &p_address, int p_port, int p_channels, int p_data) { Ref<ENetPacketPeer> out; - ERR_FAIL_COND_V_MSG(!host, out, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, out, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_V_MSG(peers.size(), out, "The ENetConnection is already connected to a peer."); ERR_FAIL_COND_V_MSG(p_port < 1 || p_port > 65535, out, "The remote port number must be between 1 and 65535 (inclusive)."); @@ -142,7 +142,7 @@ ENetConnection::EventType ENetConnection::_parse_event(const ENetEvent &p_event, return EVENT_ERROR; } break; case ENET_EVENT_TYPE_RECEIVE: { - // Packet reveived. + // Packet received. if (p_event.peer->data != nullptr) { Ref<ENetPacketPeer> pp = Ref<ENetPacketPeer>((ENetPacketPeer *)p_event.peer->data); r_event.peer = Ref<ENetPacketPeer>((ENetPacketPeer *)p_event.peer->data); @@ -160,7 +160,7 @@ ENetConnection::EventType ENetConnection::_parse_event(const ENetEvent &p_event, } ENetConnection::EventType ENetConnection::service(int p_timeout, Event &r_event) { - ERR_FAIL_COND_V_MSG(!host, EVENT_ERROR, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, EVENT_ERROR, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_V(r_event.peer.is_valid(), EVENT_ERROR); // Drop peers that have already been disconnected. @@ -186,7 +186,7 @@ ENetConnection::EventType ENetConnection::service(int p_timeout, Event &r_event) } int ENetConnection::check_events(EventType &r_type, Event &r_event) { - ERR_FAIL_COND_V_MSG(!host, -1, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, -1, "The ENetConnection instance isn't currently active."); ENetEvent event; int ret = enet_host_check_events(host, &event); if (ret < 0) { @@ -198,32 +198,32 @@ int ENetConnection::check_events(EventType &r_type, Event &r_event) { } void ENetConnection::flush() { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); enet_host_flush(host); } void ENetConnection::bandwidth_limit(int p_in_bandwidth, int p_out_bandwidth) { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); enet_host_bandwidth_limit(host, p_in_bandwidth, p_out_bandwidth); } void ENetConnection::channel_limit(int p_max_channels) { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); enet_host_channel_limit(host, p_max_channels); } void ENetConnection::bandwidth_throttle() { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); enet_host_bandwidth_throttle(host); } void ENetConnection::compress(CompressionMode p_mode) { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); Compressor::setup(host, p_mode); } double ENetConnection::pop_statistic(HostStatistic p_stat) { - ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active."); uint32_t *ptr = nullptr; switch (p_stat) { case HOST_TOTAL_SENT_DATA: @@ -239,19 +239,19 @@ double ENetConnection::pop_statistic(HostStatistic p_stat) { ptr = &(host->totalReceivedPackets); break; } - ERR_FAIL_COND_V_MSG(ptr == nullptr, 0, "Invalid statistic: " + itos(p_stat)); + ERR_FAIL_NULL_V_MSG(ptr, 0, "Invalid statistic: " + itos(p_stat) + "."); uint32_t ret = *ptr; *ptr = 0; return ret; } int ENetConnection::get_max_channels() const { - ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active."); return host->channelLimit; } int ENetConnection::get_local_port() const { - ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_V_MSG(!(host->socket), 0, "The ENetConnection instance isn't currently bound"); ENetAddress address; ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), 0, "Unable to get socket address"); @@ -265,7 +265,7 @@ void ENetConnection::get_peers(List<Ref<ENetPacketPeer>> &r_peers) { } TypedArray<ENetPacketPeer> ENetConnection::_get_peers() { - ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, Array(), "The ENetConnection instance isn't currently active."); TypedArray<ENetPacketPeer> out; for (const Ref<ENetPacketPeer> &I : peers) { out.push_back(I); @@ -275,7 +275,7 @@ TypedArray<ENetPacketPeer> ENetConnection::_get_peers() { Error ENetConnection::dtls_server_setup(const Ref<TLSOptions> &p_options) { #ifdef GODOT_ENET - ERR_FAIL_COND_V_MSG(!host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_V(p_options.is_null() || !p_options->is_server(), ERR_INVALID_PARAMETER); return enet_host_dtls_server_setup(host, const_cast<TLSOptions *>(p_options.ptr())) ? FAILED : OK; #else @@ -285,7 +285,7 @@ Error ENetConnection::dtls_server_setup(const Ref<TLSOptions> &p_options) { void ENetConnection::refuse_new_connections(bool p_refuse) { #ifdef GODOT_ENET - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); enet_host_refuse_new_connections(host, p_refuse); #else ERR_FAIL_MSG("ENet DTLS support not available in this build."); @@ -294,7 +294,7 @@ void ENetConnection::refuse_new_connections(bool p_refuse) { Error ENetConnection::dtls_client_setup(const String &p_hostname, const Ref<TLSOptions> &p_options) { #ifdef GODOT_ENET - ERR_FAIL_COND_V_MSG(!host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_V_MSG(host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_V(p_options.is_null() || p_options->is_server(), ERR_INVALID_PARAMETER); return enet_host_dtls_client_setup(host, p_hostname.utf8().get_data(), const_cast<TLSOptions *>(p_options.ptr())) ? FAILED : OK; #else @@ -315,7 +315,7 @@ Error ENetConnection::_create(ENetAddress *p_address, int p_max_peers, int p_max p_in_bandwidth /* limit incoming bandwidth if > 0 */, p_out_bandwidth /* limit outgoing bandwidth if > 0 */); - ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create an ENet host."); + ERR_FAIL_NULL_V_MSG(host, ERR_CANT_CREATE, "Couldn't create an ENet host."); return OK; } @@ -335,7 +335,7 @@ Array ENetConnection::_service(int p_timeout) { } void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_flags) { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_MSG(p_channel < 0 || p_channel > (int)host->channelLimit, "Invalid channel"); ERR_FAIL_COND_MSG(p_flags & ~ENetPacketPeer::FLAG_ALLOWED, "Invalid flags"); ENetPacket *pkt = enet_packet_create(p_packet.ptr(), p_packet.size(), p_flags); @@ -343,7 +343,7 @@ void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_f } void ENetConnection::socket_send(const String &p_address, int p_port, const PackedByteArray &p_packet) { - ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active."); ERR_FAIL_COND_MSG(!(host->socket), "The ENetConnection instance isn't currently bound"); ERR_FAIL_COND_MSG(p_port < 1 || p_port > 65535, "The remote port number must be between 1 and 65535 (inclusive)."); @@ -497,7 +497,7 @@ size_t ENetConnection::Compressor::enet_decompress(void *context, const enet_uin } void ENetConnection::Compressor::setup(ENetHost *p_host, CompressionMode p_mode) { - ERR_FAIL_COND(!p_host); + ERR_FAIL_NULL(p_host); switch (p_mode) { case COMPRESS_NONE: { enet_host_compress(p_host, nullptr); |