]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
fixed grenades to behave more like quake again (60 normal-dot-velocity tolerance...
[xonotic/darkplaces.git] / cl_parse.c
index 4719d72673ee43277f6fdd591c91b8386839700b..ed530fdd3ded6e4ef4ebbe96877e1940e6c02de7 100644 (file)
@@ -48,11 +48,11 @@ char *svc_strings[128] =
        "svc_updatecolors",     // [byte] [byte]
        "svc_particle",         // [vec3] <variable>
        "svc_damage",                   // [byte] impact [byte] blood [vec3] from
-       
+
        "svc_spawnstatic",
        "OBSOLETE svc_spawnbinary",
        "svc_spawnbaseline",
-       
+
        "svc_temp_entity",              // <variable>
        "svc_setpause",
        "svc_signonnum",
@@ -80,10 +80,16 @@ char *svc_strings[128] =
        "", // 47
        "", // 48
        "", // 49
-       "", // 50
-       "svc_fog", // 51
-       "svc_effect", // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate
-       "svc_effect2", // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate
+       "svc_cgame", //                         50              // [short] length [bytes] data
+       "svc_fog", //                           51              // unfinished and obsolete
+       "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
+       "svc_spawnbaseline2", //        55              // short modelindex instead of byte
+       "svc_spawnstatic2", //          56              // short modelindex instead of byte
+       "svc_entities", //                      57              // [int] deltaframe [int] thisframe [float vector] eye [variable length] entitydata
+       "svc_unusedlh3", //                     58
+       "svc_spawnstaticsound2", //     59              // [coord3] [short] samp [byte] vol [byte] aten
 };
 
 //=============================================================================
@@ -99,7 +105,7 @@ void CL_Parse_Init(void)
 }
 
 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
+int dpprotocol; // LordHavoc: version of network protocol, or 0 if not DarkPlaces
 
 /*
 ===============
@@ -192,7 +198,7 @@ void CL_KeepaliveMessage (void)
        static float lastmsg;
        int             ret;
        sizebuf_t       old;
-       byte            olddata[8192];
+       qbyte           olddata[8192];
        
        if (sv.active)
                return;         // no need if server is local
@@ -333,7 +339,7 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
                break;
 
        case 4:
-//             SCR_EndLoadingPlaque ();                // allow normal screen updates
+               SCR_EndLoadingPlaque ();                // allow normal screen updates
                Con_ClearNotify();
                break;
        }
@@ -360,9 +366,9 @@ void CL_ParseServerInfo (void)
 
 // parse protocol version number
        i = MSG_ReadLong ();
-       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION && i != 250)
+       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != 250)
        {
-               Con_Printf ("Server returned version %i, not %i or %i", i, DPPROTOCOL_VERSION, PROTOCOL_VERSION);
+               Con_Printf ("Server is protocol %i, not %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, PROTOCOL_VERSION);
                return;
        }
        Nehahrademcompatibility = false;
@@ -370,7 +376,9 @@ void CL_ParseServerInfo (void)
                Nehahrademcompatibility = true;
        if (cls.demoplayback && demo_nehahra.integer)
                Nehahrademcompatibility = true;
-       dpprotocol = i == DPPROTOCOL_VERSION;
+       dpprotocol = i;
+       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2)
+               dpprotocol = 0;
 
 // parse maxclients
        cl.maxclients = MSG_ReadByte ();
@@ -447,8 +455,6 @@ void CL_ParseServerInfo (void)
 // now we try to load everything else until a cache allocation fails
 //
 
-       Mem_CheckSentinelsGlobal();
-
        for (i=1 ; i<nummodels ; i++)
        {
                // LordHavoc: i == 1 means the first model is the world model
@@ -462,8 +468,6 @@ void CL_ParseServerInfo (void)
                CL_KeepaliveMessage ();
        }
 
-       Mem_CheckSentinelsGlobal();
-
        S_BeginPrecaching ();
        for (i=1 ; i<numsounds ; i++)
        {
@@ -479,8 +483,6 @@ void CL_ParseServerInfo (void)
 
        R_NewMap ();
 
-       Mem_CheckSentinelsGlobal();
-
        CL_CGVM_Start();
 
        Mem_CheckSentinelsGlobal();
@@ -525,7 +527,7 @@ If an entities model or origin changes from frame to frame, it must be
 relinked.  Other attributes can change without relinking.
 ==================
 */
-byte entkill[MAX_EDICTS];
+qbyte entkill[MAX_EDICTS];
 int bitprofile[32], bitprofilecount = 0;
 void CL_ParseUpdate (int bits)
 {
@@ -533,12 +535,6 @@ void CL_ParseUpdate (int bits)
        entity_t *ent;
        entity_state_t new;
 
-       if (cls.signon == SIGNONS - 1)
-       {       // first update is the final signon stage
-               cls.signon = SIGNONS;
-               CL_SignonReply ();
-       }
-
        if (bits & U_MOREBITS)
                bits |= (MSG_ReadByte()<<8);
        if ((bits & U_EXTEND1) && (!Nehahrademcompatibility))
@@ -660,6 +656,27 @@ void CL_ParseUpdate (int bits)
        }
 }
 
+void CL_ReadEntityFrame(void)
+{
+       entity_t *ent;
+       entity_state_t *s;
+       entity_frame_t entityframe;
+       int i;
+       EntityFrame_Read(&cl.entitydatabase);
+       EntityFrame_FetchFrame(&cl.entitydatabase, EntityFrame_MostRecentlyRecievedFrameNum(&cl.entitydatabase), &entityframe);
+       for (i = 0;i < entityframe.numentities;i++)
+       {
+               s = &entityframe.entitydata[i];
+               entkill[s->number] = 0;
+               ent = &cl_entities[s->number];
+               memcpy(&ent->state_previous, &ent->state_current, sizeof(*s));
+               memcpy(&ent->state_current, s, sizeof(*s));
+               ent->state_current.time = cl.mtime[0];
+       }
+       VectorCopy(cl.viewentoriginnew, cl.viewentoriginold);
+       VectorCopy(entityframe.eye, cl.viewentoriginnew);
+}
+
 char *bitprofilenames[32] =
 {
        "U_MOREBITS",
@@ -787,7 +804,7 @@ void CL_ParseClientdata (int bits)
                cl.idealpitch = MSG_ReadChar ();
        else
                cl.idealpitch = 0;
-       
+
        VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
        for (i=0 ; i<3 ; i++)
        {
@@ -801,7 +818,7 @@ void CL_ParseClientdata (int bits)
                else
                        cl.punchangle[i] = 0;
                if (bits & (SU_PUNCHVEC1<<i))
-                       cl.punchvector[i] = MSG_ReadFloatCoord();
+                       cl.punchvector[i] = MSG_ReadCoord();
                else
                        cl.punchvector[i] = 0;
                if (bits & (SU_VELOCITY1<<i) )
@@ -818,7 +835,7 @@ void CL_ParseClientdata (int bits)
                                cl.item_gettime[j] = cl.time;
                cl.items = i;
        }
-               
+
        cl.onground = (bits & SU_ONGROUND) != 0;
        cl.inwater = (bits & SU_INWATER) != 0;
 
@@ -839,6 +856,18 @@ void CL_ParseClientdata (int bits)
                cl.stats[STAT_ACTIVEWEAPON] = (1<<i);
        else
                cl.stats[STAT_ACTIVEWEAPON] = i;
+
+       cl.viewzoomold = cl.viewzoomnew; // for interpolation
+       if (bits & SU_VIEWZOOM)
+       {
+               i = MSG_ReadByte();
+               if (i < 2)
+                       i = 2;
+               cl.viewzoomnew = (float) i * (1.0f / 255.0f);
+       }
+       else
+               cl.viewzoomnew = 1;
+
 }
 
 /*
@@ -889,7 +918,7 @@ void CL_ParseStaticSound (int large)
                sound_num = MSG_ReadByte ();
        vol = MSG_ReadByte ();
        atten = MSG_ReadByte ();
-       
+
        S_StaticSound (cl.sound_precache[sound_num], org, vol, atten);
 }
 
@@ -924,7 +953,7 @@ void CL_ParseEffect2 (void)
 
 #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x);
 
-static byte cgamenetbuffer[65536];
+static qbyte cgamenetbuffer[65536];
 
 /*
 =====================
@@ -935,10 +964,10 @@ void CL_ParseServerMessage (void)
 {
        int                     cmd;
        int                     i, entitiesupdated;
-       byte            cmdlog[32];
+       qbyte           cmdlog[32];
        char            *cmdlogname[32], *temp;
        int                     cmdindex, cmdcount = 0;
-       
+
 //
 // if recording demos, copy the message out
 //
@@ -946,8 +975,8 @@ void CL_ParseServerMessage (void)
                Con_Printf ("%i ",net_message.cursize);
        else if (cl_shownet.integer == 2)
                Con_Printf ("------------------\n");
-       
-       cl.onground = false;    // unless the server says otherwise     
+
+       cl.onground = false;    // unless the server says otherwise
 //
 // parse the message
 //
@@ -955,7 +984,7 @@ void CL_ParseServerMessage (void)
 
        entitiesupdated = false;
        CL_EntityUpdateSetup();
-       
+
        while (1)
        {
                if (msg_badread)
@@ -980,6 +1009,11 @@ void CL_ParseServerMessage (void)
                        temp = "entity";
                        cmdlogname[cmdindex] = temp;
                        SHOWNET("fast update");
+                       if (cls.signon == SIGNONS - 1)
+                       {       // first update is the final signon stage
+                               cls.signon = SIGNONS;
+                               CL_SignonReply ();
+                       }
                        CL_ParseUpdate (cmd&127);
                        continue;
                }
@@ -1038,16 +1072,18 @@ void CL_ParseServerMessage (void)
 
                case svc_version:
                        i = MSG_ReadLong ();
-                       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);
+                       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);
                        Nehahrademcompatibility = false;
                        if (i == 250)
                                Nehahrademcompatibility = true;
                        if (cls.demoplayback && demo_nehahra.integer)
                                Nehahrademcompatibility = true;
-                       dpprotocol = i == DPPROTOCOL_VERSION;
+                       dpprotocol = i;
+                       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2)
+                               dpprotocol = 0;
                        break;
-                       
+
                case svc_disconnect:
                        Host_EndGame ("Server disconnected\n");
 
@@ -1071,16 +1107,16 @@ void CL_ParseServerMessage (void)
                        CL_ParseServerInfo ();
 //                     vid.recalc_refdef = true;       // leave intermission full screen
                        break;
-                       
+
                case svc_setangle:
                        for (i=0 ; i<3 ; i++)
                                cl.viewangles[i] = MSG_ReadAngle ();
                        break;
-                       
+
                case svc_setview:
                        cl.viewentity = MSG_ReadShort ();
                        break;
-                                       
+
                case svc_lightstyle:
                        i = MSG_ReadByte ();
                        if (i >= MAX_LIGHTSTYLES)
@@ -1106,24 +1142,24 @@ 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 >= cl.maxclients");
                        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 >= cl.maxclients");
                        cl.scores[i].frags = MSG_ReadShort ();
-                       break;                  
+                       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 >= cl.maxclients");
                        cl.scores[i].colors = MSG_ReadByte ();
                        break;
-                       
+
                case svc_particle:
                        CL_ParseParticleEffect ();
                        break;
@@ -1163,7 +1199,7 @@ void CL_ParseServerMessage (void)
                        else
                                CDAudio_Resume ();
                        break;
-                       
+
                case svc_signonnum:
                        i = MSG_ReadByte ();
                        if (i <= cls.signon)
@@ -1199,9 +1235,9 @@ void CL_ParseServerMessage (void)
                        cl.cdtrack = MSG_ReadByte ();
                        cl.looptrack = MSG_ReadByte ();
                        if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
-                               CDAudio_Play ((byte)cls.forcetrack, true);
+                               CDAudio_Play ((qbyte)cls.forcetrack, true);
                        else
-                               CDAudio_Play ((byte)cl.cdtrack, true);
+                               CDAudio_Play ((qbyte)cl.cdtrack, true);
                        break;
 
                case svc_intermission:
@@ -1221,7 +1257,7 @@ void CL_ParseServerMessage (void)
                        cl.intermission = 3;
                        cl.completed_time = cl.time;
 //                     vid.recalc_refdef = true;       // go to full screen
-                       SCR_CenterPrint (MSG_ReadString ());                    
+                       SCR_CenterPrint (MSG_ReadString ());
                        break;
 
                case svc_sellscreen:
@@ -1255,6 +1291,14 @@ void CL_ParseServerMessage (void)
                                        CL_CGVM_ParseNetwork(cgamenetbuffer, length);
                        }
                        break;
+               case svc_entities:
+                       if (cls.signon == SIGNONS - 1)
+                       {       // first update is the final signon stage
+                               cls.signon = SIGNONS;
+                               CL_SignonReply ();
+                       }
+                       CL_ReadEntityFrame();
+                       break;
                }
        }