Skip to content

Commit

Permalink
SERVER: Cleared queued packets when changing map
Browse files Browse the repository at this point in the history
See bug QW-Group#488

CL_ClearState() is called directly from the server
  code (QW-Group@da33c16)

Anyway this clears cl.protoversion, but a delayed
  packet could still arrive with the reliable data
  from the very end of the previous map, and also
  svc_playerinfo messages.  As CL_ClearState()
  blanks cl.protocolversion, we then don't know
  the format of svc_playerinfo.

Probably needs looking into more (we can probably
  afford to waste more memory now and keep client/
  server map data distinct?) but this seems to help
  in the meantime.
  • Loading branch information
meag committed Feb 24, 2021
1 parent d8b6125 commit e876f0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ typedef struct cl_delayed_packet_s

qbool CL_QueInputPacket(void);
qbool CL_UnqueOutputPacket(qbool sendall);
void CL_ClearQueuedPackets(void);

// ===================================================================================

Expand Down
5 changes: 3 additions & 2 deletions host.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,10 @@ void Host_EndGame (void)
#ifndef CLIENTONLY
SV_Shutdown ("Server was killed");
#endif
CL_Disconnect ();
CL_Disconnect();
// clear disconnect messages from loopback
NET_ClearLoopback ();
CL_ClearQueuedPackets();
NET_ClearLoopback();
}

//This shuts down both the client and server
Expand Down
7 changes: 7 additions & 0 deletions net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,13 @@ qbool CL_QueInputPacket(void)

return NET_PacketQueueAdd(&delay_queue_get, net_message.data, net_message.cursize, net_from);
}

void CL_ClearQueuedPackets(void)
{
memset(&delay_queue_get, 0, sizeof(delay_queue_get));
memset(&delay_queue_send, 0, sizeof(delay_queue_send));
delay_queue_send.outgoing = true;
}
#endif

#ifndef CLIENTONLY
Expand Down
11 changes: 7 additions & 4 deletions sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef CLIENTONLY
#include "qwsvdef.h"

#ifndef SERVERONLY
void CL_ClearState(void);
void CL_ClearQueuedPackets(void);
#endif

server_static_t svs; // persistent server info
server_t sv; // local server
demo_t demo; // server demo struct
Expand Down Expand Up @@ -214,9 +219,6 @@ void SV_SpawnServer(char *mapname, qbool devmap, char* entityfile, qbool loading
char oldmap[MAP_NAME_LEN];
extern qbool sv_allow_cheats;
extern cvar_t sv_cheats, sv_paused, sv_bigcoords;
#ifndef SERVERONLY
extern void CL_ClearState (void);
#endif

// store old map name
snprintf (oldmap, MAP_NAME_LEN, "%s", sv.mapname);
Expand Down Expand Up @@ -631,7 +633,8 @@ void SV_SpawnServer(char *mapname, qbool devmap, char* entityfile, qbool loading
SV_MVD_Record(NULL, true);

#ifndef SERVERONLY
CL_ClearState ();
CL_ClearState();
CL_ClearQueuedPackets();
#endif
}

Expand Down

0 comments on commit e876f0f

Please sign in to comment.