engine: client: get rid of NULL sentinels at the end of arrays
This commit is contained in:
parent
ac9d960eef
commit
f1d7101ad8
1 changed files with 36 additions and 34 deletions
|
@ -76,7 +76,6 @@ static const dllfunc_t cdll_exports[] =
|
||||||
{ "IN_ClearStates", (void **)&clgame.dllFuncs.IN_ClearStates },
|
{ "IN_ClearStates", (void **)&clgame.dllFuncs.IN_ClearStates },
|
||||||
{ "V_CalcRefdef", (void **)&clgame.dllFuncs.pfnCalcRefdef },
|
{ "V_CalcRefdef", (void **)&clgame.dllFuncs.pfnCalcRefdef },
|
||||||
{ "KB_Find", (void **)&clgame.dllFuncs.KB_Find },
|
{ "KB_Find", (void **)&clgame.dllFuncs.KB_Find },
|
||||||
{ NULL, NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// optional exports
|
// optional exports
|
||||||
|
@ -91,7 +90,6 @@ static const dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and high
|
||||||
{ "IN_ClientTouchEvent", (void **)&clgame.dllFuncs.pfnTouchEvent}, // Xash3D FWGS ext
|
{ "IN_ClientTouchEvent", (void **)&clgame.dllFuncs.pfnTouchEvent}, // Xash3D FWGS ext
|
||||||
{ "IN_ClientMoveEvent", (void **)&clgame.dllFuncs.pfnMoveEvent}, // Xash3D FWGS ext
|
{ "IN_ClientMoveEvent", (void **)&clgame.dllFuncs.pfnMoveEvent}, // Xash3D FWGS ext
|
||||||
{ "IN_ClientLookEvent", (void **)&clgame.dllFuncs.pfnLookEvent}, // Xash3D FWGS ext
|
{ "IN_ClientLookEvent", (void **)&clgame.dllFuncs.pfnLookEvent}, // Xash3D FWGS ext
|
||||||
{ NULL, NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pfnSPR_DrawHoles( int frame, int x, int y, const wrect_t *prc );
|
static void pfnSPR_DrawHoles( int frame, int x, int y, const wrect_t *prc );
|
||||||
|
@ -4007,9 +4005,10 @@ void CL_UnloadProgs( void )
|
||||||
qboolean CL_LoadProgs( const char *name )
|
qboolean CL_LoadProgs( const char *name )
|
||||||
{
|
{
|
||||||
static playermove_t gpMove;
|
static playermove_t gpMove;
|
||||||
const dllfunc_t *func;
|
|
||||||
CL_EXPORT_FUNCS GetClientAPI; // single export
|
CL_EXPORT_FUNCS GetClientAPI; // single export
|
||||||
qboolean critical_exports = true;
|
qboolean valid_single_export = false;
|
||||||
|
qboolean missed_exports = false;
|
||||||
|
int i;
|
||||||
|
|
||||||
if( clgame.hInstance ) CL_UnloadProgs();
|
if( clgame.hInstance ) CL_UnloadProgs();
|
||||||
|
|
||||||
|
@ -4063,8 +4062,8 @@ qboolean CL_LoadProgs( const char *name )
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear exports
|
// clear exports
|
||||||
for( func = cdll_exports; func && func->name; func++ )
|
for( i = 0; i < ARRAYSIZE( cdll_exports ); i++ )
|
||||||
*func->func = NULL;
|
*(cdll_exports[i].func) = NULL;
|
||||||
|
|
||||||
// trying to get single export
|
// trying to get single export
|
||||||
if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL )
|
if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL )
|
||||||
|
@ -4082,56 +4081,59 @@ qboolean CL_LoadProgs( const char *name )
|
||||||
CL_GetSecuredClientAPI( GetClientAPI );
|
CL_GetSecuredClientAPI( GetClientAPI );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( GetClientAPI != NULL )
|
if( GetClientAPI != NULL )
|
||||||
{
|
{
|
||||||
// check critical functions again
|
// check critical functions again
|
||||||
for( func = cdll_exports; func && func->name; func++ )
|
for( i = 0; i < ARRAYSIZE( cdll_exports ); i++ )
|
||||||
{
|
{
|
||||||
if( func->func == NULL )
|
if( *(cdll_exports[i].func) == NULL )
|
||||||
break; // BAH critical function was missed
|
break; // BAH critical function was missed
|
||||||
}
|
}
|
||||||
|
|
||||||
// because all the exports are loaded through function 'F"
|
// everything was loaded
|
||||||
if( !func || !func->name )
|
if( i == ARRAYSIZE( cdll_exports ))
|
||||||
critical_exports = false;
|
valid_single_export = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( func = cdll_exports; func && func->name != NULL; func++ )
|
for( i = 0; i < ARRAYSIZE( cdll_exports ); i++ )
|
||||||
{
|
{
|
||||||
if( *func->func != NULL )
|
if( *(cdll_exports[i].func) != NULL )
|
||||||
continue; // already get through 'F'
|
continue; // already gott through 'F' or 'GetClientAPI'
|
||||||
|
|
||||||
// functions are cleared before all the extensions are evaluated
|
// functions are cleared before all the extensions are evaluated
|
||||||
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
|
if(( *(cdll_exports[i].func) = (void *)COM_GetProcAddress( clgame.hInstance, cdll_exports[i].name )) == NULL )
|
||||||
{
|
{
|
||||||
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
|
Con_Reportf( S_ERROR "%s: failed to get address of %s proc\n", __func__, cdll_exports[i].name );
|
||||||
|
|
||||||
if( critical_exports )
|
// print all not found exports at once, for debug
|
||||||
|
missed_exports = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( missed_exports )
|
||||||
{
|
{
|
||||||
COM_FreeLibrary( clgame.hInstance );
|
COM_FreeLibrary( clgame.hInstance );
|
||||||
clgame.hInstance = NULL;
|
clgame.hInstance = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// it may be loaded through 'GetClientAPI' so we don't need to clear them
|
// it may be loaded through 'GetClientAPI' so we don't need to clear them
|
||||||
if( critical_exports )
|
if( !valid_single_export )
|
||||||
{
|
{
|
||||||
// clear new exports
|
// clear new exports
|
||||||
for( func = cdll_new_exports; func && func->name; func++ )
|
for( i = 0; i < ARRAYSIZE( cdll_new_exports ); i++ )
|
||||||
*func->func = NULL;
|
*(cdll_new_exports[i].func) = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( func = cdll_new_exports; func && func->name != NULL; func++ )
|
for( i = 0; i < ARRAYSIZE( cdll_new_exports ); i++ )
|
||||||
{
|
{
|
||||||
if( *func->func != NULL )
|
if( *(cdll_new_exports[i].func) != NULL )
|
||||||
continue; // already get through 'F'
|
continue; // already gott through 'F' or 'GetClientAPI'
|
||||||
|
|
||||||
// functions are cleared before all the extensions are evaluated
|
// functions are cleared before all the extensions are evaluated
|
||||||
// NOTE: new exports can be missed without stop the engine
|
// NOTE: new exports can be missed without stop the engine
|
||||||
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
|
if(( *(cdll_new_exports[i].func) = (void *)COM_GetProcAddress( clgame.hInstance, cdll_new_exports[i].name )) == NULL )
|
||||||
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
|
Con_Reportf( S_WARN "%s: failed to get address of %s proc\n", __func__, cdll_new_exports[i].name );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
|
if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
|
||||||
|
|
Loading…
Add table
Reference in a new issue