]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
made quakec stuffed quake1 protocol entities work alongside newer protocols, to attem...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 21 Sep 2004 09:34:06 +0000 (09:34 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 21 Sep 2004 09:34:06 +0000 (09:34 +0000)
also fixed separator positioning in Com_HexDumpToConsole (used for packet dumps)

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

cl_parse.c
common.c
common.h
host_cmd.c
pr_cmds.c
protocol.c
prvm_cmds.c
sv_main.c

index e180f6f3d471bfe8286a264f81b488a81f76ce5e..8eed400f497d784cbbd83bc7db4589b02d45e6ad 100644 (file)
@@ -339,6 +339,7 @@ void CL_ParseServerInfo (void)
                return;
        }
        cl.protocol = i;
+       Con_DPrintf("Protocol %i\n", cl.protocol);
 
 // parse maxclients
        cl.maxclients = MSG_ReadByte ();
@@ -574,7 +575,7 @@ void CL_ParseBaseline (entity_t *ent, int large)
        for (i = 0;i < 3;i++)
        {
                ent->state_baseline.origin[i] = MSG_ReadCoord(cl.protocol);
-               ent->state_baseline.angles[i] = MSG_ReadAngle8i();
+               ent->state_baseline.angles[i] = MSG_ReadAngle(cl.protocol);
        }
        CL_ValidateState(&ent->state_baseline);
        ent->state_previous = ent->state_current = ent->state_baseline;
@@ -1290,7 +1291,7 @@ int parsingerror = false;
 void CL_ParseServerMessage(void)
 {
        int                     cmd;
-       int                     i, entitiesupdated;
+       int                     i;
        qbyte           cmdlog[32];
        char            *cmdlogname[32], *temp;
        int                     cmdindex, cmdcount = 0;
@@ -1314,8 +1315,6 @@ void CL_ParseServerMessage(void)
 //
        //MSG_BeginReading ();
 
-       entitiesupdated = false;
-
        parsingerror = true;
 
        while (1)
@@ -1338,7 +1337,6 @@ void CL_ParseServerMessage(void)
                // if the high bit of the command byte is set, it is a fast update
                if (cmd & 128)
                {
-                       entitiesupdated = true;
                        // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
                        temp = "entity";
                        cmdlogname[cmdindex] = temp;
@@ -1444,12 +1442,7 @@ void CL_ParseServerMessage(void)
 
                case svc_setangle:
                        for (i=0 ; i<3 ; i++)
-                       {
-                               if (cl.protocol == PROTOCOL_DARKPLACES5)
-                                       cl.viewangles[i] = MSG_ReadAngle16i ();
-                               else
-                                       cl.viewangles[i] = MSG_ReadAngle8i ();
-                       }
+                               cl.viewangles[i] = MSG_ReadAngle (cl.protocol);
                        break;
 
                case svc_setview:
@@ -1668,8 +1661,7 @@ void CL_ParseServerMessage(void)
                }
        }
 
-       if (entitiesupdated)
-               EntityFrameQuake_ISeeDeadEntities();
+       EntityFrameQuake_ISeeDeadEntities();
 
        parsingerror = false;
 }
index 6ec9282a00ed6a0c2ba648320d8acb704cb0b63c..5c72b72f1dcbe51fe3b99574b9317234af0372ec 100644 (file)
--- a/common.c
+++ b/common.c
@@ -252,6 +252,13 @@ void MSG_WriteAngle32f (sizebuf_t *sb, float f)
        MSG_WriteFloat (sb, f);
 }
 
+void MSG_WriteAngle (sizebuf_t *sb, float f, int protocol)
+{
+       if (protocol == PROTOCOL_DARKPLACES5)
+               MSG_WriteAngle16i (sb, f);
+       else
+               MSG_WriteAngle8i (sb, f);
+}
 
 //
 // reading functions
@@ -403,7 +410,7 @@ float MSG_ReadAngle8i (void)
 
 float MSG_ReadAngle16i (void)
 {
-       return MSG_ReadShort () * (360.0/65536.0);
+       return (unsigned short)MSG_ReadShort () * (360.0/65536.0);
 }
 
 float MSG_ReadAngle32f (void)
@@ -411,6 +418,14 @@ float MSG_ReadAngle32f (void)
        return MSG_ReadFloat ();
 }
 
+float MSG_ReadAngle (int protocol)
+{
+       if (protocol == PROTOCOL_DARKPLACES5)
+               return MSG_ReadAngle16i ();
+       else
+               return MSG_ReadAngle8i ();
+}
+
 
 //===========================================================================
 
@@ -504,7 +519,7 @@ void Com_HexDumpToConsole(const qbyte *data, int size)
                                *cur++ = ' ';
                                *cur++ = ' ';
                        }
-                       if ((j & 3) == 0)
+                       if ((j & 3) == 3)
                                *cur++ = ' ';
                }
                // print text
index b6272a80bb5fac9b55ea6f38ae648972861b6031..f367ef66f705dae53b8894e93ca31a2e595084d6 100644 (file)
--- a/common.h
+++ b/common.h
@@ -123,6 +123,7 @@ void MSG_WriteCoord16i (sizebuf_t *sb, float f);
 void MSG_WriteCoord32f (sizebuf_t *sb, float f);
 void MSG_WriteCoord (sizebuf_t *sb, float f, int protocol);
 void MSG_WriteVector (sizebuf_t *sb, float *v, int protocol);
+void MSG_WriteAngle (sizebuf_t *sb, float f, int protocol);
 
 extern int                     msg_readcount;
 extern qboolean        msg_badread;            // set if a read goes beyond end of message
@@ -151,6 +152,7 @@ float MSG_ReadCoord16i (void);
 float MSG_ReadCoord32f (void);
 float MSG_ReadCoord (int protocol);
 void MSG_ReadVector (float *v, int protocol);
+float MSG_ReadAngle (int protocol);
 
 //============================================================================
 
index bdae5cf8227d10202e48b1cf481cc164f8c58f38..0bb621fdbab799bdd55789e14c020d34662787e9 100644 (file)
@@ -1216,18 +1216,9 @@ void Host_Spawn_f (void)
        // and it won't happen if the game was just loaded, so you wind up
        // with a permanent head tilt
        MSG_WriteByte (&host_client->message, svc_setangle);
-       if (sv.protocol == PROTOCOL_DARKPLACES5)
-       {
-               MSG_WriteAngle16i (&host_client->message, sv_player->v->angles[0]);
-               MSG_WriteAngle16i (&host_client->message, sv_player->v->angles[1]);
-               MSG_WriteAngle16i (&host_client->message, 0);
-       }
-       else
-       {
-               MSG_WriteAngle8i (&host_client->message, sv_player->v->angles[0]);
-               MSG_WriteAngle8i (&host_client->message, sv_player->v->angles[1]);
-               MSG_WriteAngle8i (&host_client->message, 0);
-       }
+       MSG_WriteAngle (&host_client->message, sv_player->v->angles[0], sv.protocol);
+       MSG_WriteAngle (&host_client->message, sv_player->v->angles[1], sv.protocol);
+       MSG_WriteAngle (&host_client->message, 0, sv.protocol);
 
        SV_WriteClientdataToMessage (sv_player, &host_client->message);
 
index 930a88d5c7098cf0020bf295e0f8550c95ee3d76..8bdb8f0f5e3407723d333b1be9c2444b6790f3b7 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -1874,10 +1874,7 @@ void PF_WriteLong (void)
 
 void PF_WriteAngle (void)
 {
-       if (sv.protocol == PROTOCOL_DARKPLACES5)
-               MSG_WriteAngle16i (WriteDest(), G_FLOAT(OFS_PARM1));
-       else
-               MSG_WriteAngle8i (WriteDest(), G_FLOAT(OFS_PARM1));
+       MSG_WriteAngle (WriteDest(), G_FLOAT(OFS_PARM1), sv.protocol);
 }
 
 void PF_WriteCoord (void)
@@ -1931,7 +1928,7 @@ void PF_makestatic (void)
        for (i=0 ; i<3 ; i++)
        {
                MSG_WriteCoord(&sv.signon, ent->v->origin[i], sv.protocol);
-               MSG_WriteAngle8i(&sv.signon, ent->v->angles[i]);
+               MSG_WriteAngle(&sv.signon, ent->v->angles[i], sv.protocol);
        }
 
 // throw the entity away now
index 0fe0cc0e9528b503535abae03bbcf55b4f7b29ef..f897d2193f79680e24be8bab07d11da38c73d83d 100644 (file)
@@ -35,7 +35,9 @@ entity_state_t defaultstate =
        {0,0,0,0}//unsigned char unused[4]; // !
 };
 
-double entityframequake_mtime = 0;
+// keep track of quake entities because they need to be killed if they get stale
+int cl_lastquakeentity = 0;
+qbyte cl_isquakeentity[MAX_EDICTS];
 
 void EntityFrameQuake_ReadEntity(int bits)
 {
@@ -43,8 +45,6 @@ void EntityFrameQuake_ReadEntity(int bits)
        entity_t *ent;
        entity_state_t s;
 
-       entityframequake_mtime = cl.mtime[0];
-
        if (bits & U_MOREBITS)
                bits |= (MSG_ReadByte()<<8);
        if ((bits & U_EXTEND1) && cl.protocol != PROTOCOL_NEHAHRAMOVIE)
@@ -77,6 +77,9 @@ void EntityFrameQuake_ReadEntity(int bits)
                s.active = true;
        }
 
+       cl_isquakeentity[num] = true;
+       if (cl_lastquakeentity < num)
+               cl_lastquakeentity = num;
        s.number = num;
        s.time = cl.mtime[0];
        s.flags = 0;
@@ -85,12 +88,12 @@ void EntityFrameQuake_ReadEntity(int bits)
        if (bits & U_COLORMAP)  s.colormap = MSG_ReadByte();
        if (bits & U_SKIN)              s.skin = MSG_ReadByte();
        if (bits & U_EFFECTS)   s.effects = (s.effects & 0xFF00) | MSG_ReadByte();
-       if (bits & U_ORIGIN1)   s.origin[0] = MSG_ReadCoord13i();
-       if (bits & U_ANGLE1)    s.angles[0] = MSG_ReadAngle8i();
-       if (bits & U_ORIGIN2)   s.origin[1] = MSG_ReadCoord13i();
-       if (bits & U_ANGLE2)    s.angles[1] = MSG_ReadAngle8i();
-       if (bits & U_ORIGIN3)   s.origin[2] = MSG_ReadCoord13i();
-       if (bits & U_ANGLE3)    s.angles[2] = MSG_ReadAngle8i();
+       if (bits & U_ORIGIN1)   s.origin[0] = MSG_ReadCoord(cl.protocol);
+       if (bits & U_ANGLE1)    s.angles[0] = MSG_ReadAngle(cl.protocol);
+       if (bits & U_ORIGIN2)   s.origin[1] = MSG_ReadCoord(cl.protocol);
+       if (bits & U_ANGLE2)    s.angles[1] = MSG_ReadAngle(cl.protocol);
+       if (bits & U_ORIGIN3)   s.origin[2] = MSG_ReadCoord(cl.protocol);
+       if (bits & U_ANGLE3)    s.angles[2] = MSG_ReadAngle(cl.protocol);
        if (bits & U_STEP)              s.flags |= RENDER_STEP;
        if (bits & U_ALPHA)             s.alpha = MSG_ReadByte();
        if (bits & U_SCALE)             s.scale = MSG_ReadByte();
@@ -138,14 +141,31 @@ void EntityFrameQuake_ReadEntity(int bits)
 
 void EntityFrameQuake_ISeeDeadEntities(void)
 {
-       int i;
-       for (i = 0;i < cl_max_entities;i++)
+       int num, lastentity;
+       if (cl_lastquakeentity == 0)
+               return;
+       lastentity = cl_lastquakeentity;
+       cl_lastquakeentity = 0;
+       for (num = 0;num < lastentity;num++)
        {
-               if (cl_entities_active[i] && cl_entities[i].state_current.time != cl.mtime[0])
+               if (cl_isquakeentity[num])
                {
-                       cl_entities_active[i] = false;
-                       cl_entities[i].state_current = defaultstate;
-                       cl_entities[i].state_current.number = i;
+                       cl_isquakeentity[num] = false;
+                       if (cl_entities_active[num])
+                       {
+                               if (cl_entities[num].state_current.time == cl.mtime[0])
+                               {
+                                       cl_isquakeentity[num] = true;
+                                       cl_lastquakeentity = num;
+                               }
+                               else
+                               {
+                                       cl_isquakeentity[num] = false;
+                                       cl_entities_active[num] = false;
+                                       cl_entities[num].state_current = defaultstate;
+                                       cl_entities[num].state_current.number = num;
+                               }
+                       }
                }
        }
 }
@@ -251,12 +271,12 @@ void EntityFrameQuake_WriteFrame(sizebuf_t *msg, int numstates, const entity_sta
                if (bits & U_COLORMAP)          MSG_WriteByte(&buf, s->colormap);
                if (bits & U_SKIN)                      MSG_WriteByte(&buf, s->skin);
                if (bits & U_EFFECTS)           MSG_WriteByte(&buf, s->effects);
-               if (bits & U_ORIGIN1)           MSG_WriteCoord13i(&buf, s->origin[0]);
-               if (bits & U_ANGLE1)            MSG_WriteAngle8i(&buf, s->angles[0]);
-               if (bits & U_ORIGIN2)           MSG_WriteCoord13i(&buf, s->origin[1]);
-               if (bits & U_ANGLE2)            MSG_WriteAngle8i(&buf, s->angles[1]);
-               if (bits & U_ORIGIN3)           MSG_WriteCoord13i(&buf, s->origin[2]);
-               if (bits & U_ANGLE3)            MSG_WriteAngle8i(&buf, s->angles[2]);
+               if (bits & U_ORIGIN1)           MSG_WriteCoord(&buf, s->origin[0], sv.protocol);
+               if (bits & U_ANGLE1)            MSG_WriteAngle(&buf, s->angles[0], sv.protocol);
+               if (bits & U_ORIGIN2)           MSG_WriteCoord(&buf, s->origin[1], sv.protocol);
+               if (bits & U_ANGLE2)            MSG_WriteAngle(&buf, s->angles[1], sv.protocol);
+               if (bits & U_ORIGIN3)           MSG_WriteCoord(&buf, s->origin[2], sv.protocol);
+               if (bits & U_ANGLE3)            MSG_WriteAngle(&buf, s->angles[2], sv.protocol);
                if (bits & U_ALPHA)                     MSG_WriteByte(&buf, s->alpha);
                if (bits & U_SCALE)                     MSG_WriteByte(&buf, s->scale);
                if (bits & U_EFFECTS2)          MSG_WriteByte(&buf, s->effects >> 8);
index 79fee2a84ed707e3f62e93a9b69c3ddaba2b535f..0a6acf871d01aad6796c392aa31776f2ed3db7f2 100644 (file)
@@ -1356,7 +1356,7 @@ void VM_WriteLong (void)
 
 void VM_WriteAngle (void)
 {
-       MSG_WriteAngle16i (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0));
+       MSG_WriteAngle (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
 }
 
 void VM_WriteCoord (void)
index 7aa15301af324b6d5e6c3f954dcde629bb2e0fc0..591884d8e00a7531938c3bf0bcf29afd9ed4850a 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -730,12 +730,12 @@ void SV_WriteEntitiesToClient_QUAKE (client_t *client, edict_t *clent, sizebuf_t
                if (bits & U_COLORMAP)  MSG_WriteByte(msg, ent->v->colormap);
                if (bits & U_SKIN)              MSG_WriteByte(msg, ent->v->skin);
                if (bits & U_EFFECTS)   MSG_WriteByte(msg, ent->v->effects);
-               if (bits & U_ORIGIN1)   MSG_WriteCoord13i(msg, origin[0]);
-               if (bits & U_ANGLE1)    MSG_WriteAngle8i(msg, angles[0]);
-               if (bits & U_ORIGIN2)   MSG_WriteCoord13i(msg, origin[1]);
-               if (bits & U_ANGLE2)    MSG_WriteAngle8i(msg, angles[1]);
-               if (bits & U_ORIGIN3)   MSG_WriteCoord13i(msg, origin[2]);
-               if (bits & U_ANGLE3)    MSG_WriteAngle8i(msg, angles[2]);
+               if (bits & U_ORIGIN1)   MSG_WriteCoord(msg, origin[0], sv.protocol);
+               if (bits & U_ANGLE1)    MSG_WriteAngle(msg, angles[0], sv.protocol);
+               if (bits & U_ORIGIN2)   MSG_WriteCoord(msg, origin[1], sv.protocol);
+               if (bits & U_ANGLE2)    MSG_WriteAngle(msg, angles[1], sv.protocol);
+               if (bits & U_ORIGIN3)   MSG_WriteCoord(msg, origin[2], sv.protocol);
+               if (bits & U_ANGLE3)    MSG_WriteAngle(msg, angles[2], sv.protocol);
 
                // LordHavoc: new stuff
                if (bits & U_ALPHA)             MSG_WriteByte(msg, alpha);
@@ -1320,12 +1320,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
        {
                MSG_WriteByte (msg, svc_setangle);
                for (i=0 ; i < 3 ; i++)
-               {
-                       if (sv.protocol == PROTOCOL_DARKPLACES5)
-                               MSG_WriteAngle16i (msg, ent->v->angles[i] );
-                       else
-                               MSG_WriteAngle8i (msg, ent->v->angles[i] );
-               }
+                       MSG_WriteAngle (msg, ent->v->angles[i], sv.protocol);
                ent->v->fixangle = 0;
        }
 
@@ -1880,7 +1875,7 @@ void SV_CreateBaseline (void)
                for (i=0 ; i<3 ; i++)
                {
                        MSG_WriteCoord(&sv.signon, svent->e->baseline.origin[i], sv.protocol);
-                       MSG_WriteAngle8i(&sv.signon, svent->e->baseline.angles[i]);
+                       MSG_WriteAngle(&sv.signon, svent->e->baseline.angles[i], sv.protocol);
                }
        }
 }