fixed improper player disconnecting which might have been caused by endlevel packet

This commit is contained in:
zicodxx 2012-04-23 16:15:20 +02:00
parent d30fb514b1
commit 20e8b6c497
4 changed files with 22 additions and 19 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog D1X-Rebirth Changelog
20120423
--------
main/multi.c, main/multi.h, main/net_udp.c: fixed improper player disconnecting which might have been caused by endlevel packet
20120418 20120418
-------- --------
main/gameseq.c, main/gameseq.h, main/gauges.c, main/multi.c, main/net_udp.c, main/state.c: Removed usage of 'oldmaxnet' variable when switching between coop and other game modes which would not be correctly set when coop mode is loaded from a netgame profile; Removed 'MaxNumNetPlayers' variable as already replaced by Netgame.max_numplayers main/gameseq.c, main/gameseq.h, main/gauges.c, main/multi.c, main/net_udp.c, main/state.c: Removed usage of 'oldmaxnet' variable when switching between coop and other game modes which would not be correctly set when coop mode is loaded from a netgame profile; Removed 'MaxNumNetPlayers' variable as already replaced by Netgame.max_numplayers

View file

@ -1791,6 +1791,8 @@ void multi_disconnect_player(int pnum)
if (!(Game_mode & GM_NETWORK)) if (!(Game_mode & GM_NETWORK))
return; return;
if (Players[pnum].connected == CONNECT_DISCONNECTED)
return;
if (Players[pnum].connected == CONNECT_PLAYING) if (Players[pnum].connected == CONNECT_PLAYING)
{ {

View file

@ -72,7 +72,7 @@ extern int multi_protocol; // set and determinate used protocol
// 3 Descent II Shareware // 3 Descent II Shareware
// 4 Descent II Commercial // 4 Descent II Commercial
// > 4 DXX-Rebirth // > 4 DXX-Rebirth
#define MULTI_PROTO_VERSION 11 #define MULTI_PROTO_VERSION 12
// PROTOCOL VARIABLES AND DEFINES - END // PROTOCOL VARIABLES AND DEFINES - END

View file

@ -2595,8 +2595,10 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
len += 2; len += 2;
Players[pnum].connected = data[len]; len++; if ((int)data[len] == CONNECT_DISCONNECTED)
tmpvar = data[len]; len++; multi_disconnect_player(pnum);
Players[pnum].connected = data[len]; len++;
tmpvar = data[len]; len++;
if ((Network_status != NETSTAT_PLAYING) && (Players[pnum].connected == CONNECT_PLAYING) && (tmpvar < Countdown_seconds_left)) if ((Network_status != NETSTAT_PLAYING) && (Players[pnum].connected == CONNECT_PLAYING) && (tmpvar < Countdown_seconds_left))
Countdown_seconds_left = tmpvar; Countdown_seconds_left = tmpvar;
Players[pnum].net_kills_total = GET_INTEL_SHORT(&(data[len])); len += 2; Players[pnum].net_kills_total = GET_INTEL_SHORT(&(data[len])); len += 2;
@ -2604,10 +2606,10 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
{ {
kill_matrix[pnum][i] = GET_INTEL_SHORT(&(data[len])); len += 2; kill_matrix[pnum][i] = GET_INTEL_SHORT(&(data[len])); len += 2;
} }
if (Players[i].connected)
Netgame.players[pnum].LastPacketTime = timer_query(); Netgame.players[pnum].LastPacketTime = timer_query();
} }
else else
{ {
@ -2616,7 +2618,7 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
len++; len++;
tmpvar = data[len]; len++; tmpvar = data[len]; len++;
if ((Network_status != NETSTAT_PLAYING) && (tmpvar < Countdown_seconds_left)) if ((Network_status != NETSTAT_PLAYING) && (tmpvar < Countdown_seconds_left))
Countdown_seconds_left = tmpvar; Countdown_seconds_left = tmpvar;
@ -2627,9 +2629,11 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
len += 5; len += 5;
continue; continue;
} }
Players[i].connected = data[len]; len++; if ((int)data[len] == CONNECT_DISCONNECTED)
Players[i].net_kills_total = GET_INTEL_SHORT(&(data[len])); len += 2; multi_disconnect_player(i);
Players[i].connected = data[len]; len++;
Players[i].net_kills_total = GET_INTEL_SHORT(&(data[len])); len += 2;
Players[i].net_killed_total = GET_INTEL_SHORT(&(data[len])); len += 2; Players[i].net_killed_total = GET_INTEL_SHORT(&(data[len])); len += 2;
if (Players[i].connected) if (Players[i].connected)
@ -2644,7 +2648,7 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
{ {
kill_matrix[i][j] = GET_INTEL_SHORT(&(data[len])); kill_matrix[i][j] = GET_INTEL_SHORT(&(data[len]));
} }
len += 2; len += 2;
} }
} }
} }
@ -3875,7 +3879,6 @@ void net_udp_leave_game()
} }
Players[Player_num].connected = CONNECT_DISCONNECTED; Players[Player_num].connected = CONNECT_DISCONNECTED;
net_udp_send_endlevel_packet();
change_playernum_to(0); change_playernum_to(0);
net_udp_flush(); net_udp_flush();
net_udp_close(); net_udp_close();
@ -4602,14 +4605,8 @@ void net_udp_read_pdata_short_packet(UDP_frame_info *pd)
} }
else else
{ {
// only by reading pdata a client can know if a player re/disconnected. So do that here. // only by reading pdata a client can know if a player reconnected. So do that here.
// NOTE: we might do this somewhere else - maybe with a sync packet like when adding a fresh player. // NOTE: we might do this somewhere else - maybe with a sync packet like when adding a fresh player.
if ( Players[TheirPlayernum].connected != CONNECT_DISCONNECTED && pd->connected == CONNECT_DISCONNECTED )
{
Netgame.players[TheirPlayernum].LastPacketTime = timer_query() - UDP_TIMEOUT;
multi_disconnect_player(TheirPlayernum);
return;
}
if ( Players[TheirPlayernum].connected == CONNECT_DISCONNECTED && pd->connected == CONNECT_PLAYING ) if ( Players[TheirPlayernum].connected == CONNECT_DISCONNECTED && pd->connected == CONNECT_PLAYING )
{ {
Players[TheirPlayernum].connected = CONNECT_PLAYING; Players[TheirPlayernum].connected = CONNECT_PLAYING;