2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-25 03:11:06 +01:00

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`.
This commit is contained in:
Gleb Mazovetskiy 2021-01-07 10:07:09 +00:00 committed by Alibek Omarov
parent 6d614e028a
commit 12b579bc34

View File

@ -586,10 +586,9 @@ static void SetFullscreenModeFromCommandLine( void )
void R_CollectRendererNames( void )
{
const char *renderers[] = DEFAULT_RENDERERS;
int i;
ref.numRenderers = 0;
int i, cur;
cur = 0;
for( i = 0; i < DEFAULT_RENDERERS_LEN; i++ )
{
string temp;
@ -612,26 +611,27 @@ void R_CollectRendererNames( void )
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 );
if( !pfn ) // just in case
{
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
{
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 );
}
ref.numRenderers = cur;
}
qboolean R_Init( void )