/* ================== idPort::SendPacket ================== */ void idPort::SendPacket( const netadr_t to, const void *data, int size ) { udpMsg_t *msg; if ( to.type == NA_BAD ) { common->Warning( "idPort::SendPacket: bad address type NA_BAD - ignored" ); return; } packetsWritten++; bytesWritten += size; if ( net_forceDrop.GetInteger() > 0 ) { if ( rand() < net_forceDrop.GetInteger() * RAND_MAX / 100 ) { return; } } if ( net_forceLatency.GetInteger() > 0 || ( udpPorts[ bound_to.port ] && udpPorts[ bound_to.port ]->sendFirst ) ) { assert( size <= MAX_UDP_MSG_SIZE ); msg = udpPorts[ bound_to.port ]->udpMsgAllocator.Alloc(); memcpy( msg->data, data, size ); msg->size = size; msg->address = to; msg->time = Sys_Milliseconds(); msg->next = NULL; if ( udpPorts[ bound_to.port ]->sendLast ) { udpPorts[ bound_to.port ]->sendLast->next = msg; } else { udpPorts[ bound_to.port ]->sendFirst = msg; } udpPorts[ bound_to.port ]->sendLast = msg; for ( msg = udpPorts[ bound_to.port ]->sendFirst; msg && msg->time <= Sys_Milliseconds() - net_forceLatency.GetInteger(); msg = udpPorts[ bound_to.port ]->sendFirst ) { Net_SendUDPPacket( netSocket, msg->size, msg->data, msg->address ); udpPorts[ bound_to.port ]->sendFirst = udpPorts[ bound_to.port ]->sendFirst->next; if ( !udpPorts[ bound_to.port ]->sendFirst ) { udpPorts[ bound_to.port ]->sendLast = NULL; } udpPorts[ bound_to.port ]->udpMsgAllocator.Free( msg ); } } else { Net_SendUDPPacket( netSocket, size, data, to ); } }
/* ======================== idUDP::SendPacket ======================== */ void idUDP::SendPacket( const netadr_t to, const void* data, int size ) { if( to.type == NA_BAD ) { idLib::Warning( "idUDP::SendPacket: bad address type NA_BAD - ignored" ); return; } packetsWritten++; bytesWritten += size; if( silent ) { return; } Net_SendUDPPacket( netSocket, size, data, to ); }