Skip to content

Commit

Permalink
Shared: Merge ioquake/ioq3@376267d
Browse files Browse the repository at this point in the history
Don't load .pk3s as .dlls, and don't load user config files from .pk3s.
  • Loading branch information
ensiform committed Mar 14, 2017
1 parent b823aa7 commit 8956a35
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ void CL_InitRef( void ) {
GetRefAPI_t GetRefAPI;

Com_Printf( "----- Initializing Renderer ----\n" );
cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH );
cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH|CVAR_PROTECTED );

Com_sprintf( dllName, sizeof( dllName ), "%s_" ARCH_STRING DLL_EXT, cl_renderer->string );

Expand Down
8 changes: 8 additions & 0 deletions code/qcommon/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique
long hash;
//unz_s *zfi;
//void *temp;
bool isUserConfig = false;

hash = 0;

Expand Down Expand Up @@ -1291,6 +1292,8 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique
return -1;
}

isUserConfig = !Q_stricmp( filename, "autoexec_sp.cfg" ) || !Q_stricmp( filename, Q3CONFIG_NAME );

//
// search through the path, one element at a time
//
Expand All @@ -1316,6 +1319,11 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique
}
// is the element a pak file?
if ( search->pack && search->pack->hashTable[hash] ) {
// autoexec_sp.cfg and openjk_sp.cfg can only be loaded outside of pk3 files.
if ( isUserConfig ) {
continue;
}

// look through all the pak file elements
pak = search->pack;
pakFile = pak->hashTable[hash];
Expand Down
2 changes: 1 addition & 1 deletion codemp/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,7 @@ void CL_InitRef( void ) {

Com_Printf( "----- Initializing Renderer ----\n" );

cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH, "Which renderer library to use" );
cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH|CVAR_PROTECTED, "Which renderer library to use" );

Com_sprintf( dllName, sizeof( dllName ), "%s_" ARCH_STRING DLL_EXT, cl_renderer->string );

Expand Down
8 changes: 8 additions & 0 deletions codemp/qcommon/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,7 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique
//unz_s *zfi;
//void *temp;
int l;
bool isUserConfig = false;

hash = 0;

Expand Down Expand Up @@ -1300,6 +1301,8 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique
return -1;
}

isUserConfig = !Q_stricmp( filename, "autoexec.cfg" ) || !Q_stricmp( filename, Q3CONFIG_CFG );

//
// search through the path, one element at a time
//
Expand Down Expand Up @@ -1330,6 +1333,11 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique
continue;
}

// autoexec.cfg and openjk.cfg can only be loaded outside of pk3 files.
if ( isUserConfig ) {
continue;
}

// look through all the pak file elements
pak = search->pack;
pakFile = pak->hashTable[hash];
Expand Down
7 changes: 7 additions & 0 deletions shared/sys/sys_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ void *Sys_LoadDll( const char *name, qboolean useSystemLib )
{
void *dllhandle = NULL;

// Don't load any DLLs that end with the pk3 extension
if ( COM_CompareExtension( name, ".pk3" ) )
{
Com_Printf( S_COLOR_YELLOW "WARNING: Rejecting DLL named \"%s\"", name );
return NULL;
}

if ( useSystemLib )
{
Com_Printf( "Trying to load \"%s\"...\n", name );
Expand Down

0 comments on commit 8956a35

Please sign in to comment.