Browse Source

Fix R_CollectRendererNames

Previously R_CollectRendererNames left gaps in the `ref` subarrays.
This caused `R_Init` to fail in some cases because it iterates between `0` and `ref.numRenderers`.
pull/2/head
Gleb Mazovetskiy 4 years ago committed by Alibek Omarov
parent
commit
12b579bc34
  1. 16
      engine/client/ref_common.c

16
engine/client/ref_common.c

@ -586,10 +586,9 @@ static void SetFullscreenModeFromCommandLine( void )
void R_CollectRendererNames( void ) void R_CollectRendererNames( void )
{ {
const char *renderers[] = DEFAULT_RENDERERS; const char *renderers[] = DEFAULT_RENDERERS;
int i; int i, cur;
ref.numRenderers = 0;
cur = 0;
for( i = 0; i < DEFAULT_RENDERERS_LEN; i++ ) for( i = 0; i < DEFAULT_RENDERERS_LEN; i++ )
{ {
string temp; string temp;
@ -612,26 +611,27 @@ void R_CollectRendererNames( void )
continue; continue;
} }
Q_strncpy( ref.shortNames[i], renderers[i], sizeof( ref.shortNames[i] )); Q_strncpy( ref.shortNames[cur], renderers[i], sizeof( ref.shortNames[cur] ));
pfn = COM_GetProcAddress( dll, GET_REF_HUMANREADABLE_NAME ); pfn = COM_GetProcAddress( dll, GET_REF_HUMANREADABLE_NAME );
if( !pfn ) // just in case if( !pfn ) // just in case
{ {
Con_Reportf( "R_CollectRendererNames: can't find GetHumanReadableName export in %s\n", temp ); Con_Reportf( "R_CollectRendererNames: can't find GetHumanReadableName export in %s\n", temp );
Q_strncpy( ref.readableNames[i], renderers[i], sizeof( ref.readableNames[i] )); Q_strncpy( ref.readableNames[cur], renderers[i], sizeof( ref.readableNames[cur] ));
} }
else else
{ {
REF_HUMANREADABLE_NAME GetHumanReadableName = (REF_HUMANREADABLE_NAME)pfn; REF_HUMANREADABLE_NAME GetHumanReadableName = (REF_HUMANREADABLE_NAME)pfn;
GetHumanReadableName( ref.readableNames[i], sizeof( ref.readableNames[i] )); GetHumanReadableName( ref.readableNames[cur], sizeof( ref.readableNames[cur] ));
} }
Con_Printf( "Found renderer %s: %s\n", ref.shortNames[i], ref.readableNames[i] ); Con_Printf( "Found renderer %s: %s\n", ref.shortNames[cur], ref.readableNames[cur] );
ref.numRenderers++; cur++;
COM_FreeLibrary( dll ); COM_FreeLibrary( dll );
} }
ref.numRenderers = cur;
} }
qboolean R_Init( void ) qboolean R_Init( void )

Loading…
Cancel
Save