]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Make V_CalcRoll a common function. Add sv_rollangle and sv_rollspeed cvars.
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 12 Aug 2020 14:54:09 +0000 (14:54 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 12 Aug 2020 14:54:09 +0000 (14:54 +0000)
This allows V_Init to move to client code.

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

cl_ents_qw.c
cl_main.c
client.h
common.c
common.h
host.c
sv_main.c
sv_user.c
view.c

index e21c7a2106e23eef8cfd4cb61724142a1853a5be..2656dbc0099e3eda79c3ae187c73f874d0cec6ab 100644 (file)
@@ -40,6 +40,9 @@ static void QW_TranslateEffects(entity_state_t *s, int qweffects)
                s->effects |= EF_DIMLIGHT;
 }
 
+extern cvar_t cl_rollangle;
+extern cvar_t cl_rollspeed;
+
 void EntityStateQW_ReadPlayerUpdate(void)
 {
        int slot = MSG_ReadByte(&cl_message);
@@ -130,7 +133,7 @@ void EntityStateQW_ReadPlayerUpdate(void)
        s->angles[0] = viewangles[0] * -0.0333;
        s->angles[1] = viewangles[1];
        s->angles[2] = 0;
-       s->angles[2] = V_CalcRoll(s->angles, velocity)*4;
+       s->angles[2] = Com_CalcRoll(s->angles, velocity, cl_rollangle.value, cl_rollspeed.value)*4;
 
        // if this is an update on our player, update interpolation state
        if (enumber == cl.playerentity)
index 517d388311553caf5d2533a23b878cc821e2eed3..6ba4bd0c69a52c374ae1312a667d22fc7923c6a7 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -2928,7 +2928,7 @@ void CL_Init (void)
                S_Init();
                CDAudio_Init();
                Key_Init();
-
+               V_Init();
 
                cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL);
                cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL);
index 159d3233a39be822aa6ab3a6414bcff4995ad07e..a9a1eb36492cfbdd3009f6e048e41d87a489c1c4 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1645,7 +1645,6 @@ void V_StartPitchDrift_f(cmd_state_t *cmd);
 void V_StopPitchDrift (void);
 
 void V_Init (void);
-float V_CalcRoll (const vec3_t angles, const vec3_t velocity);
 void V_UpdateBlends (void);
 void V_ParseDamage (void);
 
index 9513239f9ddfd7e6055c767e67b1c0a2a9aa2bd9..03b7087ef9016182582d45267bbab4abdb3b7471 100644 (file)
--- a/common.c
+++ b/common.c
@@ -884,6 +884,33 @@ int COM_CheckParm (const char *parm)
        return 0;
 }
 
+/*
+===============
+Com_CalcRoll
+
+Used by view and sv_user
+===============
+*/
+float Com_CalcRoll (const vec3_t angles, const vec3_t velocity, const vec_t angleval, const vec_t velocityval)
+{
+       vec3_t  right;
+       float   sign;
+       float   side;
+
+       AngleVectors (angles, NULL, right, NULL);
+       side = DotProduct (velocity, right);
+       sign = side < 0 ? -1 : 1;
+       side = fabs(side);
+
+       if (side < velocityval)
+               side = side * angleval / velocityval;
+       else
+               side = angleval;
+
+       return side*sign;
+
+}
+
 //===========================================================================
 
 /*
index f05450f9666c79649a3d2cb39c8f15a63c688534..15ca90d097399660324b0fb043867cb855f2f1c5 100644 (file)
--- a/common.h
+++ b/common.h
@@ -382,5 +382,7 @@ size_t base64_encode(unsigned char *buf, size_t buflen, size_t outbuflen);
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
+float Com_CalcRoll (const vec3_t angles, const vec3_t velocity, const vec_t angleval, const vec_t velocityval);
+
 #endif
 
diff --git a/host.c b/host.c
index c9a0ca3f4f0ee764e29353138e479f5ee73941fe..911b29bf0403f7d69733aaed30d9a29a2cb48475 100644 (file)
--- a/host.c
+++ b/host.c
@@ -701,7 +701,6 @@ static void Host_Init (void)
        Mod_Init();
        World_Init();
        SV_Init();
-       V_Init(); // some cvars needed by server player physics (cl_rollangle etc)
        Host_InitLocal();
        Host_ServerOptions();
 
index a7a99deacaa2773935d2cc21bfb19a6bd7acc001..c2419941655ad7db5e879e7548b2fb35f23cbe41 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -161,6 +161,9 @@ cvar_t teamplay = {CVAR_SERVER | CVAR_NOTIFY, "teamplay","0", "teamplay mode, va
 cvar_t timelimit = {CVAR_SERVER | CVAR_NOTIFY, "timelimit","0", "ends level at this time (in minutes)"};
 cvar_t sv_threaded = {CVAR_SERVER, "sv_threaded", "0", "enables a separate thread for server code, improving performance, especially when hosting a game while playing, EXPERIMENTAL, may be crashy"};
 
+cvar_t sv_rollspeed = {CVAR_CLIENT, "sv_rollspeed", "200", "how much strafing is necessary to tilt the view"};
+cvar_t sv_rollangle = {CVAR_CLIENT, "sv_rollangle", "2.0", "how much to tilt the view when strafing"};
+
 cvar_t saved1 = {CVAR_SERVER | CVAR_SAVE, "saved1", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
 cvar_t saved2 = {CVAR_SERVER | CVAR_SAVE, "saved2", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
 cvar_t saved3 = {CVAR_SERVER | CVAR_SAVE, "saved3", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
@@ -583,6 +586,9 @@ void SV_Init (void)
        Cvar_RegisterVariable (&timelimit);
        Cvar_RegisterVariable (&sv_threaded);
 
+       Cvar_RegisterVariable (&sv_rollangle);
+       Cvar_RegisterVariable (&sv_rollspeed);
+
        Cvar_RegisterVariable (&saved1);
        Cvar_RegisterVariable (&saved2);
        Cvar_RegisterVariable (&saved3);
index d6cd9aa0df0e8f15ee690ad5409789e46337d1a0..57fc14b76b06a77ed372e00e0abc5f7e2f0fb298 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 static usercmd_t usercmd;
 extern cvar_t sv_autodemo_perclient;
+extern cvar_t sv_rollangle;
+extern cvar_t sv_rollspeed;
 
 /*
 ==================
@@ -606,7 +608,7 @@ void SV_ClientThink (void)
        VectorAdd (PRVM_serveredictvector(host_client->edict, v_angle), PRVM_serveredictvector(host_client->edict, punchangle), v_angle);
        VectorCopy(PRVM_serveredictvector(host_client->edict, angles), angles);
        VectorCopy(PRVM_serveredictvector(host_client->edict, velocity), velocity);
-       PRVM_serveredictvector(host_client->edict, angles)[ROLL] = V_CalcRoll (angles, velocity)*4;
+       PRVM_serveredictvector(host_client->edict, angles)[ROLL] = Com_CalcRoll (angles, velocity, sv_rollangle.value, sv_rollspeed.value)*4;
        if (!PRVM_serveredictfloat(host_client->edict, fixangle))
        {
                PRVM_serveredictvector(host_client->edict, angles)[PITCH] = -v_angle[PITCH]/3;
diff --git a/view.c b/view.c
index 315738c2289b0b0c4599320a8b951f1b880edc0c..d7b1ac74c81042663a272f3c1f6c37265c25f67f 100644 (file)
--- a/view.c
+++ b/view.c
@@ -146,36 +146,6 @@ float      v_dmg_time, v_dmg_roll, v_dmg_pitch;
 
 int cl_punchangle_applied;
 
-/*
-===============
-V_CalcRoll
-
-Used by view and sv_user
-===============
-*/
-float V_CalcRoll (const vec3_t angles, const vec3_t velocity)
-{
-       vec3_t  right;
-       float   sign;
-       float   side;
-       float   value;
-
-       AngleVectors (angles, NULL, right, NULL);
-       side = DotProduct (velocity, right);
-       sign = side < 0 ? -1 : 1;
-       side = fabs(side);
-
-       value = cl_rollangle.value;
-
-       if (side < cl_rollspeed.value)
-               side = side * value / cl_rollspeed.value;
-       else
-               side = value;
-
-       return side*sign;
-
-}
-
 void V_StartPitchDrift (void)
 {
        if (cl.laststop == cl.time)
@@ -692,7 +662,7 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                VectorAdd(viewangles, cl.punchangle, viewangles);
                                cl_punchangle_applied = 1;
                        }
-                       viewangles[ROLL] += V_CalcRoll(clviewangles, clvelocity);
+                       viewangles[ROLL] += Com_CalcRoll(clviewangles, clvelocity, cl_rollangle.value, cl_rollspeed.value);
 
                        if (v_dmg_time > 0)
                        {