MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / SendNextFragment

Method SendNextFragment

neo/framework/async/MsgChannel.cpp:415–462  ·  view source on GitHub ↗

================= idMsgChannel::SendNextFragment Sends one fragment of the current message. ================= */

Source from the content-addressed store, hash-verified

413=================
414*/
415void idMsgChannel::SendNextFragment( idPort &port, const int time ) {
416 idBitMsg msg;
417 byte msgBuf[MAX_PACKETLEN];
418 int fragLength;
419
420 if ( remoteAddress.type == NA_BAD ) {
421 return;
422 }
423
424 if ( !unsentFragments ) {
425 return;
426 }
427
428 // write the packet
429 msg.Init( msgBuf, sizeof( msgBuf ) );
430 msg.WriteShort( id );
431 msg.WriteInt( outgoingSequence | FRAGMENT_BIT );
432
433 fragLength = FRAGMENT_SIZE;
434 if ( unsentFragmentStart + fragLength > unsentMsg.GetSize() ) {
435 fragLength = unsentMsg.GetSize() - unsentFragmentStart;
436 }
437
438 msg.WriteShort( unsentFragmentStart );
439 msg.WriteShort( fragLength );
440 msg.WriteData( unsentMsg.GetData() + unsentFragmentStart, fragLength );
441
442 // send the packet
443 port.SendPacket( remoteAddress, msg.GetData(), msg.GetSize() );
444
445 // update rate control variables
446 UpdateOutgoingRate( time, msg.GetSize() );
447
448 if ( net_channelShowPackets.GetBool() ) {
449 common->Printf( "%d send %4i : s = %i fragment = %i,%i\n", id, msg.GetSize(), outgoingSequence - 1, unsentFragmentStart, fragLength );
450 }
451
452 unsentFragmentStart += fragLength;
453
454 // this exit condition is a little tricky, because a packet
455 // that is exactly the fragment length still needs to send
456 // a second packet of zero length so that the other side
457 // can tell there aren't more to follow
458 if ( unsentFragmentStart == unsentMsg.GetSize() && fragLength != FRAGMENT_SIZE ) {
459 outgoingSequence++;
460 unsentFragments = false;
461 }
462}
463
464/*
465===============

Callers 7

KillMethod · 0.80
SendGameInitToClientMethod · 0.80
RunFrameMethod · 0.80
PacifierUpdateMethod · 0.80
SendEmptyToServerMethod · 0.80
SendUsercmdsToServerMethod · 0.80

Calls 9

InitMethod · 0.45
WriteShortMethod · 0.45
WriteIntMethod · 0.45
GetSizeMethod · 0.45
WriteDataMethod · 0.45
GetDataMethod · 0.45
SendPacketMethod · 0.45
GetBoolMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected