MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Cvar_WriteVariables

Function Cvar_WriteVariables

code/qcommon/cvar.cpp:963–1004  ·  view source on GitHub ↗

============ Cvar_WriteVariables Appends lines containing "set variable value" for all variables with the archive flag set to qtrue. ============ */

Source from the content-addressed store, hash-verified

961============
962*/
963void Cvar_WriteVariables( fileHandle_t f ) {
964 cvar_t *var;
965 char buffer[1024];
966
967 if ( cvar_sort ) {
968 Com_DPrintf( "Cvar_Sort: sort cvars\n" );
969 cvar_sort = qfalse;
970 Cvar_Sort();
971 }
972
973 for ( var = cvar_vars; var; var = var->next )
974 {
975 if ( !var->name || Q_stricmp( var->name, "cl_cdkey" ) == 0 )
976 continue;
977
978 if ( var->flags & CVAR_ARCHIVE ) {
979 // write the latched value, even if it hasn't taken effect yet
980 if ( var->latchedString ) {
981 if( strlen( var->name ) + strlen( var->latchedString ) + 10 > sizeof( buffer ) ) {
982 Com_Printf( S_COLOR_YELLOW "WARNING: value of variable "
983 "\"%s\" too long to write to file\n", var->name );
984 continue;
985 }
986 if ( (var->flags & CVAR_NODEFAULT) && !strcmp( var->latchedString, var->resetString ) ) {
987 continue;
988 }
989 Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->latchedString);
990 } else {
991 if( strlen( var->name ) + strlen( var->string ) + 10 > sizeof( buffer ) ) {
992 Com_Printf( S_COLOR_YELLOW "WARNING: value of variable "
993 "\"%s\" too long to write to file\n", var->name );
994 continue;
995 }
996 if ( (var->flags & CVAR_NODEFAULT) && !strcmp( var->string, var->resetString ) ) {
997 continue;
998 }
999 Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->string);
1000 }
1001 FS_Write( buffer, strlen( buffer ), f );
1002 }
1003 }
1004}
1005
1006/*
1007============

Callers 1

Com_WriteConfigToFileFunction · 0.70

Calls 6

Q_stricmpFunction · 0.85
Com_DPrintfFunction · 0.70
Cvar_SortFunction · 0.70
Com_PrintfFunction · 0.70
Com_sprintfFunction · 0.70
FS_WriteFunction · 0.70

Tested by

no test coverage detected