Exemple #1
0
static int ResendData (struct sockaddr_in *fromAddr, ubyte *buf)
{
	int				i, j, nFirst, nLast, nDrop;
	tDestListEntry	*pdl;
	tPacketProps	*ppp;
	time_t			t;

//if (!extraGameInfo [1].bSafeUDP)
//	return 0;
if (strncmp ((char *) buf, RESEND_ID, RESEND_ID_LEN))
	return 0;
if (destAddrNum <= (i = FindDestInList (fromAddr)))
	return 1;
nFirst = * ((int *) (buf + RESEND_ID_LEN));
nFirst = INTEL_INT (nFirst);
nLast = * ((int *) (buf + RESEND_ID_LEN + 4));
nLast = INTEL_INT (nLast);
pdl = destList + i;
if (!pdl->numPackets)
	return 1;
ppp = pdl->packetProps + pdl->firstPacket;
if (nFirst < (nDrop = ppp->id)) {
	DropData (pdl, nDrop);	//have the receiver 'forget' data not buffered any more
	if (nDrop > nLast)
		return 1;
	nFirst = nDrop;
	}
nDrop = -1;
t = SDL_GetTicks ();
#ifdef _DEBUG
//PrintLog ("resending packets %d - %d to", nFirst, nLast); dumpaddr (&pdl->addr); //PrintLog ("\n");
#endif
for (i = pdl->numPackets, j = pdl->firstPacket; i; i--, j++) {
	j %= MAX_BUF_PACKETS;
	ppp = pdl->packetProps + j;
	if (ppp->id > nLast)
		break;
	if (ppp->id < nFirst)
		continue;
	if (t - ppp->timeStamp > 3000) {
		nDrop = ppp->id;
		continue;
		}
	if (nDrop >= 0) {	//have the receiver 'forget' outdated data
		DropData (pdl, nDrop);
		nDrop = -1;
		}
//	nDrop = * ((int *) (ppp->data + ppp->len - 4));
//	nDrop = INTEL_INT (nDrop);
//PrintLog ("   resending packet %d (%d)\n", ppp - pdl->packetProps, pdl->numPackets);
	sendto (pdl->fd, ppp->data, ppp->len, 0, (struct sockaddr *) &pdl->addr, sizeof (pdl->addr));
	}
return 1;
}
Exemple #2
0
MozNDEFRecord::~MozNDEFRecord()
{
  DropData();
}