]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
Cleaned up a bit..
[xonotic/darkplaces.git] / cl_parse.c
index d7520d5fafbceaf4bacb8c96ab23b5a1b6d09c34..028dda200500bbcde5659ca024179f697ebab831 100644 (file)
@@ -80,13 +80,15 @@ char *svc_strings[] =
        "?", // 47
        "?", // 48
        "?", // 49
-       "svc_skyboxsize", // [coord] size
-       "svc_fog" // [byte] enable <optional past this point, only included if enable is true> [float] density [byte] red [byte] green [byte] blue
+       "svc_farclip", // [coord] size
+       "svc_fog", // [byte] enable <optional past this point, only included if enable is true> [short * 4096] density [byte] red [byte] green [byte] blue
+       "svc_playerposition" // [float] x [float] y [float] z
 };
 
 //=============================================================================
 
-int Nehahrademcompatibility; // LordHavoc: to allow playback of the early Nehahra movie segments
+qboolean Nehahrademcompatibility; // LordHavoc: to allow playback of the early Nehahra movie segments
+qboolean dpprotocol; // LordHavoc: whether or not the current network stream is the enhanced DarkPlaces protocol
 
 /*
 ===============
@@ -103,7 +105,7 @@ entity_t    *CL_EntityNum (int num)
                        Host_Error ("CL_EntityNum: %i is an invalid number",num);
                while (cl.num_entities<=num)
                {
-                       cl_entities[cl.num_entities].colormap = vid.colormap;
+                       cl_entities[cl.num_entities].colormap = -1; // no special coloring
                        cl.num_entities++;
                }
        }
@@ -217,12 +219,13 @@ void CL_KeepaliveMessage (void)
 
 extern qboolean isworldmodel;
 extern char skyname[];
-extern cvar_t r_fogdensity;
-extern cvar_t r_fogred;
-extern cvar_t r_foggreen;
-extern cvar_t r_fogblue;
+extern float fog_density;
+extern float fog_red;
+extern float fog_green;
+extern float fog_blue;
 extern void R_SetSkyBox (char *sky);
 extern void FOG_clear();
+extern cvar_t r_farclip;
 
 void CL_ParseEntityLump(char *entdata)
 {
@@ -232,7 +235,7 @@ void CL_ParseEntityLump(char *entdata)
        int i, j, k;
        FOG_clear(); // LordHavoc: no fog until set
        skyname[0] = 0; // LordHavoc: no enviroment mapped sky until set
-//     r_skyboxsize.value = 4096; // LordHavoc: default skyboxsize
+       r_farclip.value = 6144; // LordHavoc: default farclip distance
        data = entdata;
        if (!data)
                return;
@@ -261,20 +264,25 @@ void CL_ParseEntityLump(char *entdata)
                        R_SetSkyBox(value);
                else if (!strcmp("qlsky", key)) // non-standard, introduced by QuakeLives (EEK)
                        R_SetSkyBox(value);
-//             else if (!strcmp("skyboxsize", key))
-//             {
-//                     r_skyboxsize.value = atof(value);
-//                     if (r_skyboxsize.value < 64)
-//                             r_skyboxsize.value = 64;
-//             }
+               else if (!strcmp("farclip", key))
+               {
+                       r_farclip.value = atof(value);
+                       if (r_farclip.value < 64)
+                               r_farclip.value = 64;
+               }
+               else if (!strcmp("fog", key))
+               {
+                       scanf(value, "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
+                       j = 0;
+               }
                else if (!strcmp("fog_density", key))
-                       r_fogdensity.value = atof(value);
+                       fog_density = atof(value);
                else if (!strcmp("fog_red", key))
-                       r_fogred.value = atof(value);
+                       fog_red = atof(value);
                else if (!strcmp("fog_green", key))
-                       r_foggreen.value = atof(value);
+                       fog_green = atof(value);
                else if (!strcmp("fog_blue", key))
-                       r_fogblue.value = atof(value);
+                       fog_blue = atof(value);
                else if (!strcmp("wad", key)) // for HalfLife maps
                {
                        j = 0;
@@ -337,6 +345,7 @@ void CL_ParseServerInfo (void)
                Nehahrademcompatibility = true;
        if (cls.demoplayback && demo_nehahra.value)
                Nehahrademcompatibility = true;
+       dpprotocol = i == DPPROTOCOL_VERSION;
 
 // parse maxclients
        cl.maxclients = MSG_ReadByte ();
@@ -507,8 +516,6 @@ void CL_ParseUpdate (int bits)
                        ent->syncbase = model->synctype == ST_RAND ? (float)(rand()&0x7fff) / 0x7fff : 0.0;
                else
                        forcelink = true;       // hack to make null model players work
-               if (num > 0 && num <= cl.maxclients)
-                       R_TranslatePlayerSkin (num - 1);
        }
 
        ent->frame = ((bits & U_FRAME) ? MSG_ReadByte() : (baseline->frame & 0xFF));
@@ -516,20 +523,18 @@ void CL_ParseUpdate (int bits)
        i = bits & U_COLORMAP ? MSG_ReadByte() : baseline->colormap;
        ent->deltabaseline.colormap = i;
        if (!i)
-               ent->colormap = vid.colormap;
+               ent->colormap = -1; // no special coloring
        else
        {
                if (i > cl.maxclients)
-                       Sys_Error ("i >= cl.maxclients");
-               ent->colormap = cl.scores[i-1].translations;
+                       Host_Error ("i >= cl.maxclients");
+               ent->colormap = cl.scores[i-1].colors; // color it
        }
 
        skin = bits & U_SKIN ? MSG_ReadByte() : baseline->skin;
        if (skin != ent->skinnum)
        {
                ent->skinnum = skin;
-               if (num > 0 && num <= cl.maxclients)
-                       R_TranslatePlayerSkin (num - 1);
        }
        ent->deltabaseline.skin = skin;
 
@@ -567,7 +572,7 @@ void CL_ParseUpdate (int bits)
        ent->deltabaseline.frame = ent->frame;
        ent->alpha = (float) alpha * (1.0 / 255.0);
        ent->scale = (float) scale * (1.0 / 16.0);
-       ent->glowsize = glowsize < 128 ? glowsize * 8.0 : (glowsize - 256) * 8.0;
+       ent->glowsize = glowsize * 4.0;
        ent->glowcolor = glowcolor;
        ent->colormod[0] = (float) ((colormod >> 5) & 7) * (1.0 / 7.0);
        ent->colormod[1] = (float) ((colormod >> 2) & 7) * (1.0 / 7.0);
@@ -740,44 +745,6 @@ void CL_ParseClientdata (int bits)
        }
 }
 
-/*
-=====================
-CL_NewTranslation
-=====================
-*/
-void CL_NewTranslation (int slot)
-{
-       int             i, j;
-       int             top, bottom;
-       byte    *dest, *source;
-       
-       if (slot > cl.maxclients)
-               Sys_Error ("CL_NewTranslation: slot > cl.maxclients");
-       dest = cl.scores[slot].translations;
-       source = vid.colormap;
-       memcpy (dest, vid.colormap, sizeof(cl.scores[slot].translations));
-       top = cl.scores[slot].colors & 0xf0;
-       bottom = (cl.scores[slot].colors &15)<<4;
-       R_TranslatePlayerSkin (slot);
-
-       for (i=0 ; i<VID_GRADES ; i++, dest += 256, source+=256)
-       {
-               // LordHavoc: corrected color ranges
-               if (top < 128 || (top >= 224 && top < 240))     // the artists made some backwards ranges.  sigh.
-                       memcpy (dest + TOP_RANGE, source + top, 16);
-               else
-                       for (j=0 ; j<16 ; j++)
-                               dest[TOP_RANGE+j] = source[top+15-j];
-                               
-               // LordHavoc: corrected color ranges
-               if (bottom < 128 || (bottom >= 224 && bottom < 240))
-                       memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
-               else
-                       for (j=0 ; j<16 ; j++)
-                               dest[BOTTOM_RANGE+j] = source[bottom+15-j];             
-       }
-}
-
 /*
 =====================
 CL_ParseStatic
@@ -798,7 +765,7 @@ void CL_ParseStatic (void)
 // copy it to the current state
        ent->model = cl.model_precache[ent->baseline.modelindex];
        ent->frame = ent->baseline.frame;
-       ent->colormap = vid.colormap;
+       ent->colormap = -1; // no special coloring
        ent->skinnum = ent->baseline.skin;
        ent->effects = ent->baseline.effects;
        ent->alpha = 1;
@@ -840,10 +807,10 @@ extern void SHOWLMP_decodehide();
 extern void SHOWLMP_decodeshow();
 extern void R_SetSkyBox(char* sky);
 
-extern cvar_t r_fogdensity;
-extern cvar_t r_fogred;
-extern cvar_t r_foggreen;
-extern cvar_t r_fogblue;
+extern float fog_density;
+extern float fog_red;
+extern float fog_green;
+extern float fog_blue;
 
 /*
 =====================
@@ -956,7 +923,7 @@ void CL_ParseServerMessage (void)
                case svc_lightstyle:
                        i = MSG_ReadByte ();
                        if (i >= MAX_LIGHTSTYLES)
-                               Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
+                               Host_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
                        strcpy (cl_lightstyle[i].map,  MSG_ReadString());
                        cl_lightstyle[i].length = strlen(cl_lightstyle[i].map);
                        break;
@@ -992,7 +959,6 @@ void CL_ParseServerMessage (void)
                        if (i >= cl.maxclients)
                                Host_Error ("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD");
                        cl.scores[i].colors = MSG_ReadByte ();
-                       CL_NewTranslation (i);
                        break;
                        
                case svc_particle:
@@ -1016,19 +982,9 @@ void CL_ParseServerMessage (void)
                                cl.paused = MSG_ReadByte ();
 
                                if (cl.paused)
-                               {
                                        CDAudio_Pause ();
-#ifdef _WIN32
-                                       VID_HandlePause (true);
-#endif
-                               }
                                else
-                               {
                                        CDAudio_Resume ();
-#ifdef _WIN32
-                                       VID_HandlePause (false);
-#endif
-                               }
                        }
                        break;
                        
@@ -1051,7 +1007,7 @@ void CL_ParseServerMessage (void)
                case svc_updatestat:
                        i = MSG_ReadByte ();
                        if (i < 0 || i >= MAX_CL_STATS)
-                               Sys_Error ("svc_updatestat: %i is invalid", i);
+                               Host_Error ("svc_updatestat: %i is invalid", i);
                        cl.stats[i] = MSG_ReadLong ();;
                        break;
                        
@@ -1097,23 +1053,23 @@ void CL_ParseServerMessage (void)
                case svc_showlmp:
                        SHOWLMP_decodeshow();
                        break;
-       // LordHavoc: extra worldspawn fields (fog, sky, skyboxsize)
+       // LordHavoc: extra worldspawn fields (fog, sky, farclip)
                case svc_skybox:
                        R_SetSkyBox(MSG_ReadString());
                        break;
-               case svc_skyboxsize:
-                       /*r_skyboxsize.value = */MSG_ReadCoord();
+               case svc_farclip:
+                       r_farclip.value = MSG_ReadCoord();
                        break;
                case svc_fog:
                        if (MSG_ReadByte())
                        {
-                               r_fogdensity.value = MSG_ReadFloat();
-                               r_fogred.value = MSG_ReadByte() * (1.0 / 255.0);
-                               r_foggreen.value = MSG_ReadByte() * (1.0 / 255.0);
-                               r_fogblue.value = MSG_ReadByte() * (1.0 / 255.0);
+                               fog_density = MSG_ReadShort() * (1.0f / 4096.0f);
+                               fog_red = MSG_ReadByte() * (1.0 / 255.0);
+                               fog_green = MSG_ReadByte() * (1.0 / 255.0);
+                               fog_blue = MSG_ReadByte() * (1.0 / 255.0);
                        }
                        else
-                               r_fogdensity.value = 0.0f;
+                               fog_density = 0.0f;
                        break;
                }
        }