]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
removed crash parameter from Host_ShudownServer, eliminated NetConn_SendToAll and...
[xonotic/darkplaces.git] / cl_parse.c
index 9021405788fe0a29bddcd2917ed4023489a4103c..78f2589a28bffd161801a2486463e87e9cfab1ac 100644 (file)
@@ -97,8 +97,8 @@ char *svc_strings[128] =
 
 //=============================================================================
 
-cvar_t demo_nehahra = {0, "demo_nehahra", "0"};
-cvar_t developer_networkentities = {0, "developer_networkentities", "0"};
+cvar_t demo_nehahra = {0, "demo_nehahra", "0", "reads all quake demos as nehahra movie protocol"};
+cvar_t developer_networkentities = {0, "developer_networkentities", "0", "prints received entities, value is 0-4 (higher for more info)"};
 
 /*
 ==================
@@ -173,7 +173,7 @@ static unsigned char olddata[NET_MAXMESSAGE];
 void CL_KeepaliveMessage (void)
 {
        float time;
-       static float lastmsg;
+       static double nextmsg = -1;
        int oldreadcount;
        qboolean oldbadread;
        sizebuf_t old;
@@ -195,17 +195,17 @@ void CL_KeepaliveMessage (void)
        net_message = old;
        memcpy(net_message.data, olddata, net_message.cursize);
 
-       if (cls.netcon && NetConn_CanSendMessage(cls.netcon) && (time = Sys_DoubleTime()) - lastmsg >= 5)
+       if (cls.netcon && (time = Sys_DoubleTime()) >= nextmsg)
        {
                sizebuf_t       msg;
                unsigned char           buf[4];
-               lastmsg = time;
+               nextmsg = time + 5;
                // write out a nop
                // LordHavoc: must use unreliable because reliable could kill the sigon message!
                Con_Print("--> client to server keepalive\n");
+               memset(&msg, 0, sizeof(msg));
                msg.data = buf;
                msg.maxsize = sizeof(buf);
-               msg.cursize = 0;
                MSG_WriteChar(&msg, svc_nop);
                NetConn_SendUnreliableMessage(cls.netcon, &msg);
        }
@@ -268,50 +268,57 @@ An svc_signonnum has been received, perform a client side setup
 */
 static void CL_SignonReply (void)
 {
-       //char  str[8192];
-
-Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
+       Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
 
        switch (cls.signon)
        {
        case 1:
-               MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, "prespawn");
+               if (cls.netcon)
+               {
+                       MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString (&cls.netcon->message, "prespawn");
+               }
                break;
 
        case 2:
-               MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, va("name \"%s\"", cl_name.string));
+               if (cls.netcon)
+               {
+                       MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString (&cls.netcon->message, va("name \"%s\"", cl_name.string));
 
-               MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
+                       MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString (&cls.netcon->message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
 
-               if (cl_pmodel.integer)
-               {
-                       MSG_WriteByte (&cls.message, clc_stringcmd);
-                       MSG_WriteString (&cls.message, va("pmodel %i", cl_pmodel.integer));
-               }
-               if (*cl_playermodel.string)
-               {
-                       MSG_WriteByte (&cls.message, clc_stringcmd);
-                       MSG_WriteString (&cls.message, va("playermodel %s", cl_playermodel.string));
-               }
-               if (*cl_playerskin.string)
-               {
-                       MSG_WriteByte (&cls.message, clc_stringcmd);
-                       MSG_WriteString (&cls.message, va("playerskin %s", cl_playerskin.string));
-               }
+                       if (cl_pmodel.integer)
+                       {
+                               MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                               MSG_WriteString (&cls.netcon->message, va("pmodel %i", cl_pmodel.integer));
+                       }
+                       if (*cl_playermodel.string)
+                       {
+                               MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                               MSG_WriteString (&cls.netcon->message, va("playermodel %s", cl_playermodel.string));
+                       }
+                       if (*cl_playerskin.string)
+                       {
+                               MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                               MSG_WriteString (&cls.netcon->message, va("playerskin %s", cl_playerskin.string));
+                       }
 
-               MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, va("rate %i", cl_rate.integer));
+                       MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString (&cls.netcon->message, va("rate %i", cl_rate.integer));
 
-               MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, "spawn");
+                       MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString (&cls.netcon->message, "spawn");
+               }
                break;
 
        case 3:
-               MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, "begin");
+               if (cls.netcon)
+               {
+                       MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString (&cls.netcon->message, "begin");
+               }
                break;
 
        case 4:
@@ -1524,8 +1531,11 @@ void CL_ParseServerMessage(void)
 
                case svc_lightstyle:
                        i = MSG_ReadByte ();
-                       if (i >= MAX_LIGHTSTYLES)
-                               Host_Error ("svc_lightstyle >= MAX_LIGHTSTYLES");
+                       if (i >= cl_max_lightstyle)
+                       {
+                               Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
+                               break;
+                       }
                        strlcpy (cl_lightstyle[i].map,  MSG_ReadString(), sizeof (cl_lightstyle[i].map));
                        cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
                        cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);