Skip to content

Commit 8daf5b5

Browse files
Dumbeldornerzhul
authored andcommittedJun 21, 2017
C++11 cleanup on constructors dir network (#6021)
* C++11 cleanup on constructors dir network
1 parent af3badf commit 8daf5b5

File tree

4 files changed

+103
-182
lines changed

4 files changed

+103
-182
lines changed
 

Diff for: ‎src/network/connection.cpp

+11-80
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ static inline float CALC_DTIME(u64 lasttime, u64 curtime)
6060
return MYMAX(MYMIN(value,0.1),0.0);
6161
}
6262

63-
/* maximum window size to use, 0xFFFF is theoretical maximum don't think about
64-
* touching it, the less you're away from it the more likely data corruption
65-
* will occur
66-
*/
67-
#define MAX_RELIABLE_WINDOW_SIZE 0x8000
68-
/* starting value for window size */
69-
#define MIN_RELIABLE_WINDOW_SIZE 0x40
70-
7163
#define MAX_UDP_PEERS 65535
7264

7365
#define PING_TIMEOUT 5.0
@@ -209,8 +201,6 @@ SharedBuffer<u8> makeReliablePacket(
209201
ReliablePacketBuffer
210202
*/
211203

212-
ReliablePacketBuffer::ReliablePacketBuffer(): m_list_size(0) {}
213-
214204
void ReliablePacketBuffer::print()
215205
{
216206
MutexAutoLock listlock(m_list_mutex);
@@ -577,36 +567,6 @@ void IncomingSplitBuffer::removeUnreliableTimedOuts(float dtime, float timeout)
577567
Channel
578568
*/
579569

580-
Channel::Channel() :
581-
window_size(MIN_RELIABLE_WINDOW_SIZE),
582-
next_incoming_seqnum(SEQNUM_INITIAL),
583-
next_outgoing_seqnum(SEQNUM_INITIAL),
584-
next_outgoing_split_seqnum(SEQNUM_INITIAL),
585-
current_packet_loss(0),
586-
current_packet_too_late(0),
587-
current_packet_successfull(0),
588-
packet_loss_counter(0),
589-
current_bytes_transfered(0),
590-
current_bytes_received(0),
591-
current_bytes_lost(0),
592-
max_kbps(0.0),
593-
cur_kbps(0.0),
594-
avg_kbps(0.0),
595-
max_incoming_kbps(0.0),
596-
cur_incoming_kbps(0.0),
597-
avg_incoming_kbps(0.0),
598-
max_kbps_lost(0.0),
599-
cur_kbps_lost(0.0),
600-
avg_kbps_lost(0.0),
601-
bpm_counter(0.0),
602-
rate_samples(0)
603-
{
604-
}
605-
606-
Channel::~Channel()
607-
{
608-
}
609-
610570
u16 Channel::readNextIncomingSeqNum()
611571
{
612572
MutexAutoLock internal(m_internal_mutex);
@@ -849,40 +809,26 @@ void Channel::UpdateTimers(float dtime,bool legacy_peer)
849809
Peer
850810
*/
851811

852-
PeerHelper::PeerHelper() :
853-
m_peer(0)
854-
{}
855-
856812
PeerHelper::PeerHelper(Peer* peer) :
857813
m_peer(peer)
858814
{
859-
if (peer != NULL)
860-
{
861-
if (!peer->IncUseCount())
862-
{
863-
m_peer = 0;
864-
}
865-
}
815+
if (peer && !peer->IncUseCount())
816+
m_peer = nullptr;
866817
}
867818

868819
PeerHelper::~PeerHelper()
869820
{
870-
if (m_peer != 0)
821+
if (m_peer)
871822
m_peer->DecUseCount();
872823

873-
m_peer = 0;
824+
m_peer = nullptr;
874825
}
875826

876827
PeerHelper& PeerHelper::operator=(Peer* peer)
877828
{
878829
m_peer = peer;
879-
if (peer != NULL)
880-
{
881-
if (!peer->IncUseCount())
882-
{
883-
m_peer = 0;
884-
}
885-
}
830+
if (peer && !peer->IncUseCount())
831+
m_peer = nullptr;
886832
return *this;
887833
}
888834

@@ -909,8 +855,7 @@ bool Peer::IncUseCount()
909855
{
910856
MutexAutoLock lock(m_exclusive_access_mutex);
911857

912-
if (!m_pending_deletion)
913-
{
858+
if (!m_pending_deletion) {
914859
this->m_usage++;
915860
return true;
916861
}
@@ -1014,10 +959,7 @@ void Peer::Drop()
1014959
}
1015960

1016961
UDPPeer::UDPPeer(u16 a_id, Address a_address, Connection* connection) :
1017-
Peer(a_address,a_id,connection),
1018-
m_pending_disconnect(false),
1019-
resend_timeout(0.5),
1020-
m_legacy_peer(true)
962+
Peer(a_address,a_id,connection)
1021963
{
1022964
}
1023965

@@ -1261,12 +1203,9 @@ SharedBuffer<u8> UDPPeer::addSpiltPacket(u8 channel,
12611203
ConnectionSendThread::ConnectionSendThread(unsigned int max_packet_size,
12621204
float timeout) :
12631205
Thread("ConnectionSend"),
1264-
m_connection(NULL),
12651206
m_max_packet_size(max_packet_size),
12661207
m_timeout(timeout),
1267-
m_max_commands_per_iteration(1),
1268-
m_max_data_packets_per_iteration(g_settings->getU16("max_packets_per_iteration")),
1269-
m_max_packets_requeued(256)
1208+
m_max_data_packets_per_iteration(g_settings->getU16("max_packets_per_iteration"))
12701209
{
12711210
}
12721211

@@ -2031,8 +1970,7 @@ void ConnectionSendThread::sendAsPacket(u16 peer_id, u8 channelnum,
20311970
}
20321971

20331972
ConnectionReceiveThread::ConnectionReceiveThread(unsigned int max_packet_size) :
2034-
Thread("ConnectionReceive"),
2035-
m_connection(NULL)
1973+
Thread("ConnectionReceive")
20361974
{
20371975
}
20381976

@@ -2676,17 +2614,10 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
26762614
Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
26772615
bool ipv6, PeerHandler *peerhandler) :
26782616
m_udpSocket(ipv6),
2679-
m_command_queue(),
2680-
m_event_queue(),
2681-
m_peer_id(0),
26822617
m_protocol_id(protocol_id),
26832618
m_sendThread(max_packet_size, timeout),
26842619
m_receiveThread(max_packet_size),
2685-
m_info_mutex(),
2686-
m_bc_peerhandler(peerhandler),
2687-
m_bc_receive_timeout(0),
2688-
m_shutting_down(false),
2689-
m_next_remote_peer_id(2)
2620+
m_bc_peerhandler(peerhandler)
26902621

26912622
{
26922623
m_udpSocket.setTimeoutMs(5);

0 commit comments

Comments
 (0)
Please sign in to comment.