]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - protocol.c
more cleaning of matrix4x4_t struct access
[xonotic/darkplaces.git] / protocol.c
index 3899b23e7277fe498448cffd79026d4a12f1671b..f3882c4f275fa30898ea3a9240bf11c379c70680 100644 (file)
@@ -194,11 +194,11 @@ void EntityFrameQuake_ReadEntity(int bits)
        if (cls.protocol == PROTOCOL_NEHAHRAMOVIE && (bits & U_EXTEND1))
        {
                // LordHavoc: evil format
-               int i = MSG_ReadFloat();
-               int j = MSG_ReadFloat() * 255.0f;
+               int i = (int)MSG_ReadFloat();
+               int j = (int)(MSG_ReadFloat() * 255.0f);
                if (i == 2)
                {
-                       i = MSG_ReadFloat();
+                       i = (int)MSG_ReadFloat();
                        if (i)
                                s.effects |= EF_FULLBRIGHT;
                }
@@ -268,7 +268,7 @@ void EntityFrameCSQC_InitClientVersions (int client, qboolean clear)
                Mem_Free(sv2csqcents_version[client]);
                sv2csqcents_version[client] = NULL;
        }
-       sv2csqcents_version[client] = Mem_Alloc(sv2csqc, MAX_EDICTS);
+       sv2csqcents_version[client] = (unsigned char *)Mem_Alloc(sv2csqc, MAX_EDICTS);
        memset(sv2csqcents_version[client], 0, MAX_EDICTS);
 }
 
@@ -1087,7 +1087,7 @@ void EntityFrame_CL_ReadFrame(void)
        entity_t *ent;
        entityframe_database_t *d;
        if (!cl.entitydatabase)
-               cl.entitydatabase = EntityFrame_AllocDatabase(cls.mempool);
+               cl.entitydatabase = EntityFrame_AllocDatabase(cls.levelmempool);
        d = cl.entitydatabase;
 
        EntityFrame_Clear(f, NULL, -1);
@@ -1357,7 +1357,7 @@ void EntityFrame4_CL_ReadFrame(void)
        entity_state_t *s;
        entityframe4_database_t *d;
        if (!cl.entitydatabase4)
-               cl.entitydatabase4 = EntityFrame4_AllocDatabase(cls.mempool);
+               cl.entitydatabase4 = EntityFrame4_AllocDatabase(cls.levelmempool);
        d = cl.entitydatabase4;
        // read the number of the frame this refers to
        referenceframenum = MSG_ReadLong();
@@ -2470,6 +2470,9 @@ void EntityStateQW_ReadPlayerUpdate(void)
        // if this is an update on our player, update interpolation state
        if (enumber == cl.playerentity)
        {
+               // force a recalculation of the player prediction
+               cl.movement_replay = true;
+
                VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
                VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
                VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
@@ -2594,10 +2597,16 @@ void EntityFrameQW_CL_ReadFrame(qboolean delta)
        entityframeqw_snapshot_t *oldsnap, *newsnap;
 
        if (!cl.entitydatabaseqw)
-               cl.entitydatabaseqw = EntityFrameQW_AllocDatabase(cls.mempool);
+               cl.entitydatabaseqw = EntityFrameQW_AllocDatabase(cls.levelmempool);
        d = cl.entitydatabaseqw;
 
-       newsnapindex = cls.netcon->qw.incoming_sequence & QW_UPDATE_MASK;
+       // there is no cls.netcon in demos, so this reading code can't access
+       // cls.netcon-> at all...  so cls.qw_incoming_sequence and
+       // cls.qw_outgoing_sequence are updated every time the corresponding
+       // cls.netcon->qw. variables are updated
+       // read the number of this frame to echo back in next input packet
+       cl.qw_validsequence = cls.qw_incoming_sequence;
+       newsnapindex = cl.qw_validsequence & QW_UPDATE_MASK;
        newsnap = d->snapshot + newsnapindex;
        memset(newsnap, 0, sizeof(*newsnap));
        oldsnapindex = -1;
@@ -2610,7 +2619,7 @@ void EntityFrameQW_CL_ReadFrame(qboolean delta)
                        Con_DPrintf("WARNING: from mismatch\n");
                if (oldsnapindex != -1)
                {
-                       if (cls.netcon->qw.outgoing_sequence - oldsnapindex >= QW_UPDATE_BACKUP-1)
+                       if (cls.qw_outgoing_sequence - oldsnapindex >= QW_UPDATE_BACKUP-1)
                        {
                                Con_DPrintf("delta update too old\n");
                                newsnap->invalid = invalid = true; // too old
@@ -2622,8 +2631,7 @@ void EntityFrameQW_CL_ReadFrame(qboolean delta)
                        delta = false;
        }
 
-       // read the number of this frame to echo back in next input packet
-       cl.qw_validsequence = cls.netcon->qw.incoming_sequence;
+       // if we can't decode this frame properly, report that to the server
        if (invalid)
                cl.qw_validsequence = 0;