]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix svc_setview
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 4 Aug 2002 20:07:11 +0000 (20:07 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 4 Aug 2002 20:07:11 +0000 (20:07 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2194 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_parse.c
client.h
sv_main.c

index 78c41e34d0be3495fe49f2f19fbf5667739b2d93..6f8a666e1c21cc3b0a11f44bdde92cafd3d01d2b 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -638,7 +638,7 @@ void CL_LerpPlayer(float frac)
        int i;
        float d;
 
-       if (cl.entitydatabase.numframes)
+       if (cl.entitydatabase.numframes && cl.viewentity == cl.playerentity)
        {
                cl.viewentorigin[0] = cl.viewentoriginold[0] + frac * (cl.viewentoriginnew[0] - cl.viewentoriginold[0]);
                cl.viewentorigin[1] = cl.viewentoriginold[1] + frac * (cl.viewentoriginnew[1] - cl.viewentoriginold[1]);
index 039f54e2cfc1126e6c515a480533f135075b3c8e..6bbe93388e03889ba82abce6f7401d05ab09375a 100644 (file)
@@ -470,6 +470,7 @@ void CL_ParseServerInfo (void)
 // local state
        ent = &cl_entities[0];
        // entire entity array was cleared, so just fill in a few fields
+       ent->state_current.active = true;
        ent->render.model = cl.worldmodel = cl.model_precache[1];
        ent->render.scale = 1;
        ent->render.alpha = 1;
@@ -1135,6 +1136,9 @@ void CL_ParseServerMessage (void)
 
                case svc_setview:
                        cl.viewentity = MSG_ReadShort ();
+                       // LordHavoc: assume first setview recieved is the real player entity
+                       if (!cl.playerentity)
+                               cl.playerentity = cl.viewentity;
                        break;
 
                case svc_lightstyle:
index 2457c2f95e3bbd529820781cfba51d8ab6ba4a8f..7d37ebcc92e343b3b463cab3a7e2be6f16f70197 100644 (file)
--- a/client.h
+++ b/client.h
@@ -384,7 +384,12 @@ typedef struct
        char levelname[40];
        // cl_entitites[cl.viewentity] = player
        int viewentity;
+       // the real player entity (normally same as viewentity,
+       // different than viewentity if mod uses chasecam or other tricks)
+       int playerentity;
+       // max players that can be in this game
        int maxclients;
+       // type of game (deathmatch, coop, singleplayer)
        int gametype;
 
 // refresh related state
index 1dc26376f23bce324ecb5361977d4af9982cb962..3f17d4112ac4cd231af9f07b70c45452f025499b 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -881,9 +881,16 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
        Mod_CheckLoaded(sv.worldmodel);
 
 // find the client's PVS
+       // the real place being tested from
        VectorAdd (clent->v.origin, clent->v.view_ofs, testeye);
        pvs = SV_FatPVS (testeye);
-       EntityFrame_Clear(&entityframe, testeye);
+
+       // the place being reported (to consider the fact the client still
+       // applies the view_ofs[2], so we have to only send the fractional part
+       // of view_ofs[2], undoing what the client will redo)
+       VectorCopy (testeye, testorigin);
+       testorigin[2] -= (float) ((int)(clent->v.view_ofs[2]) & 255);
+       EntityFrame_Clear(&entityframe, testorigin);
 
        culled_pvs = 0;
        culled_portal = 0;
@@ -1170,7 +1177,8 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
 
        bits = 0;
 
-       bits |= SU_VIEWHEIGHT;
+       if (ent->v.view_ofs[2] != DEFAULT_VIEWHEIGHT)
+               bits |= SU_VIEWHEIGHT;
 
        if (ent->v.idealpitch)
                bits |= SU_IDEALPITCH;
@@ -1244,8 +1252,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
                MSG_WriteByte(msg, bits >> 24);
 
        if (bits & SU_VIEWHEIGHT)
-               //MSG_WriteChar (msg, ent->v.view_ofs[2]);
-               MSG_WriteChar (msg, 0);
+               MSG_WriteChar (msg, ent->v.view_ofs[2]);
 
        if (bits & SU_IDEALPITCH)
                MSG_WriteChar (msg, ent->v.idealpitch);