Don't register fs_game cvar everywhere just to get the value

This commit is contained in:
Zack Middleton 2018-01-21 02:38:08 -06:00
parent 3a6af1bc48
commit adef4e6c9e
4 changed files with 17 additions and 26 deletions

View File

@ -639,9 +639,9 @@ CLUI_GetCDKey
*/ */
static void CLUI_GetCDKey( char *buf, int buflen ) { static void CLUI_GetCDKey( char *buf, int buflen ) {
#ifndef STANDALONE #ifndef STANDALONE
cvar_t *fs; const char *gamedir;
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); gamedir = Cvar_VariableString( "fs_game" );
if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { if (UI_usesUniqueCDKey() && gamedir[0] != 0) {
Com_Memcpy( buf, &cl_cdkey[16], 16); Com_Memcpy( buf, &cl_cdkey[16], 16);
buf[16] = 0; buf[16] = 0;
} else { } else {
@ -661,9 +661,9 @@ CLUI_SetCDKey
*/ */
#ifndef STANDALONE #ifndef STANDALONE
static void CLUI_SetCDKey( char *buf ) { static void CLUI_SetCDKey( char *buf ) {
cvar_t *fs; const char *gamedir;
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); gamedir = Cvar_VariableString( "fs_game" );
if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { if (UI_usesUniqueCDKey() && gamedir[0] != 0) {
Com_Memcpy( &cl_cdkey[16], buf, 16 ); Com_Memcpy( &cl_cdkey[16], buf, 16 );
cl_cdkey[32] = 0; cl_cdkey[32] = 0;
// set the flag so the fle will be written at the next opportunity // set the flag so the fle will be written at the next opportunity

View File

@ -2943,9 +2943,6 @@ Writes key bindings and archived cvars to config file if modified
=============== ===============
*/ */
void Com_WriteConfiguration( void ) { void Com_WriteConfiguration( void ) {
#if !defined(DEDICATED) && !defined(STANDALONE)
cvar_t *fs;
#endif
// if we are quiting without fully initializing, make sure // if we are quiting without fully initializing, make sure
// we don't write out anything // we don't write out anything
if ( !com_fullyInitialized ) { if ( !com_fullyInitialized ) {
@ -2961,12 +2958,12 @@ void Com_WriteConfiguration( void ) {
// not needed for dedicated or standalone // not needed for dedicated or standalone
#if !defined(DEDICATED) && !defined(STANDALONE) #if !defined(DEDICATED) && !defined(STANDALONE)
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO );
if(!com_standalone->integer) if(!com_standalone->integer)
{ {
if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { const char *gamedir;
Com_WriteCDKey( fs->string, &cl_cdkey[16] ); gamedir = Cvar_VariableString( "fs_game" );
if (UI_usesUniqueCDKey() && gamedir[0] != 0) {
Com_WriteCDKey( gamedir, &cl_cdkey[16] );
} else { } else {
Com_WriteCDKey( BASEGAME, cl_cdkey ); Com_WriteCDKey( BASEGAME, cl_cdkey );
} }

View File

@ -3369,14 +3369,10 @@ static void FS_Startup( const char *gameName )
} }
#ifndef STANDALONE #ifndef STANDALONE
if(!com_standalone->integer) if (!com_standalone->integer) {
{
cvar_t *fs;
Com_ReadCDKey(BASEGAME); Com_ReadCDKey(BASEGAME);
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); if (fs_gamedirvar->string[0]) {
if (fs && fs->string[0] != 0) { Com_AppendCDKey(fs_gamedirvar->string);
Com_AppendCDKey( fs->string );
} }
} }
#endif #endif

View File

@ -176,15 +176,13 @@ void SV_GetChallenge(netadr_t from)
else else
{ {
// otherwise send their ip to the authorize server // otherwise send their ip to the authorize server
cvar_t *fs; const char *game;
char game[1024];
Com_DPrintf( "sending getIpAuthorize for %s\n", NET_AdrToString( from )); Com_DPrintf( "sending getIpAuthorize for %s\n", NET_AdrToString( from ));
strcpy(game, BASEGAME); game = Cvar_VariableString( "fs_game" );
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); if (game[0] == 0) {
if (fs && fs->string[0] != 0) { game = BASEGAME;
strcpy(game, fs->string);
} }
// the 0 is for backwards compatibility with obsolete sv_allowanonymous flags // the 0 is for backwards compatibility with obsolete sv_allowanonymous flags