8000 mint-arena: Remove g_configcvars from ui_controls2.c · Turtle-Arena/turtle-arena-code@23694d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 23694d5

Browse files
committed
mint-arena: Remove g_configcvars from ui_controls2.c
Use trap_Cvar_DefaultVariableStringBuffer() instead of resetting the variable to get the default value.
1 parent 8710cb3 commit 23694d5

File tree

2 files changed

+4
-100
lines changed

2 files changed

+4
-100
lines changed

code/q3_ui/ui_controls2.c

+4-93
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ typedef struct {
5656
int bind2;
5757
} bind_t;
5858

59-
typedef struct
60-
{
61-
char* name;
62-
float defaultvalue;
63-
float value;
64-
} configcvar_t;
65-
6659
#define SAVE_NOOP 0
6760
#define SAVE_YES 1
6861
#define SAVE_NO 2
@@ -452,35 +445,6 @@ bind_t *g_bindings_list[MAX_SPLITVIEW] =
452445
g_bindings4
453446
};
454447

455-
static configcvar_t g_configcvars[] =
456-
{
457-
{"cl_run", 0, 0},
458-
{"2cl_run", 0, 0},
459-
{"3cl_run", 0, 0},
460-
{"4cl_run", 0, 0},
461-
{"m_pitch", 0, 0},
462-
{"cg_cyclePastGauntlet",0, 0},
463-
{"2cg_cyclePastGauntlet",0, 0},
464-
{"3cg_cyclePastGauntlet",0, 0},
465-
{"4cg_cyclePastGauntlet",0, 0},
466-
{"cg_autoswitch", 0, 0},
467-
{"2cg_autoswitch", 0, 0},
468-
{"3cg_autoswitch", 0, 0},
469-
{"4cg_autoswitch", 0, 0},
470-
{"sensitivity", 0, 0},
471-
{"in_joystickUseAnalog", 0, 0},
472-
{"2in_joystickUseAnalog", 0, 0},
473-
{"3in_joystickUseAnalog", 0, 0},
474-
{"4in_joystickUseAnalog", 0, 0},
475-
{"in_joystickThreshold", 0, 0},
476-
{"2in_joystickThreshold", 0, 0},
477-
{"3in_joystickThreshold", 0, 0},
478-
{"4in_joystickThreshold", 0, 0},
479-
{"m_filter", 0, 0},
480-
{"cl_freelook", 0, 0},
481-
{NULL, 0, 0}
482-
};
483-
484448
static menucommon_s *g_movement_controls[] =
485449
{
486450
(menucommon_s *)&s_controls.alwaysrun,
@@ -602,55 +566,18 @@ static menucommon_s **g_mini_controls[] = {
602566
NULL
603567
};
604568

605-
/*
606-
=================
607-
Controls_InitCvars
608-
=================
609-
*/
610-
static void Controls_InitCvars( void )
611-
{
612-
int i;
613-
configcvar_t* cvarptr;
614-
615-
cvarptr = g_configcvars;
616-
for (i=0; ;i++,cvarptr++)
617-
{
618-
if (!cvarptr->name)
619-
break;
620-
621-
// get current value
622-
cvarptr->value = trap_Cvar_VariableValue( cvarptr->name );
623-
624-
// get default value
625-
trap_Cvar_Reset( cvarptr->name );
626-
cvarptr->defaultvalue = trap_Cvar_VariableValue( cvarptr->name );
627-
628-
// restore current value
629-
trap_Cvar_SetValue( cvarptr->name, cvarptr->value );
630-
}
631-
}
632-
633569
/*
634570
=================
635571
Controls_GetCvarDefault
636572
=================
637573
*/
638574
static float Controls_GetCvarDefault( char* name )
639575
{
640-
configcvar_t* cvarptr;
641-
int i;
576+
char defaultvaluebuf[MAX_CVAR_VALUE_STRING];
642577

643-
cvarptr = g_configcvars;
644-
for (i=0; ;i++,cvarptr++)
645-
{
646-
if (!cvarptr->name)
647-
return (0);
648-
649-
if (!strcmp(cvarptr->name,name))
650-
break;
651-
}
578+
trap_Cvar_DefaultVariableStringBuffer( name, defaultvaluebuf, sizeof( defaultvaluebuf ) );
652579

653-
return (cvarptr->defaultvalue);
580+
return atof( defaultvaluebuf );
654581
}
655582

656583
/*
@@ -660,20 +587,7 @@ Controls_GetCvarValue
660587
*/
661588
static float Controls_GetCvarValue( char* name )
662589
{
663-
configcvar_t* cvarptr;
664-
int i;
665-
666-
cvarptr = g_configcvars;
667-
for (i=0; ;i++,cvarptr++)
668-
{
669-
if (!cvarptr->name)
670-
return (0);
671-
672-
if (!strcmp(cvarptr->name,name))
673-
break;
674-
}
675-
676-
return (cvarptr->value);
590+
return trap_Cvar_VariableValue( name );
677591
}
678592

679593

@@ -2102,9 +2016,6 @@ static void Controls_MenuInit( int localPlayerNum )
21022016
trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_controls.localPlayerNum, "name"), s_controls.name.string, 16 );
21032017
Q_CleanStr( s_controls.name.string );
21042018

2105-
// initialize the configurable cvars
2106-
Controls_InitCvars();
2107-
21082019
// initialize the current config
21092020
Controls_GetConfig();
21102021

code/ui/ui_shared.c

-7
Original file line numberDiff line numberDiff line change
@@ -3223,13 +3223,6 @@ typedef struct {
32233223
int bind2;
32243224
} bind_t;
32253225

3226-
typedef struct
3227-
{
3228-
char* name;
3229-
float defaultvalue;
3230-
float value;
3231-
} configcvar_t;
3232-
32333226

32343227
static bind_t g_bindings[] =
32353228
{

0 commit comments

Comments
 (0)
0