brought back the client->sendsignon flag from original quake code, this
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Jun 2007 06:59:45 +0000 (06:59 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Jun 2007 06:59:45 +0000 (06:59 +0000)
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
cl_main.c
cl_parse.c
host.c
host_cmd.c
netconn.c
netconn.h
server.h
sv_main.c

index 88fb313..a725470 100644 (file)
@@ -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)
        {
index 3b6061b..ad928ca 100644 (file)
--- 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;
        }
index 1a85027..5f41466 100644 (file)
@@ -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 812a2cb..0a4df3d 100644 (file)
--- 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);
index bcdd0cf..f37626b 100644 (file)
@@ -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
 }
 
 /*
index fdf72bb..9e62d93 100755 (executable)
--- 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);
        }
 }
 
index b686aad..d875e7a 100755 (executable)
--- 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);
index e32c355..a63d123 100644 (file)
--- 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;
index 3d9e091..47b474e 100644 (file)
--- 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;
 }
 
 /*