@@ -125,7 +125,7 @@ std::list<SharedBuffer<u8> > makeSplitPacket(
125
125
{
126
126
// Chunk packets, containing the TYPE_SPLIT header
127
127
std::list<SharedBuffer<u8> > chunks;
128
-
128
+
129
129
u32 chunk_header_size = 7 ;
130
130
u32 maximum_data_size = chunksize_max - chunk_header_size;
131
131
u32 start = 0 ;
@@ -136,12 +136,12 @@ std::list<SharedBuffer<u8> > makeSplitPacket(
136
136
end = start + maximum_data_size - 1 ;
137
137
if (end > data.getSize () - 1 )
138
138
end = data.getSize () - 1 ;
139
-
139
+
140
140
u32 payload_size = end - start + 1 ;
141
141
u32 packet_size = chunk_header_size + payload_size;
142
142
143
143
SharedBuffer<u8> chunk (packet_size);
144
-
144
+
145
145
writeU8 (&chunk[0 ], TYPE_SPLIT);
146
146
writeU16 (&chunk[1 ], seqnum);
147
147
// [3] u16 chunk_count is written at next stage
@@ -150,7 +150,7 @@ std::list<SharedBuffer<u8> > makeSplitPacket(
150
150
151
151
chunks.push_back (chunk);
152
152
chunk_count++;
153
-
153
+
154
154
start = end + 1 ;
155
155
chunk_num++;
156
156
}
@@ -465,9 +465,9 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
465
465
sp->reliable = reliable;
466
466
m_buf[seqnum] = sp;
467
467
}
468
-
468
+
469
469
IncomingSplitPacket *sp = m_buf[seqnum];
470
-
470
+
471
471
// TODO: These errors should be thrown or something? Dunno.
472
472
if (chunk_count != sp->chunk_count )
473
473
LOG (derr_con<<" Connection: WARNING: chunk_count=" <<chunk_count
@@ -483,15 +483,15 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
483
483
// lag and the server re-sends stuff.
484
484
if (sp->chunks .find (chunk_num) != sp->chunks .end ())
485
485
return SharedBuffer<u8>();
486
-
486
+
487
487
// Cut chunk data out of packet
488
488
u32 chunkdatasize = p.data .getSize () - headersize;
489
489
SharedBuffer<u8> chunkdata (chunkdatasize);
490
490
memcpy (*chunkdata, &(p.data [headersize]), chunkdatasize);
491
-
491
+
492
492
// Set chunk data in buffer
493
493
sp->chunks [chunk_num] = chunkdata;
494
-
494
+
495
495
// If not all chunks are received, return empty buffer
496
496
if (sp->allReceived () == false )
497
497
return SharedBuffer<u8>();
@@ -503,7 +503,7 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
503
503
{
504
504
totalsize += i->second .getSize ();
505
505
}
506
-
506
+
507
507
SharedBuffer<u8> fulldata (totalsize);
508
508
509
509
// Copy chunks to data buffer
@@ -561,6 +561,7 @@ Channel::Channel() :
561
561
next_outgoing_split_seqnum (SEQNUM_INITIAL),
562
562
current_packet_loss (0 ),
563
563
current_packet_too_late (0 ),
564
+ current_packet_successfull (0 ),
564
565
packet_loss_counter (0 ),
565
566
current_bytes_transfered (0 ),
566
567
current_bytes_received (0 ),
@@ -2096,7 +2097,7 @@ void ConnectionReceiveThread::receive()
2096
2097
// infrastructure
2097
2098
unsigned int packet_maxsize = 1500 ;
2098
2099
SharedBuffer<u8> packetdata (packet_maxsize);
2099
-
2100
+
2100
2101
bool packet_queued = true ;
2101
2102
2102
2103
unsigned int loop_count = 0 ;
@@ -2146,13 +2147,13 @@ void ConnectionReceiveThread::receive()
2146
2147
2147
2148
u16 peer_id = readPeerId (*packetdata);
2148
2149
u8 channelnum = readChannel (*packetdata);
2149
-
2150
+
2150
2151
if (channelnum > CHANNEL_COUNT-1 ){
2151
2152
LOG (derr_con<<m_connection->getDesc ()
2152
2153
<<" Receive(): Invalid channel " <<channelnum<<std::endl);
2153
2154
throw InvalidIncomingDataException (" Channel doesn't exist" );
2154
2155
}
2155
-
2156
+
2156
2157
/* preserve original peer_id for later usage */
2157
2158
u16 packet_peer_id = peer_id;
2158
2159
@@ -2202,7 +2203,7 @@ void ConnectionReceiveThread::receive()
2202
2203
}
2203
2204
}
2204
2205
2205
-
2206
+
2206
2207
/* mark peer as seen with id */
2207
2208
if (!(packet_peer_id == PEER_ID_INEXISTENT))
2208
2209
peer->setSentWithID ();
@@ -2215,7 +2216,7 @@ void ConnectionReceiveThread::receive()
2215
2216
{
2216
2217
channel = &(dynamic_cast <UDPPeer*>(&peer)->channels [channelnum]);
2217
2218
}
2218
-
2219
+
2219
2220
if (channel != 0 ) {
2220
2221
channel->UpdateBytesReceived (received_size);
2221
2222
}
@@ -2226,17 +2227,17 @@ void ConnectionReceiveThread::receive()
2226
2227
SharedBuffer<u8> strippeddata (received_size - BASE_HEADER_SIZE);
2227
2228
memcpy (*strippeddata, &packetdata[BASE_HEADER_SIZE],
2228
2229
strippeddata.getSize ());
2229
-
2230
+
2230
2231
try {
2231
2232
// Process it (the result is some data with no headers made by us)
2232
2233
SharedBuffer<u8> resultdata = processPacket
2233
2234
(channel, strippeddata, peer_id, channelnum, false );
2234
-
2235
+
2235
2236
LOG (dout_con<<m_connection->getDesc ()
2236
2237
<<" ProcessPacket from peer_id: " << peer_id
2237
2238
<< " ,channel: " << (channelnum & 0xFF ) << " , returned "
2238
2239
<< resultdata.getSize () << " bytes" <<std::endl);
2239
-
2240
+
2240
2241
ConnectionEvent e;
2241
2242
e.dataReceived (peer_id, resultdata);
2242
2243
m_connection->putEvent (e);
@@ -2854,11 +2855,11 @@ bool Connection::Connected()
2854
2855
2855
2856
if (m_peers.size () != 1 )
2856
2857
return false ;
2857
-
2858
+
2858
2859
std::map<u16, Peer*>::iterator node = m_peers.find (PEER_ID_SERVER);
2859
2860
if (node == m_peers.end ())
2860
2861
return false ;
2861
-
2862
+
2862
2863
if (m_peer_id == PEER_ID_INEXISTENT)
2863
2864
return false ;
2864
2865
@@ -3114,4 +3115,3 @@ std::list<u16> Connection::getPeerIDs()
3114
3115
}
3115
3116
3116
3117
} // namespace
3117
-
0 commit comments