================= idMsgChannel::Process Returns false if the message should not be processed due to being out of order or a fragment. msg must be large enough to hold MAX_MESSAGE_SIZE, because if this is the final fragment of a multi-part message, the entire thing will be copied out. ================= */
| 538 | ================= |
| 539 | */ |
| 540 | bool idMsgChannel::Process( const netadr_t from, int time, idBitMsg &msg, int &sequence ) { |
| 541 | int fragStart, fragLength, dropped; |
| 542 | bool fragmented; |
| 543 | idBitMsg fragMsg; |
| 544 | |
| 545 | // the IP port can't be used to differentiate them, because |
| 546 | // some address translating routers periodically change UDP |
| 547 | // port assignments |
| 548 | if ( remoteAddress.port != from.port ) { |
| 549 | common->Printf( "idMsgChannel::Process: fixing up a translated port\n" ); |
| 550 | remoteAddress.port = from.port; |
| 551 | } |
| 552 | |
| 553 | // update incoming rate |
| 554 | UpdateIncomingRate( time, msg.GetSize() ); |
| 555 | |
| 556 | // get sequence numbers |
| 557 | sequence = msg.ReadInt(); |
| 558 | |
| 559 | // check for fragment information |
| 560 | if ( sequence & FRAGMENT_BIT ) { |
| 561 | sequence &= ~FRAGMENT_BIT; |
| 562 | fragmented = true; |
| 563 | } else { |
| 564 | fragmented = false; |
| 565 | } |
| 566 | |
| 567 | // read the fragment information |
| 568 | if ( fragmented ) { |
| 569 | fragStart = msg.ReadShort(); |
| 570 | fragLength = msg.ReadShort(); |
| 571 | } else { |
| 572 | fragStart = 0; // stop warning message |
| 573 | fragLength = 0; |
| 574 | } |
| 575 | |
| 576 | if ( net_channelShowPackets.GetBool() ) { |
| 577 | if ( fragmented ) { |
| 578 | common->Printf( "%d recv %4i : s = %i fragment = %i,%i\n", id, msg.GetSize(), sequence, fragStart, fragLength ); |
| 579 | } else { |
| 580 | common->Printf( "%d recv %4i : s = %i\n", id, msg.GetSize(), sequence ); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // |
| 585 | // discard out of order or duplicated packets |
| 586 | // |
| 587 | if ( sequence <= incomingSequence ) { |
| 588 | if ( net_channelShowDrop.GetBool() || net_channelShowPackets.GetBool() ) { |
| 589 | common->Printf( "%s: out of order packet %i at %i\n", Sys_NetAdrToString( remoteAddress ), sequence, incomingSequence ); |
| 590 | } |
| 591 | return false; |
| 592 | } |
| 593 | |
| 594 | // |
| 595 | // dropped packets don't keep this message from being used |
| 596 | // |
| 597 | dropped = sequence - (incomingSequence+1); |
no test coverage detected