Skip to content

Commit

Permalink
Format float cvars without trailing zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Nov 17, 2023
1 parent 9f48a4f commit d73f82d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/qcommon/cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ void Cvar_SetValueExt( const char *var_name, float value, qboolean force) {
if ( value == (int)value ) {
Com_sprintf (val, sizeof(val), "%i",(int)value);
} else {
Com_sprintf (val, sizeof(val), "%f",value);
Com_sprintf (val, sizeof(val), "%g",value);
}
Cvar_Set2 (var_name, val, force);
}
Expand Down Expand Up @@ -990,7 +990,7 @@ void Cvar_SetValueSafe( const char *var_name, float value )
if( Q_isintegral( value ) )
Com_sprintf( val, sizeof(val), "%i", (int)value );
else
Com_sprintf( val, sizeof(val), "%f", value );
Com_sprintf( val, sizeof(val), "%g", value );
Cvar_SetSafe( var_name, val );
}

Expand Down Expand Up @@ -1545,7 +1545,7 @@ static void Cvar_Func_f( void ) {
if ( (int)fval == fval )
sprintf( value, "%i", (int)fval );
else
sprintf( value, "%f", fval );
sprintf( value, "%g", fval );
}

Cvar_Set2( cvar_name, value, qfalse );
Expand Down

0 comments on commit d73f82d

Please sign in to comment.