|
|
@ -1461,16 +1461,21 @@ inpkg_delplayer (int pl_nr) {
|
|
|
|
void
|
|
|
|
void
|
|
|
|
send_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
send_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* if the packet would be send to the ai player so ignore it */
|
|
|
|
/* check if the packet would be send to
|
|
|
|
if (PS_IS_aiplayer (players[addr->pl_nr].state))
|
|
|
|
* an AI_Player, so ignore it. */
|
|
|
|
|
|
|
|
if ((addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS) && PS_IS_aiplayer (players[addr->pl_nr].state))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* set the id for the packet and the network flags
|
|
|
|
|
|
|
|
* the id is needed for the inpkg index to check for
|
|
|
|
|
|
|
|
* double reached packets */
|
|
|
|
packet->h.id = HTON16 (pkg_lastid++);
|
|
|
|
packet->h.id = HTON16 (pkg_lastid++);
|
|
|
|
if (bman.net_ai_family != PF_INET)
|
|
|
|
if (bman.net_ai_family != PF_INET)
|
|
|
|
packet->h.flags = packet->h.flags | PKGF_ipv6;
|
|
|
|
packet->h.flags = packet->h.flags | PKGF_ipv6;
|
|
|
|
udp_send (bman.sock, (char *) packet, NTOH16 (packet->h.len), &addr->sAddr, bman.net_ai_family);
|
|
|
|
udp_send (bman.sock, (char *) packet, NTOH16 (packet->h.len), &addr->sAddr, bman.net_ai_family);
|
|
|
|
|
|
|
|
|
|
|
|
/* test if we have any important packet if so put it in the resend_cache */
|
|
|
|
/* if PKGF_ackreq is set add the packet to the resendcache
|
|
|
|
|
|
|
|
* so we can resend it if no PKF_ackreq returned for the packet. */
|
|
|
|
if (packet->h.flags & PKGF_ackreq) {
|
|
|
|
if (packet->h.flags & PKGF_ackreq) {
|
|
|
|
if (rscache_add (addr, packet) == -1)
|
|
|
|
if (rscache_add (addr, packet) == -1)
|
|
|
|
d_printf ("resend_cache overrun.... packet throw away.\n");
|
|
|
|
d_printf ("resend_cache overrun.... packet throw away.\n");
|
|
|
@ -1521,18 +1526,26 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
players[addr->pl_nr].net.pingreq = players[addr->pl_nr].net.pingack + 5;
|
|
|
|
players[addr->pl_nr].net.pingreq = players[addr->pl_nr].net.pingack + 5;
|
|
|
|
|
|
|
|
|
|
|
|
/* test if we have any important packet */
|
|
|
|
/* test if we have any important packet */
|
|
|
|
if (packet->h.flags & PKGF_ackreq)
|
|
|
|
if (packet->h.flags & PKGF_ackreq) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* we need to send an acknolege so the client
|
|
|
|
|
|
|
|
* knows we have got this packet and delete
|
|
|
|
|
|
|
|
* it from the resend cache. */
|
|
|
|
send_pkgack (addr, packet->h.typ, NTOH16 (packet->h.id));
|
|
|
|
send_pkgack (addr, packet->h.typ, NTOH16 (packet->h.id));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check the packet with the index so we can
|
|
|
|
|
|
|
|
* ignore packets we already have got
|
|
|
|
|
|
|
|
* this is important to keep away from
|
|
|
|
|
|
|
|
* the bomb is dropped twice bug. */
|
|
|
|
|
|
|
|
if (inpkg_check (packet->h.typ, NTOH16 (packet->h.id), addr) != -1) {
|
|
|
|
|
|
|
|
/* we have got this packet already */
|
|
|
|
|
|
|
|
d_printf ("do_pkg: double packet ignoring addr->pl_nr=%d\n", addr->pl_nr);
|
|
|
|
|
|
|
|
if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS)
|
|
|
|
|
|
|
|
players[addr->pl_nr].net.pkgopt.to_2sec++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* check the packet with the index */
|
|
|
|
|
|
|
|
if (inpkg_check (packet->h.typ, NTOH16 (packet->h.id), addr) != -1) {
|
|
|
|
|
|
|
|
/* we have got this packet already */
|
|
|
|
|
|
|
|
d_printf ("do_pkg: double packet ignoring addr->pl_nr=%d\n", addr->pl_nr);
|
|
|
|
|
|
|
|
if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS)
|
|
|
|
|
|
|
|
players[addr->pl_nr].net.pkgopt.to_2sec++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* forward packet */
|
|
|
|
/* forward packet */
|
|
|
|
if (GT_MP_PTPM)
|
|
|
|
if (GT_MP_PTPM)
|
|
|
|
fwd_pkg (packet, addr);
|
|
|
|
fwd_pkg (packet, addr);
|
|
|
|