]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
fix view blends so they are alpha, not additive
[xonotic/darkplaces.git] / cl_parse.c
index 5a1b5b5f840d58a21e4f05dadb65b6f4f0353892..902c2af148095b6c09b3f553a47b7f2b028794f2 100644 (file)
@@ -81,7 +81,7 @@ char *svc_strings[128] =
        "", // 48
        "", // 49
        "svc_cgame", //                         50              // [short] length [bytes] data
-       "svc_fog", //                           51              // unfinished and obsolete
+       "svc_unusedlh1", //                     51              // unused
        "svc_effect", //                        52              // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate
        "svc_effect2", //                       53              // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate
        "svc_sound2", //                        54              // short soundindex instead of byte
@@ -116,19 +116,6 @@ This error checks and tracks the total number of entities
 */
 entity_t       *CL_EntityNum (int num)
 {
-       /*
-       if (num >= cl.num_entities)
-       {
-               if (num >= MAX_EDICTS)
-                       Host_Error ("CL_EntityNum: %i is an invalid number",num);
-               cl.num_entities = num;
-//             while (cl.num_entities <= num)
-//             {
-//                     cl_entities[cl.num_entities].colormap = -1; // no special coloring
-//                     cl.num_entities++;
-//             }
-       }
-       */
        if (num >= MAX_EDICTS)
                Host_Error ("CL_EntityNum: %i is an invalid number",num);
                
@@ -182,7 +169,7 @@ void CL_ParseStartSoundPacket(int largesoundindex)
                pos[i] = MSG_ReadCoord ();
 
     S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
-}       
+}
 
 /*
 ==================
@@ -197,6 +184,7 @@ void CL_KeepaliveMessage (void)
        float   time;
        static float lastmsg;
        int             ret;
+       int             c;
        sizebuf_t       old;
        qbyte           olddata[8192];
        
@@ -215,14 +203,15 @@ void CL_KeepaliveMessage (void)
                switch (ret)
                {
                default:
-                       Host_Error ("CL_KeepaliveMessage: CL_GetMessage failed");               
+                       Host_Error ("CL_KeepaliveMessage: CL_GetMessage failed");
                case 0:
                        break;  // nothing waiting
                case 1:
                        Host_Error ("CL_KeepaliveMessage: received a message");
                        break;
                case 2:
-                       if (MSG_ReadByte() != svc_nop)
+                       c = MSG_ReadByte();
+                       if (c != svc_nop)
                                Host_Error ("CL_KeepaliveMessage: datagram wasn't a nop");
                        break;
                }
@@ -339,7 +328,6 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
                break;
 
        case 4:
-//             SCR_EndLoadingPlaque ();                // allow normal screen updates
                Con_ClearNotify();
                break;
        }
@@ -366,9 +354,9 @@ void CL_ParseServerInfo (void)
 
 // parse protocol version number
        i = MSG_ReadLong ();
-       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != 250)
+       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != DPPROTOCOL_VERSION3 && i != 250)
        {
-               Con_Printf ("Server is protocol %i, not %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, PROTOCOL_VERSION);
+               Con_Printf ("Server is protocol %i, not %i, %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, DPPROTOCOL_VERSION3, PROTOCOL_VERSION);
                return;
        }
        Nehahrademcompatibility = false;
@@ -377,7 +365,7 @@ void CL_ParseServerInfo (void)
        if (cls.demoplayback && demo_nehahra.integer)
                Nehahrademcompatibility = true;
        dpprotocol = i;
-       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2)
+       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2 && dpprotocol != DPPROTOCOL_VERSION3)
                dpprotocol = 0;
 
 // parse maxclients
@@ -471,7 +459,7 @@ void CL_ParseServerInfo (void)
        S_BeginPrecaching ();
        for (i=1 ; i<numsounds ; i++)
        {
-               cl.sound_precache[i] = S_PrecacheSound (sound_precache[i]);
+               cl.sound_precache[i] = S_PrecacheSound (sound_precache[i], true);
                CL_KeepaliveMessage ();
        }
        S_EndPrecaching ();
@@ -508,12 +496,12 @@ void CL_ValidateState(entity_state_t *s)
        Mod_CheckLoaded(model);
        if (model && s->frame >= model->numframes)
        {
-               Con_Printf("CL_ValidateState: no such frame %i in \"%s\"\n", s->frame, model->name);
+               Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\"\n", s->frame, model->name);
                s->frame = 0;
        }
        if (model && s->skin > 0 && s->skin >= model->numskins)
        {
-               Con_Printf("CL_ValidateState: no such skin %i in \"%s\"\n", s->skin, model->name);
+               Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\"\n", s->skin, model->name);
                s->skin = 0;
        }
 }
@@ -595,12 +583,8 @@ void CL_ParseUpdate (int bits)
        if (bits & U_EFFECTS2)  new.effects = (new.effects & 0x00FF) | (MSG_ReadByte() << 8);
        if (bits & U_GLOWSIZE)  new.glowsize = MSG_ReadByte();
        if (bits & U_GLOWCOLOR) new.glowcolor = MSG_ReadByte();
-#if 0
-       if (bits & U_COLORMOD)  {int i = MSG_ReadByte();float r = (((int) i >> 5) & 7) * 1.0 / 7, g = (((int) i >> 2) & 7) * 1.0 / 7, b = ((int) i & 3) * 1.0 / 3;Con_Printf("warning: U_COLORMOD %i (%1.2f %1.2f %1.2f) ignored\n", i, r, g, b);}
-#else
        // apparently the dpcrush demo uses this (unintended, and it uses white anyway)
        if (bits & U_COLORMOD)  MSG_ReadByte();
-#endif
        if (bits & U_GLOWTRAIL) new.flags |= RENDER_GLOWTRAIL;
        if (bits & U_FRAME2)    new.frame = (new.frame & 0x00FF) | (MSG_ReadByte() << 8);
        if (bits & U_MODEL2)    new.modelindex = (new.modelindex & 0x00FF) | (MSG_ReadByte() << 8);
@@ -615,7 +599,8 @@ void CL_ParseUpdate (int bits)
                int j = MSG_ReadFloat() * 255.0f;
                if (i == 2)
                {
-                       if (MSG_ReadFloat())
+                       i = MSG_ReadFloat();
+                       if (i)
                                new.effects |= EF_FULLBRIGHT;
                }
                if (j < 0)
@@ -719,8 +704,7 @@ void CL_BitProfile_f(void)
        Con_Printf("bitprofile: %i updates\n");
        if (bitprofilecount)
                for (i = 0;i < 32;i++)
-//                     if (bitprofile[i])
-                               Con_Printf("%s: %i %3.2f%%\n", bitprofilenames[i], bitprofile[i], bitprofile[i] * 100.0 / bitprofilecount);
+                       Con_Printf("%s: %i %3.2f%%\n", bitprofilenames[i], bitprofile[i], bitprofile[i] * 100.0 / bitprofilecount);
        Con_Printf("\n");
        for (i = 0;i < 32;i++)
                bitprofile[i] = 0;
@@ -899,6 +883,10 @@ void CL_ParseStatic (int large)
 
        VectorCopy (ent->state_baseline.origin, ent->render.origin);
        VectorCopy (ent->state_baseline.angles, ent->render.angles);    
+
+       // This is definitely cheating...
+       if (ent->render.model == NULL)
+               cl.num_statics--;
 }
 
 /*
@@ -1055,7 +1043,6 @@ void CL_ParseServerMessage (void)
                        break;
 
                case svc_nop:
-//                     Con_Printf ("svc_nop\n");
                        break;
 
                case svc_time:
@@ -1072,15 +1059,15 @@ void CL_ParseServerMessage (void)
 
                case svc_version:
                        i = MSG_ReadLong ();
-                       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != 250)
-                               Host_Error ("CL_ParseServerMessage: Server is protocol %i, not %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, PROTOCOL_VERSION);
+                       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != DPPROTOCOL_VERSION3 && i != 250)
+                               Host_Error ("CL_ParseServerMessage: Server is protocol %i, not %i, %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, DPPROTOCOL_VERSION3, PROTOCOL_VERSION);
                        Nehahrademcompatibility = false;
                        if (i == 250)
                                Nehahrademcompatibility = true;
                        if (cls.demoplayback && demo_nehahra.integer)
                                Nehahrademcompatibility = true;
                        dpprotocol = i;
-                       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2)
+                       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2 && dpprotocol != DPPROTOCOL_VERSION3)
                                dpprotocol = 0;
                        break;
 
@@ -1105,7 +1092,6 @@ void CL_ParseServerMessage (void)
 
                case svc_serverinfo:
                        CL_ParseServerInfo ();
-//                     vid.recalc_refdef = true;       // leave intermission full screen
                        break;
 
                case svc_setangle:
@@ -1243,20 +1229,17 @@ void CL_ParseServerMessage (void)
                case svc_intermission:
                        cl.intermission = 1;
                        cl.completed_time = cl.time;
-//                     vid.recalc_refdef = true;       // go to full screen
                        break;
 
                case svc_finale:
                        cl.intermission = 2;
                        cl.completed_time = cl.time;
-//                     vid.recalc_refdef = true;       // go to full screen
                        SCR_CenterPrint (MSG_ReadString ());
                        break;
 
                case svc_cutscene:
                        cl.intermission = 3;
                        cl.completed_time = cl.time;
-//                     vid.recalc_refdef = true;       // go to full screen
                        SCR_CenterPrint (MSG_ReadString ());
                        break;
 
@@ -1276,15 +1259,6 @@ void CL_ParseServerMessage (void)
                        {
                                int length;
                                length = (int) ((unsigned short) MSG_ReadShort());
-                               /*
-                               if (cgamenetbuffersize < length)
-                               {
-                                       cgamenetbuffersize = length;
-                                       if (cgamenetbuffer)
-                                               Mem_Free(cgamenetbuffer);
-                                       cgamenetbuffer = Mem_Alloc(cgamenetbuffersize);
-                               }
-                               */
                                for (i = 0;i < length;i++)
                                        cgamenetbuffer[i] = MSG_ReadByte();
                                if (!msg_badread)
@@ -1305,3 +1279,4 @@ void CL_ParseServerMessage (void)
        if (entitiesupdated)
                CL_EntityUpdateEnd();
 }
+