|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: pkgcache.c,v 1.11 2006/08/15 13:33:32 stpohle Exp $
|
|
|
|
/* $Id: pkgcache.c,v 1.12 2006/08/15 15:00:32 stpohle Exp $
|
|
|
|
* Resendcache work, We need this to resend lost packets over the network.
|
|
|
|
* Resendcache work, We need this to resend lost packets over the network.
|
|
|
|
* we will keep every packet with the PKGF_ackreq flag as long as we haven't
|
|
|
|
* we will keep every packet with the PKGF_ackreq flag as long as we haven't
|
|
|
|
* got any answer from the destination host. And resend the packet after a givin
|
|
|
|
* got any answer from the destination host. And resend the packet after a givin
|
|
|
@ -38,25 +38,38 @@ void rscache_add (_net_addr *addr, struct pkg *packet) {
|
|
|
|
rscache.count ++;
|
|
|
|
rscache.count ++;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* delete the entry */
|
|
|
|
|
|
|
|
void rscache_delnr (int nr) {
|
|
|
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (nr >= 0 && nr < PKG_RESENDCACHE_SIZE) {
|
|
|
|
|
|
|
|
for (a = nr; a < rscache.count - 1; a++)
|
|
|
|
|
|
|
|
rscache.entry[nr] = rscache.entry[nr+1];
|
|
|
|
|
|
|
|
rscache.count--;
|
|
|
|
|
|
|
|
d_printf ("rscache_delnr: element %d deleted.\n", nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
d_printf ("rscache_delnr: number is out of range (%d)\n", nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* delete the packet from the cache */
|
|
|
|
|
|
|
|
void rscache_del (_net_addr *addr, unsigned char typ, short unsigned int id) {
|
|
|
|
/* find and delete the givin packet.
|
|
|
|
|
|
|
|
* Return Value: 0 = nothing deleted, 1 one entry deleted */
|
|
|
|
|
|
|
|
int rscache_del (_net_addr *addr, unsigned char typ, short unsigned int id) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("rscache_del: addr %p\n", addr);
|
|
|
|
d_printf ("rscache_del: addr %p (pl_nr:%d, typ:%d, id:%d\n", addr, addr->pl_nr, typ, id);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; (i < rscache.count) && (i < PKG_RESENDCACHE_SIZE); i++) {
|
|
|
|
for (i = 0; (i < rscache.count) && (i < PKG_RESENDCACHE_SIZE); i++) {
|
|
|
|
if (rscache.entry[i].addr.pl_nr == addr->pl_nr &&
|
|
|
|
if (rscache.entry[i].addr.pl_nr == addr->pl_nr &&
|
|
|
|
NTOH16(rscache.entry[i].packet.h.id) == id &&
|
|
|
|
NTOH16(rscache.entry[i].packet.h.id) == id &&
|
|
|
|
((struct pkg)rscache.entry[i].packet).h.typ == typ) { // found element
|
|
|
|
rscache.entry[i].packet.h.typ == typ) { // found element
|
|
|
|
int a;
|
|
|
|
rscache_delnr (i);
|
|
|
|
|
|
|
|
d_printf ("rscache_del: element %d deleted.\n", i);
|
|
|
|
for (a = i; a < rscache.count - 1; a++)
|
|
|
|
return 1;
|
|
|
|
rscache.entry[i] = rscache.entry[i+1];
|
|
|
|
|
|
|
|
rscache.count--;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* test for old packets where we haven't got a ackreq packet for.
|
|
|
|
/* test for old packets where we haven't got a ackreq packet for.
|
|
|
@ -93,8 +106,7 @@ void rscache_loop () {
|
|
|
|
if (rscache.entry[i].addr.pl_nr >= 0 && rscache.entry[i].addr.pl_nr < MAX_PLAYERS)
|
|
|
|
if (rscache.entry[i].addr.pl_nr >= 0 && rscache.entry[i].addr.pl_nr < MAX_PLAYERS)
|
|
|
|
players[rscache.entry[i].addr.pl_nr].net.pkgopt.to_2sec++;
|
|
|
|
players[rscache.entry[i].addr.pl_nr].net.pkgopt.to_2sec++;
|
|
|
|
|
|
|
|
|
|
|
|
rscache_del (&rscache.entry[i].addr, rscache.entry[i].packet.h.typ,
|
|
|
|
rscache_delnr (i);
|
|
|
|
NTOH16(rscache.entry[i].packet.h.id));
|
|
|
|
|
|
|
|
if (i > 0) i--;
|
|
|
|
if (i > 0) i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|