]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
rewrite of map texture loading (mainly to do with HL textures and wads)
[xonotic/darkplaces.git] / cl_parse.c
index 3a4cbe5ea5ea445f24ce6c4bb8af73f1f350d294..0d776abff948e84593a95c23b6ee3daa19e4a44a 100644 (file)
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
-char *svc_strings[] =
+char *svc_strings[128] =
 {
        "svc_bad",
        "svc_nop",
@@ -226,7 +226,7 @@ extern cvar_t r_farclip;
 void CL_ParseEntityLump(char *entdata)
 {
        char *data;
-       char key[128], value[1024];
+       char key[128], value[4096];
        char wadname[128];
        int i, j, k;
        FOG_clear(); // LordHavoc: no fog until set
@@ -282,12 +282,12 @@ void CL_ParseEntityLump(char *entdata)
                else if (!strcmp("wad", key)) // for HalfLife maps
                {
                        j = 0;
-                       for (i = 0;i < 128;i++)
+                       for (i = 0;i < 4096;i++)
                                if (value[i] != ';' && value[i] != '\\' && value[i] != '/' && value[i] != ':')
                                        break;
                        if (value[i])
                        {
-                               for (;i < 128;i++)
+                               for (;i < 4096;i++)
                                {
                                        // ignore path - the \\ check is for HalfLife... stupid windoze 'programmers'...
                                        if (value[i] == '\\' || value[i] == '/' || value[i] == ':')
@@ -298,7 +298,7 @@ void CL_ParseEntityLump(char *entdata)
                                                value[i] = 0;
                                                strcpy(wadname, "textures/");
                                                strcat(wadname, &value[j]);
-                                               W_LoadTextureWadFile (wadname, FALSE);
+                                               W_LoadTextureWadFile (wadname, false);
                                                j = i+1;
                                                if (!k)
                                                        break;
@@ -331,9 +331,9 @@ void CL_ParseServerInfo (void)
 
 // parse protocol version number
        i = MSG_ReadLong ();
-       if (i != PROTOCOL_VERSION && i != 250)
+       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION && i != 250)
        {
-               Con_Printf ("Server returned version %i, not %i", i, PROTOCOL_VERSION);
+               Con_Printf ("Server returned version %i, not %i or %i", i, DPPROTOCOL_VERSION, PROTOCOL_VERSION);
                return;
        }
        Nehahrademcompatibility = false;
@@ -765,6 +765,9 @@ void CL_ParseServerMessage (void)
 {
        int                     cmd;
        int                     i;
+       byte            cmdlog[32];
+       char            *cmdlogname[32], *temp;
+       int                     cmdindex, cmdcount = 0;
        
 //
 // if recording demos, copy the message out
@@ -793,21 +796,55 @@ void CL_ParseServerMessage (void)
                        return;         // end of message
                }
 
-       // if the high bit of the command byte is set, it is a fast update
+               cmdindex = cmdcount & 31;
+               cmdcount++;
+               cmdlog[cmdindex] = cmd;
+
+               // if the high bit of the command byte is set, it is a fast update
                if (cmd & 128)
                {
+                       // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
+                       temp = "svc_entity";
+                       cmdlogname[cmdindex] = temp;
                        SHOWNET("fast update");
                        CL_ParseUpdate (cmd&127);
                        continue;
                }
 
                SHOWNET(svc_strings[cmd]);
+               cmdlogname[cmdindex] = svc_strings[cmd];
+               if (!cmdlogname[cmdindex])
+               {
+                       // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
+                       temp = "<unknown>";
+                       cmdlogname[cmdindex] = temp;
+               }
        
-       // other commands
+               // other commands
                switch (cmd)
                {
                default:
-                       Host_Error ("CL_ParseServerMessage: Illegible server message\n");
+                       {
+                               char description[32*64], temp[64];
+                               int count;
+                               strcpy(description, "packet dump: ");
+                               i = cmdcount - 32;
+                               if (i < 0)
+                                       i = 0;
+                               count = cmdcount - i;
+                               i &= 31;
+                               while(count > 0)
+                               {
+                                       sprintf(temp, "%3i:%s ", cmdlog[i], cmdlogname[i]);
+                                       strcat(description, temp);
+                                       count--;
+                                       i++;
+                                       i &= 31;
+                               }
+                               description[strlen(description)-1] = '\n'; // replace the last space with a newline
+                               Con_Printf(description);
+                               Host_Error ("CL_ParseServerMessage: Illegible server message\n");
+                       }
                        break;
                        
                case svc_nop:
@@ -826,9 +863,17 @@ void CL_ParseServerMessage (void)
                
                case svc_version:
                        i = MSG_ReadLong ();
-                       if (i != PROTOCOL_VERSION && i != 250)
-                               Host_Error ("CL_ParseServerMessage: Server is protocol %i instead of %i\n", i, PROTOCOL_VERSION);
-                       Nehahrademcompatibility = i == 250;
+                       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION && i != 250)
+                       {
+                               Host_Error ("CL_ParseServerMessage: Server is protocol %i, not %i or %i", i, DPPROTOCOL_VERSION, PROTOCOL_VERSION);
+                               return;
+                       }
+                       Nehahrademcompatibility = false;
+                       if (i == 250)
+                               Nehahrademcompatibility = true;
+                       if (cls.demoplayback && demo_nehahra.value)
+                               Nehahrademcompatibility = true;
+                       dpprotocol = i == DPPROTOCOL_VERSION;
                        break;
                        
                case svc_disconnect:
@@ -868,7 +913,8 @@ void CL_ParseServerMessage (void)
                        i = MSG_ReadByte ();
                        if (i >= MAX_LIGHTSTYLES)
                                Host_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
-                       strcpy (cl_lightstyle[i].map,  MSG_ReadString());
+                       strncpy (cl_lightstyle[i].map,  MSG_ReadString(), MAX_STYLESTRING - 1);
+                       cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
                        cl_lightstyle[i].length = strlen(cl_lightstyle[i].map);
                        break;
                        
@@ -884,21 +930,21 @@ void CL_ParseServerMessage (void)
                case svc_updatename:
                        i = MSG_ReadByte ();
                        if (i >= cl.maxclients)
-                               Host_Error ("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD");
+                               Host_Error ("CL_ParseServerMessage: svc_updatename >= MAX_SCOREBOARD");
                        strcpy (cl.scores[i].name, MSG_ReadString ());
                        break;
                        
                case svc_updatefrags:
                        i = MSG_ReadByte ();
                        if (i >= cl.maxclients)
-                               Host_Error ("CL_ParseServerMessage: svc_updatefrags > MAX_SCOREBOARD");
+                               Host_Error ("CL_ParseServerMessage: svc_updatefrags >= MAX_SCOREBOARD");
                        cl.scores[i].frags = MSG_ReadShort ();
                        break;                  
 
                case svc_updatecolors:
                        i = MSG_ReadByte ();
                        if (i >= cl.maxclients)
-                               Host_Error ("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD");
+                               Host_Error ("CL_ParseServerMessage: svc_updatecolors >= MAX_SCOREBOARD");
                        cl.scores[i].colors = MSG_ReadByte ();
                        break;
                        
@@ -919,14 +965,11 @@ void CL_ParseServerMessage (void)
                        break;
 
                case svc_setpause:
-                       {
-                               cl.paused = MSG_ReadByte ();
-
-                               if (cl.paused)
-                                       CDAudio_Pause ();
-                               else
-                                       CDAudio_Resume ();
-                       }
+                       cl.paused = MSG_ReadByte ();
+                       if (cl.paused)
+                               CDAudio_Pause ();
+                       else
+                               CDAudio_Resume ();
                        break;
                        
                case svc_signonnum:
@@ -949,7 +992,7 @@ void CL_ParseServerMessage (void)
                        i = MSG_ReadByte ();
                        if (i < 0 || i >= MAX_CL_STATS)
                                Host_Error ("svc_updatestat: %i is invalid", i);
-                       cl.stats[i] = MSG_ReadLong ();;
+                       cl.stats[i] = MSG_ReadLong ();
                        break;
                        
                case svc_spawnstaticsound: