summaryrefslogtreecommitdiff
path: root/src/renderer/tr_shader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/tr_shader.c')
-rw-r--r--src/renderer/tr_shader.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/renderer/tr_shader.c b/src/renderer/tr_shader.c
index 8e86a73f..bfcd47d3 100644
--- a/src/renderer/tr_shader.c
+++ b/src/renderer/tr_shader.c
@@ -2328,11 +2328,15 @@ static char *FindShaderInShaderText( const char *shadername ) {
hash = generateHashValue(shadername, MAX_SHADERTEXT_HASH);
- for (i = 0; shaderTextHashTable[hash][i]; i++) {
- p = shaderTextHashTable[hash][i];
- token = COM_ParseExt(&p, qtrue);
- if ( !Q_stricmp( token, shadername ) ) {
- return p;
+ if(shaderTextHashTable[hash])
+ {
+ for (i = 0; shaderTextHashTable[hash][i]; i++)
+ {
+ p = shaderTextHashTable[hash][i];
+ token = COM_ParseExt(&p, qtrue);
+
+ if(!Q_stricmp(token, shadername))
+ return p;
}
}
@@ -2867,7 +2871,6 @@ void R_ShaderList_f (void) {
ri.Printf (PRINT_ALL, "------------------\n");
}
-
/*
====================
ScanAndLoadShaderFiles
@@ -2884,7 +2887,7 @@ static void ScanAndLoadShaderFiles( void )
char *p;
int numShaderFiles;
int i;
- char *oldp, *token, *hashMem;
+ char *oldp, *token, *hashMem, *textEnd;
int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size;
long sum = 0, summand;
@@ -2945,20 +2948,22 @@ static void ScanAndLoadShaderFiles( void )
// build single large buffer
s_shaderText = ri.Hunk_Alloc( sum + numShaderFiles*2, h_low );
s_shaderText[ 0 ] = '\0';
-
+ textEnd = s_shaderText;
+
// free in reverse order, so the temp files are all dumped
for ( i = numShaderFiles - 1; i >= 0 ; i-- )
{
- if(buffers[i])
- {
- p = &s_shaderText[strlen(s_shaderText)];
- strcat( s_shaderText, buffers[i] );
- ri.FS_FreeFile( buffers[i] );
- COM_Compress(p);
- strcat( s_shaderText, "\n" );
- }
+ if ( !buffers[i] )
+ continue;
+
+ strcat( textEnd, buffers[i] );
+ strcat( textEnd, "\n" );
+ textEnd += strlen( textEnd );
+ ri.FS_FreeFile( buffers[i] );
}
+ COM_Compress( s_shaderText );
+
// free up memory
ri.FS_FreeFileList( shaderFiles );