From 3ad7fd58a384148f78dfd1a541e81a69e90dab8f Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 13 Jun 2007 06:59:45 +0000 Subject: [PATCH] brought back the client->sendsignon flag from original quake code, this fixes the occasional error message on old clients when a level change occurs and chat messages or scoreboard updates or other reliable messages are delivered to the client when it is not expecting them (during model/sound loading when it is supposed to just be exchanging keepalive messages) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7408 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_input.c | 2 +- cl_main.c | 6 +++--- cl_parse.c | 4 ++-- host.c | 6 +++--- host_cmd.c | 2 ++ netconn.c | 6 +++--- netconn.h | 2 +- server.h | 2 ++ sv_main.c | 7 +++++-- 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/cl_input.c b/cl_input.c index 88fb3132..a7254701 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1569,7 +1569,7 @@ void CL_SendMove(void) // send the reliable message (forwarded commands) if there is one if (buf.cursize || cls.netcon->message.cursize) - NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, max(20*(buf.cursize+40), cl_rate.integer)); + NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, max(20*(buf.cursize+40), cl_rate.integer), false); if (cls.netcon->message.overflowed) { diff --git a/cl_main.c b/cl_main.c index 3b6061bc..ad928ca7 100644 --- a/cl_main.c +++ b/cl_main.c @@ -346,9 +346,9 @@ void CL_Disconnect(void) Con_DPrint("Sending clc_disconnect\n"); MSG_WriteByte(&buf, clc_disconnect); } - NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000); - NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000); - NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000); + NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, false); + NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, false); + NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, false); NetConn_Close(cls.netcon); cls.netcon = NULL; } diff --git a/cl_parse.c b/cl_parse.c index 1a85027f..5f41466e 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -287,7 +287,7 @@ void CL_KeepaliveMessage (qboolean readmessages) sizebuf_t old; // no need if server is local and definitely not if this is a demo - if (sv.active || !cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD) + if (!cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD) return; if (readmessages) @@ -318,7 +318,7 @@ void CL_KeepaliveMessage (qboolean readmessages) msg.data = buf; msg.maxsize = sizeof(buf); MSG_WriteChar(&msg, clc_nop); - NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol, 10000); + NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol, 10000, false); } } diff --git a/host.c b/host.c index 812a2cb6..0a4df3d0 100644 --- a/host.c +++ b/host.c @@ -386,9 +386,9 @@ void SV_DropClient(qboolean crash) buf.data = bufdata; buf.maxsize = sizeof(bufdata); MSG_WriteByte(&buf, svc_disconnect); - NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000); - NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000); - NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000); + NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, false); + NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, false); + NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, false); } // break the net connection NetConn_Close(host_client->netconnection); diff --git a/host_cmd.c b/host_cmd.c index bcdd0cf3..f37626bd 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1364,6 +1364,7 @@ void Host_PreSpawn_f (void) SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize); MSG_WriteByte (&host_client->netconnection->message, svc_signonnum); MSG_WriteByte (&host_client->netconnection->message, 2); + host_client->sendsignon = true; // send this message, this will be cleared later } // reset the name change timer because the client will send name soon @@ -1507,6 +1508,7 @@ void Host_Spawn_f (void) MSG_WriteByte (&host_client->netconnection->message, svc_signonnum); MSG_WriteByte (&host_client->netconnection->message, 3); + host_client->sendsignon = true; // send this message, this will be cleared later } /* diff --git a/netconn.c b/netconn.c index fdf72bbe..9e62d93c 100755 --- a/netconn.c +++ b/netconn.c @@ -505,7 +505,7 @@ qboolean NetConn_CanSend(netconn_t *conn) } } -int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol, int rate) +int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol, int rate, qboolean quakesignon_suppressreliables) { int totallen = 0; @@ -622,7 +622,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers } // if we have a new reliable message to send, do so - if (!conn->sendMessageLength && conn->message.cursize) + if (!conn->sendMessageLength && conn->message.cursize && !quakesignon_suppressreliables) { if (conn->message.cursize > (int)sizeof(conn->sendMessage)) { @@ -1179,7 +1179,7 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer msg.data = buf; msg.maxsize = sizeof(buf); MSG_WriteChar(&msg, clc_nop); - NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol, 10000); + NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol, 10000, false); } } diff --git a/netconn.h b/netconn.h index b686aad9..d875e7a8 100755 --- a/netconn.h +++ b/netconn.h @@ -350,7 +350,7 @@ extern cvar_t net_address; //extern cvar_t net_netaddress_ipv6; qboolean NetConn_CanSend(netconn_t *conn); -int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol, int rate); +int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol, int rate, qboolean quakesignon_suppressreliables); void NetConn_CloseClientPorts(void); void NetConn_OpenClientPorts(void); void NetConn_CloseServerPorts(void); diff --git a/server.h b/server.h index e32c3550..a63d1232 100644 --- a/server.h +++ b/server.h @@ -140,6 +140,8 @@ typedef struct client_s qboolean clientconnectcalled; // false = don't send datagrams qboolean spawned; + // false = don't send reliable messages until svc_signonnum 2 (before spawned is set) + qboolean sendsignon; // requested rate in bytes per second int rate; diff --git a/sv_main.c b/sv_main.c index 3d9e091b..47b474e5 100644 --- a/sv_main.c +++ b/sv_main.c @@ -714,6 +714,7 @@ void SV_SendServerinfo (client_t *client) MSG_WriteByte (&client->netconnection->message, 1); client->spawned = false; // need prespawn, spawn, etc + client->sendsignon = true; // send this message, this will be cleared later // clear movement info until client enters the new level properly memset(&client->cmd, 0, sizeof(client->cmd)); @@ -1620,7 +1621,7 @@ static void SV_SendClientDatagram (client_t *client) if (!NetConn_CanSend(client->netconnection)) { // send the datagram - //NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate); + //NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate, true); return; } else if (host_client->spawned) @@ -1681,7 +1682,9 @@ static void SV_SendClientDatagram (client_t *client) } // send the datagram - NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate); + NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate, !client->spawned && !client->sendsignon); + if (!client->netconnection->message.cursize) + client->sendsignon = false; } /* -- 2.39.2