|
|
@ -11,8 +11,8 @@ extern _point debug_field;
|
|
|
|
extern int debug_lastping;
|
|
|
|
extern int debug_lastping;
|
|
|
|
|
|
|
|
|
|
|
|
static short int pkg_lastid; /* the packet id, this will only counted
|
|
|
|
static short int pkg_lastid; /* the packet id, this will only counted
|
|
|
|
up nothing more.. if we are at 0x10000
|
|
|
|
* up nothing more.. if we are at 0x10000
|
|
|
|
we will start at 0 */
|
|
|
|
* we will start at 0 */
|
|
|
|
|
|
|
|
|
|
|
|
struct _resend_cache resend_cache;
|
|
|
|
struct _resend_cache resend_cache;
|
|
|
|
struct _inpkg_index inpkg_index[PKG_IN_INDEX_NUM];
|
|
|
|
struct _inpkg_index inpkg_index[PKG_IN_INDEX_NUM];
|
|
|
@ -1379,11 +1379,17 @@ inpkg_check (unsigned char typ, short int id, _net_addr * addr)
|
|
|
|
int i,
|
|
|
|
int i,
|
|
|
|
pos;
|
|
|
|
pos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check if the player is still connected */
|
|
|
|
|
|
|
|
if (!PS_IS_used (players[addr->pl_nr].state))
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
/* find packet */
|
|
|
|
/* find packet */
|
|
|
|
for (i = 0, pos = -1; (i < PKG_IN_INDEX_NUM && pos == -1); i++)
|
|
|
|
for (i = 0, pos = -1; (i < PKG_IN_INDEX_NUM && pos == -1); i++)
|
|
|
|
if (inpkg_index[i].pl_nr == addr->pl_nr &&
|
|
|
|
if (inpkg_index[i].pl_nr == addr->pl_nr
|
|
|
|
inpkg_index[i].typ == typ && inpkg_index[i].id == id)
|
|
|
|
&& inpkg_index[i].typ == typ
|
|
|
|
|
|
|
|
&& inpkg_index[i].id == id)
|
|
|
|
pos = i;
|
|
|
|
pos = i;
|
|
|
|
|
|
|
|
|
|
|
|
if (pos == -1) {
|
|
|
|
if (pos == -1) {
|
|
|
|
/* add to index */
|
|
|
|
/* add to index */
|
|
|
|
if (++inpkg_index_pos >= PKG_IN_INDEX_NUM)
|
|
|
|
if (++inpkg_index_pos >= PKG_IN_INDEX_NUM)
|
|
|
@ -1397,6 +1403,16 @@ inpkg_check (unsigned char typ, short int id, _net_addr * addr)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* delete all old pkg indexes about a player */
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
inpkg_delplayer (int pl_nr) {
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PKG_IN_INDEX_NUM; i++)
|
|
|
|
|
|
|
|
if (inpkg_index[i].pl_nr == pl_nr) inpkg_index[i].pl_nr = -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* sends the packet and if PKGF_ackreq is set add packet to the resendcache */
|
|
|
|
/* sends the packet and if PKGF_ackreq is set add packet to the resendcache */
|
|
|
|
void
|
|
|
|
void
|
|
|
|
send_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
send_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
@ -1427,15 +1443,11 @@ fwd_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
if (GT_MP_PTPS) /* clients don't forward anything */
|
|
|
|
if (GT_MP_PTPS) /* clients don't forward anything */
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (packet->h.typ == PKG_field || packet->h.typ == PKG_playerdata
|
|
|
|
if (packet->h.typ <= PKG_quit)
|
|
|
|
|| packet->h.typ == PKG_playermove || packet->h.typ == PKG_ill
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
|| packet->h.typ == PKG_bombdata || packet->h.typ == PKG_chat
|
|
|
|
|
|
|
|
|| packet->h.typ == PKG_special)
|
|
|
|
|
|
|
|
for (pl = 1; pl < MAX_PLAYERS; pl++)
|
|
|
|
|
|
|
|
if ((!PS_IS_aiplayer (players[pl].state)) && PS_IS_netplayer (players[pl].state)
|
|
|
|
if ((!PS_IS_aiplayer (players[pl].state)) && PS_IS_netplayer (players[pl].state)
|
|
|
|
&& ((players[pl].net.flags & NETF_firewall) == NETF_firewall
|
|
|
|
&& (players[addr->pl_nr].net.flags & NETF_firewall) == NETF_firewall
|
|
|
|
|| (players[addr->pl_nr].net.flags & NETF_firewall) ==
|
|
|
|
&& pl != addr->pl_nr)
|
|
|
|
NETF_firewall) && pl != addr->pl_nr)
|
|
|
|
|
|
|
|
send_pkg (packet, &players[pl].net.addr);
|
|
|
|
send_pkg (packet, &players[pl].net.addr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -1452,8 +1464,10 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
d_printf ("do_pkg: packet comes from the wrong network type\n");
|
|
|
|
d_printf ("do_pkg: packet comes from the wrong network type\n");
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* get the addr and set the ping timeout value */
|
|
|
|
/* get the addr and set the ping timeout value */
|
|
|
|
addr->pl_nr = get_player_nr (addr->host, addr->port);
|
|
|
|
addr->pl_nr = get_player_nr (addr->host, addr->port);
|
|
|
|
|
|
|
|
if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS) {
|
|
|
|
players[addr->pl_nr].net.timestamp = timestamp;
|
|
|
|
players[addr->pl_nr].net.timestamp = timestamp;
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
@ -1464,19 +1478,16 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
/* check the packet with the index */
|
|
|
|
/* check the packet with the index */
|
|
|
|
if (inpkg_check (packet->h.typ, NTOH16 (packet->h.id), addr) != -1) {
|
|
|
|
if (inpkg_check (packet->h.typ, NTOH16 (packet->h.id), addr) != -1) {
|
|
|
|
/* we have got this packet already */
|
|
|
|
/* we have got this packet already */
|
|
|
|
d_printf ("do_pkg: double packet ignoring\n");
|
|
|
|
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)
|
|
|
|
if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS)
|
|
|
|
players[addr->pl_nr].net.pkgopt.to_2sec++;
|
|
|
|
players[addr->pl_nr].net.pkgopt.to_2sec++;
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* check if the incoming packet have the right size */
|
|
|
|
|
|
|
|
if (packet->h.typ == PKG_servermode && NTOH16 (packet->h.len) != sizeof (struct pkg_servermode))
|
|
|
|
|
|
|
|
send_error (addr, "pkg_servermode: packetsize incorrect.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* forward packet */
|
|
|
|
/* forward packet */
|
|
|
|
if (GT_MP_PTPM)
|
|
|
|
if (GT_MP_PTPM)
|
|
|
|
fwd_pkg (packet, addr);
|
|
|
|
fwd_pkg (packet, addr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (packet->h.typ) {
|
|
|
|
switch (packet->h.typ) {
|
|
|
|
case (PKG_error):
|
|
|
|
case (PKG_error):
|
|
|
|