summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/connection.cpp18
-rw-r--r--src/net/netcomputer.cpp6
2 files changed, 18 insertions, 6 deletions
diff --git a/src/net/connection.cpp b/src/net/connection.cpp
index c54c0dbb..b2bc7cef 100644
--- a/src/net/connection.cpp
+++ b/src/net/connection.cpp
@@ -31,8 +31,8 @@
#endif
Connection::Connection():
- mRemote(0),
- mLocal(0)
+ mRemote(nullptr),
+ mLocal(nullptr)
{
}
@@ -86,8 +86,8 @@ void Connection::stop()
if (mLocal)
enet_host_destroy(mLocal);
- mRemote = 0;
- mLocal = 0;
+ mRemote = nullptr;
+ mLocal = nullptr;
}
bool Connection::isConnected() const
@@ -110,9 +110,17 @@ void Connection::send(const MessageOut &msg, bool reliable, unsigned channel)
reliable ? ENET_PACKET_FLAG_RELIABLE : 0);
if (packet)
- enet_peer_send(mRemote, channel, packet);
+ {
+ if (enet_peer_send(mRemote, channel, packet) < 0)
+ {
+ LOG_ERROR("Failure to send packet!");
+ enet_packet_destroy(packet);
+ }
+ }
else
+ {
LOG_ERROR("Failure to create packet!");
+ }
}
void Connection::process()
diff --git a/src/net/netcomputer.cpp b/src/net/netcomputer.cpp
index 5d86f13a..f2d9607b 100644
--- a/src/net/netcomputer.cpp
+++ b/src/net/netcomputer.cpp
@@ -70,7 +70,11 @@ void NetComputer::send(const MessageOut &msg, bool reliable,
if (packet)
{
- enet_peer_send(mPeer, channel, packet);
+ if (enet_peer_send(mPeer, channel, packet) < 0)
+ {
+ LOG_ERROR("Failure to send packet!");
+ enet_packet_destroy(packet);
+ }
}
else
{