engine: minor refactoring, rename ref_state_t fields to snake case, rename readable names to shorter (no pun intended) long names

This commit is contained in:
Alibek Omarov
2025-03-20 03:11:17 +03:00
parent 5009db6aac
commit d93bee0cbc
4 changed files with 21 additions and 21 deletions

View File

@@ -1273,16 +1273,16 @@ static void pfnEnableTextInput( int enable )
Key_EnableTextInput( enable, false );
}
static int pfnGetRenderers( unsigned int num, char *shortName, size_t size1, char *readableName, size_t size2 )
static int pfnGetRenderers( unsigned int num, char *short_name, size_t size1, char *long_name, size_t size2 )
{
if( num >= ref.numRenderers )
if( num >= ref.num_renderers )
return 0;
if( shortName && size1 )
Q_strncpy( shortName, ref.shortNames[num], size1 );
if( short_name && size1 )
Q_strncpy( short_name, ref.short_names[num], size1 );
if( readableName && size2 )
Q_strncpy( readableName, ref.readableNames[num], size2 );
if( long_name && size2 )
Q_strncpy( long_name, ref.long_names[num], size2 );
return 1;
}

View File

@@ -623,7 +623,7 @@ static void SetFullscreenModeFromCommandLine( void )
static void R_CollectRendererNames( void )
{
// ordering is important!
static const char *shortNames[] =
static const char *short_names[] =
{
#if XASH_REF_GL_ENABLED
"gl",
@@ -646,7 +646,7 @@ static void R_CollectRendererNames( void )
};
// ordering is important here too!
static const char *readableNames[ARRAYSIZE( shortNames )] =
static const char *long_names[ARRAYSIZE( short_names )] =
{
#if XASH_REF_GL_ENABLED
"OpenGL",
@@ -668,9 +668,9 @@ static void R_CollectRendererNames( void )
#endif
};
ref.numRenderers = ARRAYSIZE( shortNames );
ref.shortNames = shortNames;
ref.readableNames = readableNames;
ref.num_renderers = ARRAYSIZE( short_names );
ref.short_names = short_names;
ref.long_names = long_names;
}
qboolean R_Init( void )
@@ -747,26 +747,26 @@ qboolean R_Init( void )
{
int i;
for( i = 0; i < ref.numRenderers; i++ )
for( i = 0; i < ref.num_renderers; i++ )
{
// skip renderer that was requested but failed to load
if( !Q_strcmp( requested_cmdline, ref.shortNames[i] ))
if( !Q_strcmp( requested_cmdline, ref.short_names[i] ))
continue;
if( !Q_strcmp( requested_cvar, ref.shortNames[i] ))
if( !Q_strcmp( requested_cvar, ref.short_names[i] ))
continue;
// do not show bruteforcing attempts, however, warn user about falling back
// to software mode
if( !Q_strcmp( "soft", ref.shortNames[i] ) && !host_developer.value )
if( !Q_strcmp( "soft", ref.short_names[i] ) && !host_developer.value )
Sys_Warn( "Can't initialize any hardware accelerated renderer. Falling back to software rendering...\n" );
success = R_LoadRenderer( ref.shortNames[i], !host_developer.value );
success = R_LoadRenderer( ref.short_names[i], !host_developer.value );
if( success )
{
// remember last valid renderer
Cvar_DirectSet( &r_refdll, ref.shortNames[i] );
Cvar_DirectSet( &r_refdll, ref.short_names[i] );
break;
}
}

View File

@@ -24,12 +24,12 @@ struct ref_state_s
{
HINSTANCE hInstance;
qboolean initialized;
int numRenderers;
int num_renderers;
ref_interface_t dllFuncs;
// depends on build configuration
const char **shortNames;
const char **readableNames;
const char **short_names;
const char **long_names;
};
extern struct ref_state_s ref;

View File

@@ -210,7 +210,7 @@ typedef struct ui_extendedfuncs_s {
// new engine extended api start here
// returns 1 if there are more in list, otherwise 0
int (*pfnGetRenderers)( unsigned int num, char *shortName, size_t size1, char *readableName, size_t size2 );
int (*pfnGetRenderers)( unsigned int num, char *short_name, size_t size1, char *long_name, size_t size2 );
double (*pfnDoubleTime)( void );
char *(*pfnParseFile)( char *data, char *buf, const int size, unsigned int flags, int *len );