void SendAskInfoViaMS(INT32 node, tic_t asktime) { const char *address; UINT16 port; char *inip; ms_holepunch_packet_t mshpp; MSOpenUDPSocket(); // This must be called after calling MSOpenUDPSocket, due to the // static buffer. address = I_GetNodeAddress(node); // Copy the IP address into the buffer. inip = mshpp.ip; while(*address && *address != ':') *inip++ = *address++; *inip = '\0'; // Get the port. port = (UINT16)(*address++ ? atoi(address) : 0); mshpp.port = SHORT(port); // Set the time for ping calculation. mshpp.time = LONG(asktime); // Send to the MS. M_Memcpy(netbuffer, &mshpp, sizeof(mshpp)); doomcom->datalength = sizeof(ms_holepunch_packet_t); doomcom->remotenode = (INT16)msnode; I_NetSend(); }
// // HSendPacket // boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlength) { doomcom->datalength = (INT16)(packetlength + BASEPACKETSIZE); if (node == 0) // packet is to go back to us { if ((rebound_head+1) % MAXREBOUND == rebound_tail) { #ifdef PARANOIA CONS_Debug(DBG_NETPLAY, "No more rebound buf\n"); #endif return false; } M_Memcpy(&reboundstore[rebound_head], netbuffer, doomcom->datalength); reboundsize[rebound_head] = doomcom->datalength; rebound_head = (rebound_head+1) % MAXREBOUND; #ifdef DEBUGFILE if (debugfile) { doomcom->remotenode = (INT16)node; DebugPrintpacket("SENDLOCAL"); } #endif return true; } if (!netgame) I_Error("Tried to transmit to another node"); #ifdef NONET (void)node; (void)reliable; (void)acknum; #else // do this before GetFreeAcknum because this function backup // the current packet doomcom->remotenode = (INT16)node; if (doomcom->datalength <= 0) { DEBFILE("HSendPacket: nothing to send\n"); #ifdef DEBUGFILE if (debugfile) DebugPrintpacket("TRISEND"); #endif return false; } if (node < MAXNETNODES) // can be a broadcast netbuffer->ackreturn = GetAcktosend(node); else netbuffer->ackreturn = 0; if (reliable) { if (I_NetCanSend && !I_NetCanSend()) { if (netbuffer->packettype < PT_CANFAIL) GetFreeAcknum(&netbuffer->ack, true); DEBFILE("HSendPacket: Out of bandwidth\n"); return false; } else if (!GetFreeAcknum(&netbuffer->ack, false)) return false; } else netbuffer->ack = acknum; netbuffer->checksum = NetbufferChecksum(); sendbytes += packetheaderlength + doomcom->datalength; // for stat // simulate internet :) if (true || rand()<(INT32)RAND_MAX/5) { #ifdef DEBUGFILE if (debugfile) DebugPrintpacket("SEND"); #endif I_NetSend(); } #ifdef DEBUGFILE else if (debugfile) DebugPrintpacket("NOTSEND"); #endif #endif // ndef NONET return true; }