upgraded network protocol to DP5, now sends precise entity angles (except for EF_LOWP...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 1 Mar 2004 03:49:14 +0000 (03:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 1 Mar 2004 03:49:14 +0000 (03:49 +0000)
)

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

cl_input.c
cl_parse.c
cl_particles.c
common.c
common.h
protocol.c
protocol.h
sv_main.c
todo
view.c

index 2948b61..c3fef75 100644 (file)
@@ -390,7 +390,7 @@ void CL_SendMove(usercmd_t *cmd)
                for (i = 0;i < 3;i++)
                        MSG_WriteFloat (&buf, cl.viewangles[i]);
        }
-       else if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES4)
+       else if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES4 || cl.protocol == PROTOCOL_DARKPLACES5)
        {
                for (i=0 ; i<3 ; i++)
                        MSG_WritePreciseAngle (&buf, cl.viewangles[i]);
index 04879f6..e3d70dd 100644 (file)
@@ -151,8 +151,7 @@ void CL_ParseStartSoundPacket(int largesoundindex)
        if (ent >= MAX_EDICTS)
                Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent);
 
-       for (i = 0;i < 3;i++)
-               pos[i] = MSG_ReadCoord ();
+       MSG_ReadVector(pos);
 
        S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
 }
@@ -335,9 +334,9 @@ void CL_ParseServerInfo (void)
        // 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)
+       if (i != PROTOCOL_QUAKE && i != PROTOCOL_DARKPLACES1 && i != PROTOCOL_DARKPLACES2 && i != PROTOCOL_DARKPLACES3 && i != PROTOCOL_DARKPLACES4 && i != PROTOCOL_DARKPLACES5 && i != PROTOCOL_NEHAHRAMOVIE)
        {
-               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);
+               Host_Error("CL_ParseServerInfo: Server is protocol %i, not %i (Quake), %i (DP1), %i (DP2), %i (DP3), %i (DP4), %i (DP5), or %i (Nehahra movie)", i, PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_DARKPLACES5, PROTOCOL_NEHAHRAMOVIE);
                return;
        }
        cl.protocol = i;
@@ -765,25 +764,46 @@ void CL_ParseClientdata (int bits)
                cl.idealpitch = 0;
 
        VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
-       for (i=0 ; i<3 ; i++)
+       if (cl.protocol == PROTOCOL_DARKPLACES5)
        {
-               if (bits & (SU_PUNCH1<<i) )
+               for (i = 0;i < 3;i++)
                {
-                       if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4)
+                       if (bits & (SU_PUNCH1<<i) )
                                cl.punchangle[i] = MSG_ReadPreciseAngle();
                        else
-                               cl.punchangle[i] = MSG_ReadChar();
+                               cl.punchangle[i] = 0;
+                       if (bits & (SU_PUNCHVEC1<<i))
+                               cl.punchvector[i] = MSG_ReadFloat();
+                       else
+                               cl.punchvector[i] = 0;
+                       if (bits & (SU_VELOCITY1<<i) )
+                               cl.mvelocity[0][i] = MSG_ReadFloat();
+                       else
+                               cl.mvelocity[0][i] = 0;
+               }
+       }
+       else
+       {
+               for (i = 0;i < 3;i++)
+               {
+                       if (bits & (SU_PUNCH1<<i) )
+                       {
+                               if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4 || cl.protocol == PROTOCOL_DARKPLACES5)
+                                       cl.punchangle[i] = MSG_ReadPreciseAngle();
+                               else
+                                       cl.punchangle[i] = MSG_ReadChar();
+                       }
+                       else
+                               cl.punchangle[i] = 0;
+                       if (bits & (SU_PUNCHVEC1<<i))
+                               cl.punchvector[i] = MSG_ReadCoord();
+                       else
+                               cl.punchvector[i] = 0;
+                       if (bits & (SU_VELOCITY1<<i) )
+                               cl.mvelocity[0][i] = MSG_ReadChar()*16;
+                       else
+                               cl.mvelocity[0][i] = 0;
                }
-               else
-                       cl.punchangle[i] = 0;
-               if (bits & (SU_PUNCHVEC1<<i))
-                       cl.punchvector[i] = MSG_ReadCoord();
-               else
-                       cl.punchvector[i] = 0;
-               if (bits & (SU_VELOCITY1<<i) )
-                       cl.mvelocity[0][i] = MSG_ReadChar()*16;
-               else
-                       cl.mvelocity[0][i] = 0;
        }
 
        i = MSG_ReadLong ();
@@ -1320,16 +1340,12 @@ void CL_ParseTempEntity(void)
                break;
 
        case TE_LAVASPLASH:
-               pos[0] = MSG_ReadCoord();
-               pos[1] = MSG_ReadCoord();
-               pos[2] = MSG_ReadCoord();
+               MSG_ReadVector(pos);
                CL_LavaSplash(pos);
                break;
 
        case TE_TELEPORT:
-               pos[0] = MSG_ReadCoord();
-               pos[1] = MSG_ReadCoord();
-               pos[2] = MSG_ReadCoord();
+               MSG_ReadVector(pos);
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 500, 1.0f, 1.0f, 1.0f, 1500, 99.0f, 0, 0, true, 1);
 //             CL_TeleportSplash(pos);
@@ -1526,8 +1542,8 @@ void CL_ParseServerMessage(void)
                        // 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);
+                       if (i != PROTOCOL_QUAKE && i != PROTOCOL_DARKPLACES1 && i != PROTOCOL_DARKPLACES2 && i != PROTOCOL_DARKPLACES3 && i != PROTOCOL_DARKPLACES4 && i != PROTOCOL_DARKPLACES5 && i != PROTOCOL_NEHAHRAMOVIE)
+                               Host_Error("CL_ParseServerMessage: Server is protocol %i, not %i (Quake), %i (DP1), %i (DP2), %i (DP3), %i (DP4), %i (DP5), or %i (Nehahra movie)", i, PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_DARKPLACES5, PROTOCOL_NEHAHRAMOVIE);
                        cl.protocol = i;
                        break;
 
index b9d73f7..1b0d3ed 100644 (file)
@@ -603,8 +603,7 @@ void CL_ParseParticleEffect (void)
        vec3_t org, dir;
        int i, count, msgcount, color;
 
-       for (i=0 ; i<3 ; i++)
-               org[i] = MSG_ReadCoord ();
+       MSG_ReadVector(org);
        for (i=0 ; i<3 ; i++)
                dir[i] = MSG_ReadChar () * (1.0/16);
        msgcount = MSG_ReadByte ();
index 43db21a..a1f1b40 100644 (file)
--- a/common.c
+++ b/common.c
@@ -353,16 +353,10 @@ int MSG_ReadBytes (int numbytes, unsigned char *out)
        return l;
 }
 
-// used by server (always latest PROTOCOL_DARKPLACES)
-float MSG_ReadDPCoord (void)
-{
-       return (signed short) MSG_ReadLittleShort();
-}
-
 // used by client
 float MSG_ReadCoord (void)
 {
-       if (cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4)
+       if (cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4 || cl.protocol == PROTOCOL_DARKPLACES5)
                return (signed short) MSG_ReadLittleShort();
        else if (cl.protocol == PROTOCOL_DARKPLACES1)
                return MSG_ReadLittleFloat();
index 62796b3..150f313 100644 (file)
--- a/common.h
+++ b/common.h
@@ -131,12 +131,10 @@ int MSG_ReadBytes (int numbytes, unsigned char *out);
 
 float MSG_ReadCoord (void);
 
-float MSG_ReadDPCoord (void);
-
 #define MSG_ReadAngle() (MSG_ReadByte() * (360.0f / 256.0f))
 #define MSG_ReadPreciseAngle() (MSG_ReadShort() * (360.0f / 65536.0f))
 
-#define MSG_ReadVector(v) {(v)[0] = MSG_ReadCoord();(v)[1] = MSG_ReadCoord();(v)[2] = MSG_ReadCoord();}
+#define MSG_ReadVector(v) ((v)[0] = MSG_ReadCoord(), (v)[1] = MSG_ReadCoord(), (v)[2] = MSG_ReadCoord())
 
 //============================================================================
 
index 0ded4ed..87a1816 100644 (file)
@@ -163,6 +163,12 @@ void EntityState_Write(entity_state_t *ent, sizebuf_t *msg, entity_state_t *delt
                                        MSG_WriteShort(msg, org[1]);
                                if (bits & E_ORIGIN3)
                                        MSG_WriteShort(msg, org[2]);
+                               if (bits & E_ANGLE1)
+                                       MSG_WriteAngle(msg, ent->angles[0]);
+                               if (bits & E_ANGLE2)
+                                       MSG_WriteAngle(msg, ent->angles[1]);
+                               if (bits & E_ANGLE3)
+                                       MSG_WriteAngle(msg, ent->angles[2]);
                        }
                        else
                        {
@@ -172,13 +178,13 @@ void EntityState_Write(entity_state_t *ent, sizebuf_t *msg, entity_state_t *delt
                                        MSG_WriteFloat(msg, org[1]);
                                if (bits & E_ORIGIN3)
                                        MSG_WriteFloat(msg, org[2]);
+                               if (bits & E_ANGLE1)
+                                       MSG_WritePreciseAngle(msg, ent->angles[0]);
+                               if (bits & E_ANGLE2)
+                                       MSG_WritePreciseAngle(msg, ent->angles[1]);
+                               if (bits & E_ANGLE3)
+                                       MSG_WritePreciseAngle(msg, ent->angles[2]);
                        }
-                       if (bits & E_ANGLE1)
-                               MSG_WriteAngle(msg, ent->angles[0]);
-                       if (bits & E_ANGLE2)
-                               MSG_WriteAngle(msg, ent->angles[1]);
-                       if (bits & E_ANGLE3)
-                               MSG_WriteAngle(msg, ent->angles[2]);
                        if (bits & E_MODEL1)
                                MSG_WriteByte(msg, ent->modelindex & 0xFF);
                        if (bits & E_MODEL2)
@@ -277,12 +283,24 @@ void EntityState_ReadUpdate(entity_state_t *e, int number)
                                e->origin[2] = MSG_ReadFloat();
                }
        }
-       if (bits & E_ANGLE1)
-               e->angles[0] = MSG_ReadAngle();
-       if (bits & E_ANGLE2)
-               e->angles[1] = MSG_ReadAngle();
-       if (bits & E_ANGLE3)
-               e->angles[2] = MSG_ReadAngle();
+       if (cl.protocol == PROTOCOL_DARKPLACES5 && !(e->flags & RENDER_LOWPRECISION))
+       {
+               if (bits & E_ANGLE1)
+                       e->angles[0] = MSG_ReadPreciseAngle();
+               if (bits & E_ANGLE2)
+                       e->angles[1] = MSG_ReadPreciseAngle();
+               if (bits & E_ANGLE3)
+                       e->angles[2] = MSG_ReadPreciseAngle();
+       }
+       else
+       {
+               if (bits & E_ANGLE1)
+                       e->angles[0] = MSG_ReadAngle();
+               if (bits & E_ANGLE2)
+                       e->angles[1] = MSG_ReadAngle();
+               if (bits & E_ANGLE3)
+                       e->angles[2] = MSG_ReadAngle();
+       }
        if (bits & E_MODEL1)
                e->modelindex = (e->modelindex & 0xFF00) | (unsigned int) MSG_ReadByte();
        if (bits & E_MODEL2)
index 4d140b4..717d991 100644 (file)
@@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // so here I jump to 3500
 #define        PROTOCOL_DARKPLACES3 3500
 #define PROTOCOL_DARKPLACES4 3501
+#define PROTOCOL_DARKPLACES5 3502
 
 // model effects
 #define        EF_ROCKET       1                       // leave a trail
index d695f3b..71b5719 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -272,7 +272,7 @@ void SV_SendServerinfo (client_t *client)
        MSG_WriteString (&client->message,message);
 
        MSG_WriteByte (&client->message, svc_serverinfo);
-       MSG_WriteLong (&client->message, PROTOCOL_DARKPLACES4);
+       MSG_WriteLong (&client->message, PROTOCOL_DARKPLACES5);
        MSG_WriteByte (&client->message, svs.maxclients);
 
        if (!coop.integer && deathmatch.integer)
@@ -1295,9 +1295,9 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
                if (bits & (SU_PUNCH1<<i))
                        MSG_WritePreciseAngle(msg, ent->v->punchangle[i]); // PROTOCOL_DARKPLACES
                if (bits & (SU_PUNCHVEC1<<i)) // PROTOCOL_DARKPLACES
-                       MSG_WriteDPCoord(msg, punchvector[i]); // PROTOCOL_DARKPLACES
+                       MSG_WriteFloat(msg, punchvector[i]); // PROTOCOL_DARKPLACES
                if (bits & (SU_VELOCITY1<<i))
-                       MSG_WriteChar (msg, ent->v->velocity[i]/16);
+                       MSG_WriteFloat(msg, ent->v->velocity[i]);
        }
 
 // [always sent]       if (bits & SU_ITEMS)
diff --git a/todo b/todo
index bf15b68..27e946d 100644 (file)
--- a/todo
+++ b/todo
 -n darkplaces: segfault reading memory in windows when starting a new server from menu (yummyluv)
 -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv)
 -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv)
+0 darkplaces: fix view blends, they're not working
 d darkplaces: fixed SV_TouchAreaGrid to not crash if SV_IncreaseEdicts is called during a touch function, by making a list of edicts to touch and then running through the list afterward (KGB|romi)
 d darkplaces: moved R_ShadowVolumeLighting to r_shadow.c
 d darkplaces: added RENDER_LIGHT flag to entity_render_t to make rtlighting optional per entity
 d darkplaces: cleaned up rtlight handling, merging most code between world rtlights and dlights
 d darkplaces: safety checked lightmap access in Mod_Q1BSP_RecursiveLightPoint as one map Sajt uses was crashing (Sajt)
-0 darkplaces: upgrade network protocol to send precise angles, and make EF_LOWPRECISION downgrade both origin and angles (Urre)
+-n darkplaces: upgrade network protocol to send precise angles, and make EF_LOWPRECISION downgrade both origin and angles (Urre, Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt)
 0 darkplaces: figure out why cubemap upload scaling crashes (Urre)
 0 darkplaces: make screenshots save to screenshots/fniggium%04i.tga in GAME_FNIGGIUM (Sajt)
 0 darkplaces: make screenshots save to screenshots directory (Sajt)
@@ -295,7 +296,7 @@ d darkplaces: q1bsp trace bug: scrags frequently fly through ceilings - this nee
 0 sv_user.qc: figure out why looking up/down slows movement and fix it (Vermeulen)
 1 darkplaces: add DP_CLIENTCAMERA extension (.entity clientcamera; sets which entity the client views from) (Wazat for Battlemech, SeienAbunae)
 1 darkplaces: add DP_EF_CLIENTLOCKANGLES extension (prevents client from turning view, takes angles from entity) (Wazat for Battlemech, SeienAbunae)
-1 darkplaces: add DP_EF_PRECISEANGLES extension (sends short angles instead of byte) (Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt)
+f darkplaces: add DP_EF_PRECISEANGLES extension (sends short angles instead of byte), failed because network protocol was upgraded by default (Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt)
 1 darkplaces: add DP_QC_ENDFRAME extension/documentation and post it on wiki (tell Uffe, SeienAbunae)
 1 darkplaces: add DP_SV_READCLIENTINPUT extension (.vector clientinput; works like .movement but for mouse or any other similar controllers) (Wazat for Battlemech, FrikaC, SeienAbunae)
 1 darkplaces: add EndGame function (called on server shutdown or level change) (SeienAbunae, Nexuiz)
diff --git a/view.c b/view.c
index 4987947..570e460 100644 (file)
--- a/view.c
+++ b/view.c
@@ -214,8 +214,7 @@ void V_ParseDamage (void)
 
        armor = MSG_ReadByte ();
        blood = MSG_ReadByte ();
-       for (i=0 ; i<3 ; i++)
-               from[i] = MSG_ReadCoord ();
+       MSG_ReadVector(from);
 
        count = blood*0.5 + armor*0.5;
        if (count < 10)