Skip to content

Commit b7e2db5

Browse files
committed
Migrate some more cl_* cvars
Tiny bug fix: cl_consoleFontSize was read as a float in one place but the font size is always created with an integer value.
1 parent b7ef948 commit b7e2db5

5 files changed

Lines changed: 23 additions & 46 deletions

File tree

src/engine/client/cl_avi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ bool CL_OpenAVIForWriting( const char *fileName )
334334
afd = {};
335335

336336
// Don't start if a framerate has not been chosen
337-
if ( cl_aviFrameRate->integer <= 0 )
337+
if ( cl_aviFrameRate.Get() <= 0 )
338338
{
339339
Log::Warn("cl_aviFrameRate must be ≥ 1" );
340340
return false;
@@ -353,7 +353,7 @@ bool CL_OpenAVIForWriting( const char *fileName )
353353

354354
Q_strncpyz( afd.fileName, fileName, MAX_QPATH );
355355

356-
afd.frameRate = cl_aviFrameRate->integer;
356+
afd.frameRate = cl_aviFrameRate.Get();
357357
afd.framePeriod = ( int )( 1000000.0f / afd.frameRate );
358358
afd.width = cls.windowConfig.vidWidth;
359359
afd.height = cls.windowConfig.vidHeight;

src/engine/client/cl_input.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -827,19 +827,11 @@ bool CL_ReadyToSendPacket()
827827
}
828828

829829
// check for exceeding cl_maxpackets
830-
if ( cl_maxpackets->integer < 15 )
831-
{
832-
Cvar_Set( "cl_maxpackets", "15" );
833-
}
834-
else if ( cl_maxpackets->integer > 125 )
835-
{
836-
Cvar_Set( "cl_maxpackets", "125" );
837-
}
838830

839831
oldPacketNum = ( clc.netchan.outgoingSequence - 1 ) & PACKET_MASK;
840832
delta = cls.realtime - cl.outPackets[ oldPacketNum ].p_realtime;
841833

842-
if ( delta < 1000 / cl_maxpackets->integer )
834+
if ( delta < 1000 / cl_maxpackets.Get() )
843835
{
844836
// the accumulated commands will go out in the next packet
845837
return false;
@@ -916,16 +908,8 @@ void CL_WritePacket()
916908
// we want to send all the usercmds that were generated in the last
917909
// few packet, so even if a couple packets are dropped in a row,
918910
// all the cmds will make it to the server
919-
if ( cl_packetdup->integer < 0 )
920-
{
921-
Cvar_Set( "cl_packetdup", "0" );
922-
}
923-
else if ( cl_packetdup->integer > 5 )
924-
{
925-
Cvar_Set( "cl_packetdup", "5" );
926-
}
927911

928-
oldPacketNum = ( clc.netchan.outgoingSequence - 1 - cl_packetdup->integer ) & PACKET_MASK;
912+
oldPacketNum = ( clc.netchan.outgoingSequence - 1 - cl_packetdup.Get() ) & PACKET_MASK;
929913
count = cl.cmdNumber - cl.outPackets[ oldPacketNum ].p_cmdNumber;
930914

931915
if ( count > MAX_PACKET_USERCMDS )

src/engine/client/cl_main.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ Cvar::Cvar<float> cl_mumbleScale("cl_mumbleScale", "multiplier of world coordina
6767
Cvar::Cvar<bool> cl_nodelta("cl_nodelta", "disable network snapshot delta compression", Cvar::NONE, false);
6868

6969
Cvar::Cvar<float> cl_timeout("cl_timeout", "disconnect after this many seconds without server packets", Cvar::NONE, 200);
70-
cvar_t *cl_maxpackets;
71-
cvar_t *cl_packetdup;
70+
Cvar::Range<Cvar::Cvar<int>> cl_maxpackets("cl_maxpackets", "client->server max packets per second", Cvar::NONE, 125, 15, 125);
71+
Cvar::Range<Cvar::Cvar<int>> cl_packetdup("cl_packetdup", "send N extra copies of each usercmd_t", Cvar::NONE, 1, 0, 5);
7272
Cvar::Range<Cvar::Cvar<int>> cl_timeNudge("cl_timeNudge", "ms to extrapolate/interpolate ahead/behind latest snapshots (negative means extrapolate ahead)", Cvar::NONE, 0, -30, 30);
7373
cvar_t *cl_showTimeDelta;
7474

@@ -89,7 +89,7 @@ Cvar::Cvar<std::string> cvar_demo_status_filename(
8989
""
9090
);
9191

92-
cvar_t *cl_aviFrameRate;
92+
Cvar::Cvar<int> cl_aviFrameRate("cl_aviFrameRate", "demo video framerate", Cvar::NONE, 25);
9393

9494
Cvar::Cvar<bool> cl_freelook("cl_freelook", "vertical mouse movement always controls pitch", Cvar::NONE, true);
9595

@@ -121,9 +121,9 @@ Cvar::Cvar<bool> cl_autorecord("cl_autorecord", "record a demo of every game", C
121121
Cvar::Cvar<bool> cl_allowDownload("cl_allowDownload", "auto-download paks required by the server", Cvar::NONE, true);
122122

123123
Cvar::Cvar<std::string> cl_consoleFont("cl_consoleFont", "path (in homepath) for console typeface", Cvar::NONE, "");
124-
cvar_t *cl_consoleFontSize;
125-
cvar_t *cl_consoleFontScaling;
126-
cvar_t *cl_consoleFontKerning;
124+
Cvar::Cvar<int> cl_consoleFontSize("cl_consoleFontSize", "console font point size", Cvar::NONE, 16);
125+
Cvar::Cvar<bool> cl_consoleFontScaling("cl_consoleFontScaling", "rescale console font size by ratio of display size to 1080p", Cvar::NONE, true);
126+
Cvar::Cvar<float> cl_consoleFontKerning("cl_consoleFontKerning", "px of horizontal padding on console glyphs", Cvar::NONE, 0);
127127
//see also com_consoleCommand for terminal consoles
128128
Cvar::Cvar<std::string> cl_consoleCommand("cl_consoleCommand", "command prepended to console lines, when in game", Cvar::NONE, "say");
129129

@@ -2098,20 +2098,20 @@ bool CL_InitRenderer()
20982098
}
20992099

21002100
Cvar::Latch(cl_consoleFont);
2101-
cl_consoleFontSize = Cvar_Get( "cl_consoleFontSize", "16", CVAR_LATCH );
2102-
cl_consoleFontScaling = Cvar_Get( "cl_consoleFontScaling", "1", CVAR_LATCH );
2101+
Cvar::Latch(cl_consoleFontSize);
2102+
Cvar::Latch(cl_consoleFontScaling);
21032103

21042104
// Register console font specified by cl_consoleFont. Empty string means use the embbed Unifont
21052105

2106-
int fontSize = cl_consoleFontSize->integer;
2106+
int fontSize = cl_consoleFontSize.Get();
21072107

2108-
if ( cl_consoleFontScaling->integer )
2108+
if ( cl_consoleFontScaling.Get() )
21092109
{
21102110
// This gets 12px on 1920×1080 screen, which is libRocket default for 1em
21112111
int fontScale = std::min(cls.windowConfig.vidWidth, cls.windowConfig.vidHeight) / 90;
21122112

21132113
// fontScale / 12px gets 1px on 1920×1080 screen
2114-
fontSize = cl_consoleFontSize->integer * fontScale / 12;
2114+
fontSize = cl_consoleFontSize.Get() * fontScale / 12;
21152115
}
21162116

21172117
if ( !cl_consoleFont.Get().empty() )
@@ -2301,13 +2301,6 @@ void CL_Init()
23012301
cl_showSend = Cvar_Get( "cl_showSend", "0", CVAR_TEMP );
23022302
cl_showTimeDelta = Cvar_Get( "cl_showTimeDelta", "0", CVAR_TEMP );
23032303

2304-
cl_aviFrameRate = Cvar_Get( "cl_aviFrameRate", "25", 0 );
2305-
2306-
cl_maxpackets = Cvar_Get( "cl_maxpackets", "125", 0 );
2307-
cl_packetdup = Cvar_Get( "cl_packetdup", "1", 0 );
2308-
2309-
cl_consoleFontKerning = Cvar_Get( "cl_consoleFontKerning", "0", 0 );
2310-
23112304
// userinfo
23122305
cl_rate = Cvar_Get( "rate", XSTRING(NETWORK_DEFAULT_RATE), CVAR_USERINFO | CVAR_ARCHIVE);
23132306

src/engine/client/cl_scrn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void SCR_UpdateScreen()
282282

283283
float SCR_ConsoleFontUnicharWidth( int ch )
284284
{
285-
return Glyph( ch )->xSkip + cl_consoleFontKerning->value;
285+
return Glyph( ch )->xSkip + cl_consoleFontKerning.Get();
286286
}
287287

288288
float SCR_ConsoleFontCharWidth( const char *s )
@@ -292,7 +292,7 @@ float SCR_ConsoleFontCharWidth( const char *s )
292292

293293
float SCR_ConsoleFontCharHeight()
294294
{
295-
return cls.consoleFont->glyphBlock[0][(unsigned)'I'].imageHeight + CONSOLE_FONT_VPADDING * cl_consoleFontSize->value;
295+
return cls.consoleFont->glyphBlock[0][(unsigned)'I'].imageHeight + CONSOLE_FONT_VPADDING * cl_consoleFontSize.Get();
296296
}
297297

298298
float SCR_ConsoleFontCharVPadding()

src/engine/client/client.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ extern struct rsa_private_key private_key;
369369
// cvars
370370
//
371371
extern Cvar::Cvar<bool> cl_nodelta;
372-
extern cvar_t *cl_maxpackets;
373-
extern cvar_t *cl_packetdup;
372+
extern Cvar::Range<Cvar::Cvar<int>> cl_maxpackets;
373+
extern Cvar::Range<Cvar::Cvar<int>> cl_packetdup;
374374
extern cvar_t *cl_shownet;
375375
extern cvar_t *cl_showSend;
376376
extern Cvar::Range<Cvar::Cvar<int>> cl_timeNudge;
@@ -413,15 +413,15 @@ extern Cvar::Cvar<bool> cl_allowDownload;
413413
// -NERVE - SMF
414414

415415
extern Cvar::Cvar<std::string> cl_consoleFont;
416-
extern cvar_t *cl_consoleFontSize;
417-
extern cvar_t *cl_consoleFontScaling;
418-
extern cvar_t *cl_consoleFontKerning;
416+
extern Cvar::Cvar<int> cl_consoleFontSize;
417+
extern Cvar::Cvar<bool> cl_consoleFontScaling;
418+
extern Cvar::Cvar<float> cl_consoleFontKerning;
419419
extern Cvar::Cvar<std::string> cl_consoleCommand;
420420

421421
extern Cvar::Range<Cvar::Cvar<int>> con_scrollLock;
422422

423423
// XreaL BEGIN
424-
extern cvar_t *cl_aviFrameRate;
424+
extern Cvar::Cvar<int> cl_aviFrameRate;
425425
extern Cvar::Cvar<bool> cl_aviMotionJpeg;
426426
// XreaL END
427427

0 commit comments

Comments
 (0)