aboutsummaryrefslogtreecommitdiff
path: root/src/network/connection.h
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-19 22:23:47 +0200
committerGitHub <noreply@github.com>2017-08-19 22:23:47 +0200
commit88b436e6a9c98af7215bd115e1b7a3f1a1db99d3 (patch)
treef07cdd7f93ca26b84192d7b89f7b952e603ba5cf /src/network/connection.h
parent7528986e4449febead9b18b6118f0b096f7cf800 (diff)
downloadminetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.tar.gz
minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.tar.bz2
minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.zip
Code modernization: subfolders (#6283)
* Code modernization: subfolders Modernize various code on subfolders client, network, script, threading, unittests, util * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Make connection.cpp readable in a pointed place + typo
Diffstat (limited to 'src/network/connection.h')
-rw-r--r--src/network/connection.h58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/network/connection.h b/src/network/connection.h
index bf192870b..c64272035 100644
--- a/src/network/connection.h
+++ b/src/network/connection.h
@@ -133,16 +133,14 @@ inline bool seqnum_higher(u16 totest, u16 base)
{
if ((totest - base) > (SEQNUM_MAX/2))
return false;
- else
- return true;
- }
- else
- {
- if ((base - totest) > (SEQNUM_MAX/2))
- return true;
- else
- return false;
+
+ return true;
}
+
+ if ((base - totest) > (SEQNUM_MAX/2))
+ return true;
+
+ return false;
}
inline bool seqnum_in_window(u16 seqnum, u16 next,u16 window_size)
@@ -150,14 +148,12 @@ inline bool seqnum_in_window(u16 seqnum, u16 next,u16 window_size)
u16 window_start = next;
u16 window_end = ( next + window_size ) % (SEQNUM_MAX+1);
- if (window_start < window_end)
- {
+ if (window_start < window_end) {
return ((seqnum >= window_start) && (seqnum < window_end));
}
- else
- {
- return ((seqnum < window_end) || (seqnum >= window_start));
- }
+
+
+ return ((seqnum < window_end) || (seqnum >= window_start));
}
struct BufferedPacket
@@ -166,8 +162,7 @@ struct BufferedPacket
data(a_data, a_size)
{}
BufferedPacket(u32 a_size):
- data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
- resend_count(0)
+ data(a_size)
{}
Buffer<u8> data; // Data of the packet, including headers
float time = 0.0f; // Seconds from buffering the packet or re-sending
@@ -202,12 +197,13 @@ std::list<SharedBuffer<u8> > makeAutoSplitPacket(
// Add the TYPE_RELIABLE header to the data
SharedBuffer<u8> makeReliablePacket(
- SharedBuffer<u8> data,
+ const SharedBuffer<u8> &data,
u16 seqnum);
struct IncomingSplitPacket
{
- IncomingSplitPacket() {}
+ IncomingSplitPacket() = default;
+
// Key is chunk number, value is data without headers
std::map<u16, SharedBuffer<u8> > chunks;
u32 chunk_count;
@@ -315,7 +311,7 @@ typedef std::list<BufferedPacket>::iterator RPBSearchResult;
class ReliablePacketBuffer
{
public:
- ReliablePacketBuffer() {};
+ ReliablePacketBuffer() = default;
bool getFirstSeqnum(u16& result);
@@ -410,7 +406,7 @@ struct ConnectionCommand
bool reliable = false;
bool raw = false;
- ConnectionCommand() {}
+ ConnectionCommand() = default;
void serve(Address address_)
{
@@ -501,8 +497,8 @@ public:
IncomingSplitBuffer incoming_splits;
- Channel() {};
- ~Channel() {};
+ Channel() = default;
+ ~Channel() = default;
void UpdatePacketLossCounter(unsigned int count);
void UpdatePacketTooLateCounter();
@@ -590,12 +586,8 @@ class PeerHandler
{
public:
- PeerHandler()
- {
- }
- virtual ~PeerHandler()
- {
- }
+ PeerHandler() = default;
+ virtual ~PeerHandler() = default;
/*
This is called after the Peer has been inserted into the
@@ -612,7 +604,7 @@ public:
class PeerHelper
{
public:
- PeerHelper() {};
+ PeerHelper() = default;;
PeerHelper(Peer* peer);
~PeerHelper();
@@ -744,7 +736,7 @@ class Peer {
float max_rtt = 0.0f;
float avg_rtt = -1.0f;
- rttstats() {};
+ rttstats() = default;
};
rttstats m_rtt;
@@ -769,7 +761,7 @@ public:
friend class Connection;
UDPPeer(u16 a_id, Address a_address, Connection* connection);
- virtual ~UDPPeer() {};
+ virtual ~UDPPeer() = default;
void PutReliableSendCommand(ConnectionCommand &c,
unsigned int max_packet_size);
@@ -841,7 +833,7 @@ struct ConnectionEvent
bool timeout = false;
Address address;
- ConnectionEvent() {}
+ ConnectionEvent() = default;
std::string describe()
{