Skip to content

Commit fae6ddd

Browse files
committed
Migrate j_* cvars to new style
Using migration helper script.
1 parent ace30ea commit fae6ddd

File tree

3 files changed

+29
-41
lines changed

3 files changed

+29
-41
lines changed

src/engine/client/cl_input.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -448,27 +448,27 @@ void CL_JoystickMove( usercmd_t *cmd )
448448

449449
if ( !kb[ KB_STRAFE ].active )
450450
{
451-
cl.viewangles[ YAW ] += anglespeed * j_yaw->value * cl.joystickAxis[ j_yaw_axis->integer ];
452-
cmd->rightmove = ClampChar( cmd->rightmove + ( int )( j_side->value * cl.joystickAxis[ j_side_axis->integer ] ) );
451+
cl.viewangles[ YAW ] += anglespeed * j_yaw.Get() * cl.joystickAxis[ j_yaw_axis.Get() ];
452+
cmd->rightmove = ClampChar( cmd->rightmove + ( int )( j_side.Get() * cl.joystickAxis[ j_side_axis.Get() ] ) );
453453
}
454454
else
455455
{
456-
cl.viewangles[ YAW ] += anglespeed * j_side->value * cl.joystickAxis[ j_side_axis->integer ];
457-
cmd->rightmove = ClampChar( cmd->rightmove + ( int )( j_yaw->value * cl.joystickAxis[ j_yaw_axis->integer ] ) );
456+
cl.viewangles[ YAW ] += anglespeed * j_side.Get() * cl.joystickAxis[ j_side_axis.Get() ];
457+
cmd->rightmove = ClampChar( cmd->rightmove + ( int )( j_yaw.Get() * cl.joystickAxis[ j_yaw_axis.Get() ] ) );
458458
}
459459

460460
if ( kb[ KB_MLOOK ].active )
461461
{
462-
cl.viewangles[ PITCH ] += anglespeed * j_forward->value * cl.joystickAxis[ j_forward_axis->integer ];
463-
cmd->forwardmove = ClampChar( cmd->forwardmove + ( int )( j_pitch->value * cl.joystickAxis[ j_pitch_axis->integer ] ) );
462+
cl.viewangles[ PITCH ] += anglespeed * j_forward.Get() * cl.joystickAxis[ j_forward_axis.Get() ];
463+
cmd->forwardmove = ClampChar( cmd->forwardmove + ( int )( j_pitch.Get() * cl.joystickAxis[ j_pitch_axis.Get() ] ) );
464464
}
465465
else
466466
{
467-
cl.viewangles[ PITCH ] += anglespeed * j_pitch->value * cl.joystickAxis[ j_pitch_axis->integer ];
468-
cmd->forwardmove = ClampChar( cmd->forwardmove + ( int )( j_forward->value * cl.joystickAxis[ j_forward_axis->integer ] ) );
467+
cl.viewangles[ PITCH ] += anglespeed * j_pitch.Get() * cl.joystickAxis[ j_pitch_axis.Get() ];
468+
cmd->forwardmove = ClampChar( cmd->forwardmove + ( int )( j_forward.Get() * cl.joystickAxis[ j_forward_axis.Get() ] ) );
469469
}
470470

471-
cmd->upmove = ClampChar( cmd->upmove + ( int ) ( j_up->value * cl.joystickAxis[ j_up_axis->integer ] ) );
471+
cmd->upmove = ClampChar( cmd->upmove + ( int ) ( j_up.Get() * cl.joystickAxis[ j_up_axis.Get() ] ) );
472472
}
473473

474474
/*

src/engine/client/cl_main.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ cvar_t *m_forward;
107107
cvar_t *m_side;
108108
cvar_t *m_filter;
109109

110-
cvar_t *j_pitch;
111-
cvar_t *j_yaw;
112-
cvar_t *j_forward;
113-
cvar_t *j_side;
114-
cvar_t *j_up;
115-
cvar_t *j_pitch_axis;
116-
cvar_t *j_yaw_axis;
117-
cvar_t *j_forward_axis;
118-
cvar_t *j_side_axis;
119-
cvar_t *j_up_axis;
110+
Cvar::Cvar<float> j_pitch("j_pitch", "joystick move scale for pitch axis", Cvar::NONE, 0.022);
111+
Cvar::Cvar<float> j_yaw("j_yaw", "joystick move scale for yaw axis", Cvar::NONE, -0.022);
112+
Cvar::Cvar<float> j_forward("j_forward", "joystick move scale for forward axis", Cvar::NONE, -0.25);
113+
Cvar::Cvar<float> j_side("j_side", "joystick move scale for side (strafe) axis", Cvar::NONE, 0.25);
114+
Cvar::Cvar<float> j_up("j_up", "joystick move scale for up axis", Cvar::NONE, 1.0);
115+
Cvar::Range<Cvar::Cvar<int>> j_pitch_axis("j_pitch_axis", "joystick pitch axis number", Cvar::NONE, 3, 0, Util::ordinal(joystickAxis_t::MAX_JOYSTICK_AXIS) - 1);
116+
Cvar::Range<Cvar::Cvar<int>> j_yaw_axis("j_yaw_axis", "joystick yaw axis number", Cvar::NONE, 4, 0, Util::ordinal(joystickAxis_t::MAX_JOYSTICK_AXIS) - 1);
117+
Cvar::Range<Cvar::Cvar<int>> j_forward_axis("j_forward_axis", "joystick forward axis number", Cvar::NONE, 1, 0, Util::ordinal(joystickAxis_t::MAX_JOYSTICK_AXIS) - 1);
118+
Cvar::Range<Cvar::Cvar<int>> j_side_axis("j_side_axis", "joystick side (strafe) axis number", Cvar::NONE, 0, 0, Util::ordinal(joystickAxis_t::MAX_JOYSTICK_AXIS) - 1);
119+
Cvar::Range<Cvar::Cvar<int>> j_up_axis("j_up_axis", "joystick up axis number", Cvar::NONE, 2, 0, Util::ordinal(joystickAxis_t::MAX_JOYSTICK_AXIS) - 1);
120120

121121
cvar_t *cl_activeAction;
122122

@@ -2352,18 +2352,6 @@ void CL_Init()
23522352
m_side = Cvar_Get( "m_side", "0.25", 0 );
23532353
m_filter = Cvar_Get( "m_filter", "0", CVAR_ARCHIVE );
23542354

2355-
j_pitch = Cvar_Get( "j_pitch", "0.022", 0 );
2356-
j_yaw = Cvar_Get( "j_yaw", "-0.022", 0 );
2357-
j_forward = Cvar_Get( "j_forward", "-0.25", 0 );
2358-
j_side = Cvar_Get( "j_side", "0.25", 0 );
2359-
j_up = Cvar_Get ("j_up", "1", 0);
2360-
2361-
j_pitch_axis = Cvar_Get( "j_pitch_axis", "3", 0 );
2362-
j_yaw_axis = Cvar_Get( "j_yaw_axis", "4", 0 );
2363-
j_forward_axis = Cvar_Get( "j_forward_axis", "1", 0 );
2364-
j_side_axis = Cvar_Get( "j_side_axis", "0", 0 );
2365-
j_up_axis = Cvar_Get( "j_up_axis", "2", 0 );
2366-
23672355
cl_consoleFontKerning = Cvar_Get( "cl_consoleFontKerning", "0", 0 );
23682356

23692357
cl_consoleCommand = Cvar_Get( "cl_consoleCommand", "say", 0 );

src/engine/client/client.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,16 @@ extern cvar_t *m_forward;
410410
extern cvar_t *m_side;
411411
extern cvar_t *m_filter;
412412

413-
extern cvar_t *j_pitch;
414-
extern cvar_t *j_yaw;
415-
extern cvar_t *j_forward;
416-
extern cvar_t *j_side;
417-
extern cvar_t *j_up;
418-
extern cvar_t *j_pitch_axis;
419-
extern cvar_t *j_yaw_axis;
420-
extern cvar_t *j_forward_axis;
421-
extern cvar_t *j_side_axis;
422-
extern cvar_t *j_up_axis;
413+
extern Cvar::Cvar<float> j_pitch;
414+
extern Cvar::Cvar<float> j_yaw;
415+
extern Cvar::Cvar<float> j_forward;
416+
extern Cvar::Cvar<float> j_side;
417+
extern Cvar::Cvar<float> j_up;
418+
extern Cvar::Range<Cvar::Cvar<int>> j_pitch_axis;
419+
extern Cvar::Range<Cvar::Cvar<int>> j_yaw_axis;
420+
extern Cvar::Range<Cvar::Cvar<int>> j_forward_axis;
421+
extern Cvar::Range<Cvar::Cvar<int>> j_side_axis;
422+
extern Cvar::Range<Cvar::Cvar<int>> j_up_axis;
423423

424424
extern Cvar::Cvar<bool> cvar_demo_timedemo;
425425

0 commit comments

Comments
 (0)