]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
renamed PROTOCOL_VERSION stuff to PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, and so on
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 13 Sep 2003 04:50:36 +0000 (04:50 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 13 Sep 2003 04:50:36 +0000 (04:50 +0000)
mostly fixed network entity bugs

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3453 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
cl_main.c
cl_parse.c
client.h
common.h
netconn.c
protocol.c
protocol.h
sv_main.c
sv_user.c

index 680632c75a2a354aae828dd6568682621e7e6b3b..53438e56f41e59501ed4ac241e5037a3eff6822c 100644 (file)
@@ -387,12 +387,12 @@ void CL_SendMove(usercmd_t *cmd)
 
        MSG_WriteFloat (&buf, cl.mtime[0]);     // so server can get ping times
 
-       if (dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3)
+       if (cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3)
        {
                for (i = 0;i < 3;i++)
                        MSG_WriteFloat (&buf, cl.viewangles[i]);
        }
-       else if (dpprotocol == DPPROTOCOL_VERSION1 || dpprotocol == DPPROTOCOL_VERSION4)
+       else if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES4)
        {
                for (i=0 ; i<3 ; i++)
                        MSG_WritePreciseAngle (&buf, cl.viewangles[i]);
@@ -431,7 +431,7 @@ void CL_SendMove(usercmd_t *cmd)
        MSG_WriteByte (&buf, in_impulse);
        in_impulse = 0;
 
-       if (dpprotocol == DPPROTOCOL_VERSION1 || dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3)
+       if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3)
        {
                // LordHavoc: should we ack this on receipt instead?  would waste net bandwidth though
                i = EntityFrame_MostRecentlyRecievedFrameNum(&cl.entitydatabase);
index 88b134c839f363fd6e8380127db88f3f5a9fc2fc..fe5f8afd642dd37de7f002e0362ec628e4538012 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -462,7 +462,6 @@ void CL_DecayLights(void)
                        dl->radius = (cl.time < dl->die) ? max(0, dl->radius - time * dl->decay) : 0;
 }
 
-extern qboolean Nehahrademcompatibility;
 #define MAXVIEWMODELS 32
 entity_t *viewmodels[MAXVIEWMODELS];
 int numviewmodels;
@@ -786,7 +785,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE))
                 && (e->render.alpha == 1)
                 && !(e->render.flags & RENDER_VIEWMODEL)
-                && ((e - cl_entities) != cl.viewentity || (!cl.intermission && !Nehahrademcompatibility && !cl_noplayershadow.integer)))
+                && ((e - cl_entities) != cl.viewentity || (!cl.intermission && cl.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
                        e->render.flags |= RENDER_SHADOW;
                // as soon as player is known we can call V_CalcRefDef
                if ((e - cl_entities) == cl.viewentity)
index c8ac50b9422f955b6f0659781772e1f35b9f6104..38de3397371a68e4c877cb6478c2139ced42c77c 100644 (file)
@@ -96,9 +96,7 @@ char *svc_strings[128] =
 //=============================================================================
 
 cvar_t demo_nehahra = {0, "demo_nehahra", "0"};
-
-qboolean Nehahrademcompatibility; // LordHavoc: to allow playback of the early Nehahra movie segments
-int dpprotocol; // LordHavoc: version of network protocol, or 0 if not DarkPlaces
+cvar_t developer_networkentities = {0, "developer_networkentities", "0"};
 
 mempool_t *cl_scores_mempool;
 
@@ -331,19 +329,15 @@ void CL_ParseServerInfo (void)
 
 // parse protocol version number
        i = MSG_ReadLong ();
-       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != DPPROTOCOL_VERSION3 && i != DPPROTOCOL_VERSION4 && i != 250)
+       // hack for unmarked Nehahra movie demos which had a custom protocol
+       if (i == PROTOCOL_QUAKE && cls.demoplayback && demo_nehahra.integer)
+               i = PROTOCOL_NEHAHRAMOVIE;
+       if (i != PROTOCOL_QUAKE && i != PROTOCOL_DARKPLACES1 && i != PROTOCOL_DARKPLACES2 && i != PROTOCOL_DARKPLACES3 && i != PROTOCOL_DARKPLACES4 && i != PROTOCOL_NEHAHRAMOVIE)
        {
-               Host_Error ("Server is protocol %i, not %i, %i, %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, DPPROTOCOL_VERSION3, DPPROTOCOL_VERSION4, PROTOCOL_VERSION);
+               Host_Error("CL_ParseServerInfo: Server is protocol %i, not %i (Quake), %i (DP1), %i (DP2), %i (DP3), %i (DP4), or %i (Nehahra movie)", i, PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRAMOVIE);
                return;
        }
-       Nehahrademcompatibility = false;
-       if (i == 250)
-               Nehahrademcompatibility = true;
-       if (cls.demoplayback && demo_nehahra.integer)
-               Nehahrademcompatibility = true;
-       dpprotocol = i;
-       if (dpprotocol != DPPROTOCOL_VERSION1 && dpprotocol != DPPROTOCOL_VERSION2 && dpprotocol != DPPROTOCOL_VERSION3 && dpprotocol != DPPROTOCOL_VERSION4)
-               dpprotocol = 0;
+       cl.protocol = i;
 
 // parse maxclients
        cl.maxclients = MSG_ReadByte ();
@@ -363,10 +357,10 @@ void CL_ParseServerInfo (void)
        strncpy (cl.levelname, str, sizeof(cl.levelname)-1);
 
 // seperate the printfs so the server message can have a color
-       if (!Nehahrademcompatibility) // no messages when playing the Nehahra movie
+       if (cl.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
        {
                Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
-               Con_Printf ("%c%s\n", 2, str);
+               Con_Printf("%c%s\n", 2, str);
        }
 
        // check memory integrity
@@ -560,7 +554,7 @@ void CL_ParseUpdate (int bits)
 
        if (bits & U_MOREBITS)
                bits |= (MSG_ReadByte()<<8);
-       if ((bits & U_EXTEND1) && (!Nehahrademcompatibility))
+       if ((bits & U_EXTEND1) && cl.protocol != PROTOCOL_NEHAHRAMOVIE)
        {
                bits |= MSG_ReadByte() << 16;
                if (bits & U_EXTEND2)
@@ -619,7 +613,7 @@ void CL_ParseUpdate (int bits)
        if (bits & U_EXTERIORMODEL)     new.flags |= RENDER_EXTERIORMODEL;
 
        // LordHavoc: to allow playback of the Nehahra movie
-       if (Nehahrademcompatibility && (bits & U_EXTEND1))
+       if (cl.protocol == PROTOCOL_NEHAHRAMOVIE && (bits & U_EXTEND1))
        {
                // LordHavoc: evil format
                int i = MSG_ReadFloat();
@@ -656,7 +650,7 @@ static entity_frame_t entityframe;
 extern mempool_t *cl_entities_mempool;
 void CL_ReadEntityFrame(void)
 {
-       if (dpprotocol == DPPROTOCOL_VERSION1 || dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3)
+       if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3)
        {
                int i;
                entity_t *ent;
@@ -688,7 +682,7 @@ void CL_EntityUpdateSetup(void)
 
 void CL_EntityUpdateEnd(void)
 {
-       if (dpprotocol == PROTOCOL_VERSION || dpprotocol == DPPROTOCOL_VERSION1 || dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3)
+       if (cl.protocol == PROTOCOL_QUAKE || cl.protocol == PROTOCOL_NEHAHRAMOVIE || cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3)
        {
                int i;
                // disable entities that disappeared this frame
@@ -772,7 +766,7 @@ void CL_ParseClientdata (int bits)
        {
                if (bits & (SU_PUNCH1<<i) )
                {
-                       if (dpprotocol)
+                       if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4)
                                cl.punchangle[i] = MSG_ReadPreciseAngle();
                        else
                                cl.punchangle[i] = MSG_ReadChar();
@@ -1504,16 +1498,12 @@ void CL_ParseServerMessage(void)
 
                case svc_version:
                        i = MSG_ReadLong ();
-                       if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION1 && i != DPPROTOCOL_VERSION2 && i != DPPROTOCOL_VERSION3 && i != DPPROTOCOL_VERSION4 && i != 250)
-                               Host_Error ("CL_ParseServerMessage: Server is protocol %i, not %i, %i, %i, %i or %i", i, DPPROTOCOL_VERSION1, DPPROTOCOL_VERSION2, DPPROTOCOL_VERSION3, DPPROTOCOL_VERSION4, 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 && dpprotocol != DPPROTOCOL_VERSION3 && dpprotocol != DPPROTOCOL_VERSION4)
-                               dpprotocol = 0;
+                       // hack for unmarked Nehahra movie demos which had a custom protocol
+                       if (i == PROTOCOL_QUAKE && cls.demoplayback && demo_nehahra.integer)
+                               i = PROTOCOL_NEHAHRAMOVIE;
+                       if (i != PROTOCOL_QUAKE && i != PROTOCOL_DARKPLACES1 && i != PROTOCOL_DARKPLACES2 && i != PROTOCOL_DARKPLACES3 && i != PROTOCOL_DARKPLACES4 && i != PROTOCOL_NEHAHRAMOVIE)
+                               Host_Error("CL_ParseServerMessage: Server is protocol %i, not %i (Quake), %i (DP1), %i (DP2), %i (DP3), %i (DP4), or %i (Nehahra movie)", i, PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRAMOVIE);
+                       cl.protocol = i;
                        break;
 
                case svc_disconnect:
@@ -1751,4 +1741,5 @@ void CL_Parse_Init(void)
        Cvar_RegisterVariable (&demo_nehahra);
        if (gamemode == GAME_NEHAHRA)
                Cvar_SetValue("demo_nehahra", 1);
+       Cvar_RegisterVariable(&developer_networkentities);
 }
index c0350f8779d0f21559f85c9dda5bfad53b06bac0..88b75241123e5c4f198429e447d033e907fe9419 100644 (file)
--- a/client.h
+++ b/client.h
@@ -425,6 +425,9 @@ typedef struct
        // for interpolation
        float viewzoomold, viewzoomnew;
 
+       // protocol version of the server we're connected to
+       int protocol;
+
        // entity database stuff
        entity_database_t entitydatabase;
        entity_database4_t *entitydatabase4;
index f3e7be34fc414a6332f2bef1e6ef72cbef7f97cb..302dee2d06e73227ca48bff6e10cb7fb8a3b827f 100644 (file)
--- a/common.h
+++ b/common.h
@@ -138,8 +138,6 @@ float MSG_ReadDPCoord (void);
 
 #define MSG_ReadVector(v) {(v)[0] = MSG_ReadCoord();(v)[1] = MSG_ReadCoord();(v)[2] = MSG_ReadCoord();}
 
-extern int dpprotocol;
-
 //============================================================================
 
 extern char com_token[1024];
index 3c70fefec5476a771c8899528e4608d5e1edee3e..9d2abab9dbdda00e9004026287cd43f23950de50 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -35,7 +35,6 @@ static cvar_t sv_masters [] =
        {CVAR_SAVE, "sv_master3", ""},
        {CVAR_SAVE, "sv_master4", ""},
        {0, "sv_masterextra1", "198.88.152.4"},
-       {0, "sv_masterextra2", "68.102.242.12"},
        {0, NULL, NULL}
 };
 
index e773b2f8948200a5b57792936f6273b19538de47..4df89c77708f6b30b69d12eb494876aacfe7d752 100644 (file)
@@ -1,6 +1,8 @@
 
 #include "quakedef.h"
 
+extern cvar_t developer_networkentities;
+
 entity_state_t defaultstate =
 {
        0,//double time; // time this state was built
@@ -207,11 +209,8 @@ void EntityState_Write(entity_state_t *ent, sizebuf_t *msg, entity_state_t *delt
 void EntityState_ReadUpdate(entity_state_t *e, int number)
 {
        int bits;
-       if (!e->active)
-       {
-               *e = defaultstate;
-               e->active = true;
-       }
+       cl_entities_active[number] = true;
+       e->active = true;
        e->time = cl.mtime[0];
        e->number = number;
 
@@ -227,7 +226,7 @@ void EntityState_ReadUpdate(entity_state_t *e, int number)
                }
        }
 
-       if (dpprotocol == DPPROTOCOL_VERSION2)
+       if (cl.protocol == PROTOCOL_DARKPLACES2)
        {
                if (bits & E_ORIGIN1)
                        e->origin[0] = (signed short) MSG_ReadShort();
@@ -240,7 +239,7 @@ void EntityState_ReadUpdate(entity_state_t *e, int number)
        {
                if (bits & E_FLAGS)
                        e->flags = MSG_ReadByte();
-               if (e->flags & RENDER_LOWPRECISION || dpprotocol == DPPROTOCOL_VERSION2)
+               if (e->flags & RENDER_LOWPRECISION || cl.protocol == PROTOCOL_DARKPLACES2)
                {
                        if (bits & E_ORIGIN1)
                                e->origin[0] = (signed short) MSG_ReadShort();
@@ -289,7 +288,7 @@ void EntityState_ReadUpdate(entity_state_t *e, int number)
                e->glowsize = MSG_ReadByte();
        if (bits & E_GLOWCOLOR)
                e->glowcolor = MSG_ReadByte();
-       if (dpprotocol == DPPROTOCOL_VERSION2)
+       if (cl.protocol == PROTOCOL_DARKPLACES2)
                if (bits & E_FLAGS)
                        e->flags = MSG_ReadByte();
        if (bits & E_TAGATTACHMENT)
@@ -297,6 +296,48 @@ void EntityState_ReadUpdate(entity_state_t *e, int number)
                e->tagentity = MSG_ReadShort();
                e->tagindex = MSG_ReadByte();
        }
+
+       if (developer_networkentities.integer)
+       {
+               Con_Printf("ReadUpdate e%i", number);
+
+               if (bits & E_ORIGIN1)
+                       Con_Printf(" E_ORIGIN1 %f", e->origin[0]);
+               if (bits & E_ORIGIN2)
+                       Con_Printf(" E_ORIGIN2 %f", e->origin[1]);
+               if (bits & E_ORIGIN3)
+                       Con_Printf(" E_ORIGIN3 %f", e->origin[2]);
+               if (bits & E_ANGLE1)
+                       Con_Printf(" E_ANGLE1 %f", e->angles[0]);
+               if (bits & E_ANGLE2)
+                       Con_Printf(" E_ANGLE2 %f", e->angles[1]);
+               if (bits & E_ANGLE3)
+                       Con_Printf(" E_ANGLE3 %f", e->angles[2]);
+               if (bits & (E_MODEL1 | E_MODEL2))
+                       Con_Printf(" E_MODEL %i", e->modelindex);
+
+               if (bits & (E_FRAME1 | E_FRAME2))
+                       Con_Printf(" E_FRAME %i", e->frame);
+               if (bits & (E_EFFECTS1 | E_EFFECTS2))
+                       Con_Printf(" E_EFFECTS %i", e->effects);
+               if (bits & E_ALPHA)
+                       Con_Printf(" E_ALPHA %f", e->alpha / 255.0f);
+               if (bits & E_SCALE)
+                       Con_Printf(" E_SCALE %f", e->scale / 16.0f);
+               if (bits & E_COLORMAP)
+                       Con_Printf(" E_COLORMAP %i", e->colormap);
+               if (bits & E_SKIN)
+                       Con_Printf(" E_SKIN %i", e->skin);
+
+               if (bits & E_GLOWSIZE)
+                       Con_Printf(" E_GLOWSIZE %i", e->glowsize * 8);
+               if (bits & E_GLOWCOLOR)
+                       Con_Printf(" E_GLOWCOLOR %i", e->glowcolor);
+
+               if (bits & E_TAGATTACHMENT)
+                       Con_Printf(" E_TAGATTACHMENT e%i:%i", e->tagentity, e->tagindex);
+               Con_Printf("\n");
+       }
 }
 
 // (server) clears the database to contain no frames (thus delta compression compresses against nothing)
@@ -505,10 +546,8 @@ void EntityFrame_Read(entity_database_t *d)
                {
                        if (f->numentities >= MAX_ENTITY_DATABASE)
                                Host_Error("EntityFrame_Read: entity list too big\n");
-                       memcpy(f->entitydata + f->numentities, old, sizeof(entity_state_t));
-                       f->entitydata[f->numentities].time = cl.mtime[0];
-                       old++;
-                       f->numentities++;
+                       f->entitydata[f->numentities] = *old++;
+                       f->entitydata[f->numentities++].time = cl.mtime[0];
                }
                if (removed)
                {
@@ -597,7 +636,10 @@ entity_state_t *EntityFrame4_GetReferenceEntity(entity_database4_t *d, int numbe
                }
                // clear the newly created entities
                for (;oldmax < d->maxreferenceentities;oldmax++)
+               {
                        d->referenceentity[oldmax] = defaultstate;
+                       d->referenceentity[oldmax].number = oldmax;
+               }
        }
        return d->referenceentity + number;
 }
@@ -625,6 +667,7 @@ entity_database4_t *EntityFrame4_AllocDatabase(mempool_t *pool)
        d = Mem_Alloc(pool, sizeof(*d));
        d->mempool = pool;
        EntityFrame4_ResetDatabase(d);
+       d->ackframenum = -1;
        return d;
 }
 
@@ -643,44 +686,56 @@ void EntityFrame4_ResetDatabase(entity_database4_t *d)
 {
        int i;
        d->referenceframenum = -1;
-       d->ackframenum = -1;
        for (i = 0;i < MAX_ENTITY_HISTORY;i++)
                d->commit[i].numentities = 0;
+       for (i = 0;i < d->maxreferenceentities;i++)
+               d->referenceentity[i] = defaultstate;
 }
 
 void EntityFrame4_AckFrame(entity_database4_t *d, int framenum)
 {
-       int i, foundit = false;
-       entity_state_t *s;
+       int i, j;
        entity_database4_commit_t *commit;
-       // check if client is requesting no delta compression
+       // check if the peer is requesting no delta compression
        if (framenum == -1)
        {
                EntityFrame4_ResetDatabase(d);
                return;
        }
-       for (i = 0;i < MAX_ENTITY_HISTORY;i++)
+       // return early if this is already the reference frame
+       if (d->referenceframenum == framenum)
+               return;
+       // find the frame in the database
+       for (i = 0, commit = d->commit;i < MAX_ENTITY_HISTORY;i++, commit++)
+               if (commit->numentities && commit->framenum == framenum)
+                       break;
+       // check if the frame was found
+       if (i == MAX_ENTITY_HISTORY)
+       {
+               Con_Printf("EntityFrame4_AckFrame: frame %i not found in database, expect glitches!  (VERY BAD ERROR)\n", framenum);
+               d->ackframenum = -1;
+               EntityFrame4_ResetDatabase(d);
+               return;
+       }
+       // apply commit to database
+       d->referenceframenum = framenum;
+       for (j = 0;j < commit->numentities;j++)
        {
-               if (d->commit[i].numentities && d->commit[i].framenum <= framenum)
+               //*EntityFrame4_GetReferenceEntity(d, commit->entity[j].number) = commit->entity[j];
+               entity_state_t *s = EntityFrame4_GetReferenceEntity(d, commit->entity[j].number);
+               if (commit->entity[j].active != s->active)
                {
-                       if (d->commit[i].framenum == framenum)
-                       {
-                               // apply commit to database
-                               commit = d->commit + i;
-                               d->referenceframenum = commit->framenum;
-                               while (commit->numentities--)
-                               {
-                                       s = commit->entity + commit->numentities;
-                                       *EntityFrame4_GetReferenceEntity(d, s->number) = *s;
-                               }
-                               foundit = true;
-                       }
-                       d->commit[i].numentities = 0;
-                       d->commit[i].framenum = -1;
+                       if (commit->entity[j].active)
+                               Con_Printf("commit entity %i has become active (modelindex %i)\n", commit->entity[j].number, commit->entity[j].modelindex);
+                       else
+                               Con_Printf("commit entity %i has become inactive (modelindex %i)\n", commit->entity[j].number, commit->entity[j].modelindex);
                }
+               *s = commit->entity[j];
        }
-       if (!foundit)
-               Con_DPrintf("EntityFrame4_AckFrame: frame %i not found in database, expect glitches!\n", framenum);
+       // purge the now-obsolete updates
+       for (i = 0;i < MAX_ENTITY_HISTORY;i++)
+               if (d->commit[i].framenum <= framenum)
+                       d->commit[i].numentities = 0;
 }
 
 void EntityFrame4_SV_WriteFrame_Begin(entity_database4_t *d, sizebuf_t *msg, int framenum)
@@ -731,38 +786,43 @@ void EntityFrame4_SV_WriteFrame_End(entity_database4_t *d, sizebuf_t *msg)
 extern void CL_MoveLerpEntityStates(entity_t *ent);
 void EntityFrame4_CL_ReadFrame(entity_database4_t *d)
 {
-       int i, n, cnumber, referenceframenum, framenum, enumber, done, stopnumber;
-       entity_state_t *e;
+       int i, n, cnumber, referenceframenum, framenum, enumber, done, stopnumber, skip = false;
        // read the number of the frame this refers to
        referenceframenum = MSG_ReadLong();
        // read the number of this frame
        framenum = MSG_ReadLong();
        // read the start number
        enumber = MSG_ReadShort();
-       EntityFrame4_AckFrame(d, referenceframenum);
        for (i = 0;i < MAX_ENTITY_HISTORY;i++)
                if (!d->commit[i].numentities)
                        break;
        if (i < MAX_ENTITY_HISTORY)
        {
                d->currentcommit = d->commit + i;
-               d->ackframenum = d->currentcommit->framenum = framenum;
+               d->currentcommit->framenum = d->ackframenum = framenum;
                d->currentcommit->numentities = 0;
+               EntityFrame4_AckFrame(d, referenceframenum);
+               if (d->ackframenum == -1)
+               {
+                       Con_Printf("EntityFrame4_CL_ReadFrame: reference frame invalid, this update will be skipped\n");
+                       skip = true;
+               }
        }
        else
        {
-               Con_Printf("EntityFrame4_CL_ReadFrame: error while decoding frame %i: database full, resetting, expect glitches!!\n", framenum);
-               d->currentcommit = NULL;
-               EntityFrame4_ResetDatabase(d);
+               Con_Printf("EntityFrame4_CL_ReadFrame: error while decoding frame %i: database full, reading but not storing this update\n", framenum);
+               skip = true;
        }
        done = false;
        while (!done && !msg_badread)
        {
+               // read the number of the modified entity
+               // (gaps will be copied unmodified)
                n = (unsigned short)MSG_ReadShort();
                if (n == 0x8000)
                {
                        // no more entities in this update, but we still need to copy the
-                       // rest of the reference entities
+                       // rest of the reference entities (final gap)
                        done = true;
                        // read end of range number, then process normally
                        n = (unsigned short)MSG_ReadShort();
@@ -774,39 +834,58 @@ void EntityFrame4_CL_ReadFrame(entity_database4_t *d)
                // process entities in range from the last one to the changed one
                for (;enumber < stopnumber;enumber++)
                {
-                       e = EntityFrame4_GetReferenceEntity(d, enumber);
+                       if (skip)
+                       {
+                               if (enumber == cnumber && (n & 0x8000) == 0)
+                               {
+                                       entity_state_t tempstate;
+                                       EntityState_ReadUpdate(&tempstate, enumber);
+                               }
+                               continue;
+                       }
+                       // slide the current into the previous slot
                        cl_entities[enumber].state_previous = cl_entities[enumber].state_current;
-                       // skipped (unchanged), copy from reference database
-                       cl_entities[enumber].state_current = *e;
+                       // copy a new current from reference database
+                       cl_entities[enumber].state_current = *EntityFrame4_GetReferenceEntity(d, enumber);
+                       // if this is the one to modify, read more data...
                        if (enumber == cnumber)
                        {
-                               // modified
                                if (n & 0x8000)
                                {
                                        // simply removed
+                                       if (developer_networkentities.integer)
+                                               Con_Printf("entity %i: remove\n", enumber);
                                        cl_entities[enumber].state_current = defaultstate;
                                }
                                else
                                {
                                        // read the changes
+                                       if (developer_networkentities.integer)
+                                               Con_Printf("entity %i: update\n", enumber);
                                        EntityState_ReadUpdate(&cl_entities[enumber].state_current, enumber);
                                }
                        }
+                       //else if (developer_networkentities.integer)
+                       //      Con_Printf("entity %i: copy\n", enumber);
+                       // fix the number (it gets wiped occasionally by copying from defaultstate)
                        cl_entities[enumber].state_current.number = enumber;
-#if 0
-                       // debugging code
-                       if (cl_entities[enumber].state_current.active != cl_entities[enumber].state_previous.active)
+                       // check if we need to update the lerp stuff
+                       if (cl_entities[enumber].state_current.active)
                        {
-                               if (cl_entities[enumber].state_current.active)
-                                       Con_Printf("entity #%i has become active\n");
-                               else if (cl_entities[enumber].state_current.active)
-                                       Con_Printf("entity #%i has become inactive\n");
+                               CL_MoveLerpEntityStates(&cl_entities[enumber]);
+                               cl_entities_active[enumber] = true;
                        }
-#endif
-                       CL_MoveLerpEntityStates(&cl_entities[enumber]);
-                       cl_entities_active[enumber] = true;
+                       // add this to the commit entry whether it is modified or not
                        if (d->currentcommit)
                                EntityFrame4_AddCommitEntity(d, &cl_entities[enumber].state_current);
+                       // print extra messages if desired
+                       if (developer_networkentities.integer && cl_entities[enumber].state_current.active != cl_entities[enumber].state_previous.active)
+                       {
+                               if (cl_entities[enumber].state_current.active)
+                                       Con_Printf("entity #%i has become active\n", enumber);
+                               else if (cl_entities[enumber].state_previous.active)
+                                       Con_Printf("entity #%i has become inactive\n", enumber);
+                       }
                }
        }
        d->currentcommit = NULL;
index 9ec2011421bde66d3da630676deb2807529e561f..d594b03d2b49841335402b1a735ca76b95d74a97 100644 (file)
@@ -22,13 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef PROTOCOL_H
 #define PROTOCOL_H
 
-#define        PROTOCOL_VERSION 15
-#define        DPPROTOCOL_VERSION1 96
-#define        DPPROTOCOL_VERSION2 97
+#define        PROTOCOL_QUAKE 15
+#define        PROTOCOL_NEHAHRAMOVIE 250
+#define        PROTOCOL_DARKPLACES1 96
+#define        PROTOCOL_DARKPLACES2 97
 // LordHavoc: I think the 96-99 range was going to run out too soon...
 // so here I jump to 3500
-#define        DPPROTOCOL_VERSION3 3500
-#define DPPROTOCOL_VERSION4 3501
+#define        PROTOCOL_DARKPLACES3 3500
+#define PROTOCOL_DARKPLACES4 3501
 
 // model effects
 #define        EF_ROCKET       1                       // leave a trail
@@ -335,7 +336,7 @@ typedef struct
 entity_state_t;
 
 /*
-DPPROTOCOL_VERSION3
+PROTOCOL_DARKPLACES3
 server updates entities according to some (unmentioned) scheme.
 
 a frame consists of all visible entities, some of which are up to date,
@@ -367,7 +368,7 @@ if server receives ack message in put packet it performs these steps:
 */
 
 /*
-DPPROTOCOL_VERSION4
+PROTOCOL_DARKPLACES4
 a frame consists of some visible entities in a range (this is stored as start and end, note that end may be less than start if it wrapped).
 
 these entities are stored in a range (firstentity/endentity) of structs in the entitydata[] buffer.
index d849693b1694dac42daf3800b5140ef58fc7a772..df5dd14132ae9ad27cb4b2022bee9a7d76800cf2 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -258,7 +258,7 @@ void SV_SendServerinfo (client_t *client)
        MSG_WriteString (&client->message,message);
 
        MSG_WriteByte (&client->message, svc_serverinfo);
-       MSG_WriteLong (&client->message, DPPROTOCOL_VERSION4);
+       MSG_WriteLong (&client->message, PROTOCOL_DARKPLACES4);
        MSG_WriteByte (&client->message, svs.maxclients);
 
        if (!coop.integer && deathmatch.integer)
@@ -1191,7 +1191,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
        if ( ent->v->waterlevel >= 2)
                bits |= SU_INWATER;
 
-       // dpprotocol
+       // PROTOCOL_DARKPLACES
        VectorClear(punchvector);
        if ((val = GETEDICTFIELDVALUE(ent, eval_punchvector)))
                VectorCopy(val->vector, punchvector);
@@ -1214,8 +1214,8 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
        {
                if (ent->v->punchangle[i])
                        bits |= (SU_PUNCH1<<i);
-               if (punchvector[i]) // dpprotocol
-                       bits |= (SU_PUNCHVEC1<<i); // dpprotocol
+               if (punchvector[i]) // PROTOCOL_DARKPLACES
+                       bits |= (SU_PUNCHVEC1<<i); // PROTOCOL_DARKPLACES
                if (ent->v->velocity[i])
                        bits |= (SU_VELOCITY1<<i);
        }
@@ -1251,9 +1251,9 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
        for (i=0 ; i<3 ; i++)
        {
                if (bits & (SU_PUNCH1<<i))
-                       MSG_WritePreciseAngle(msg, ent->v->punchangle[i]); // dpprotocol
-               if (bits & (SU_PUNCHVEC1<<i)) // dpprotocol
-                       MSG_WriteDPCoord(msg, punchvector[i]); // dpprotocol
+                       MSG_WritePreciseAngle(msg, ent->v->punchangle[i]); // PROTOCOL_DARKPLACES
+               if (bits & (SU_PUNCHVEC1<<i)) // PROTOCOL_DARKPLACES
+                       MSG_WriteDPCoord(msg, punchvector[i]); // PROTOCOL_DARKPLACES
                if (bits & (SU_VELOCITY1<<i))
                        MSG_WriteChar (msg, ent->v->velocity[i]/16);
        }
index a0be10803d6a8cb505328caa6519b65e34c5030c..4ebdc9ee33b7ce53a7fb0894f43787d5ceebdcc9 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -623,7 +623,7 @@ void SV_ReadClientMove (usercmd_t *move)
                val->_float = host_client->ping * 1000.0;
 
        // read current angles
-       // DPPROTOCOL_VERSION4
+       // PROTOCOL_DARKPLACES4
        for (i = 0;i < 3;i++)
                angle[i] = MSG_ReadPreciseAngle();
 
@@ -743,10 +743,7 @@ void SV_ReadClientMessage(void)
                        break;
 
                case clc_ackentities:
-                       //if (dpprotocol == DPPROTOCOL_VERSION1 || dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3)
-                       //      EntityFrame_AckFrame(&host_client->entitydatabase, MSG_ReadLong());
-                       //else
-                               EntityFrame4_AckFrame(host_client->entitydatabase4, MSG_ReadLong());
+                       EntityFrame4_AckFrame(host_client->entitydatabase4, host_client->entitydatabase4->ackframenum = MSG_ReadLong());
                        break;
                }
        }