aboutsummaryrefslogtreecommitdiffstats
path: root/code/renderer
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-08-23 00:22:20 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-08-23 00:22:20 +0000
commit3ac0cab7a7a47a07b71755c59bab24e0b70088bd (patch)
tree08f539ee044c124f4878c7a945922e4c59e99fcd /code/renderer
parent37c20d0ddfb0b25296cabe9755231ceb2b43dedd (diff)
downloadioquake3-aero-3ac0cab7a7a47a07b71755c59bab24e0b70088bd.tar.gz
ioquake3-aero-3ac0cab7a7a47a07b71755c59bab24e0b70088bd.zip
* (bug 3076) Map cycle breaks on empty or bot only servers (misanthropia)
* (bug 3303) Removal of never compiled code from cgame drawing functions (beast <info@dbwatersports.com>) * (bug 3297) Add missing limit to Q3 UI server info (beast <info@dbwatersports.com>) * (bug 3029) Fix to shader hash table being overpopulated (identified by Stefan "#@" Langer <raute_at@gmx.de>) git-svn-id: svn://svn.icculus.org/quake3/trunk@1129 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/renderer')
-rw-r--r--code/renderer/tr_shader.c84
1 files changed, 33 insertions, 51 deletions
diff --git a/code/renderer/tr_shader.c b/code/renderer/tr_shader.c
index 7e4fc2a..edcf2bc 100644
--- a/code/renderer/tr_shader.c
+++ b/code/renderer/tr_shader.c
@@ -2866,27 +2866,27 @@ static void ScanAndLoadShaderFiles( void )
char **shaderFiles;
char *buffers[MAX_SHADER_FILES];
char *p;
- int numShaders;
+ int numShaderFiles;
int i;
char *oldp, *token, *hashMem;
int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size;
long sum = 0;
// scan for shader files
- shaderFiles = ri.FS_ListFiles( "scripts", ".shader", &numShaders );
+ shaderFiles = ri.FS_ListFiles( "scripts", ".shader", &numShaderFiles );
- if ( !shaderFiles || !numShaders )
+ if ( !shaderFiles || !numShaderFiles )
{
ri.Printf( PRINT_WARNING, "WARNING: no shader files found\n" );
return;
}
- if ( numShaders > MAX_SHADER_FILES ) {
- numShaders = MAX_SHADER_FILES;
+ if ( numShaderFiles > MAX_SHADER_FILES ) {
+ numShaderFiles = MAX_SHADER_FILES;
}
// load and parse shader files
- for ( i = 0; i < numShaders; i++ )
+ for ( i = 0; i < numShaderFiles; i++ )
{
char filename[MAX_QPATH];
@@ -2899,16 +2899,16 @@ static void ScanAndLoadShaderFiles( void )
}
// build single large buffer
- s_shaderText = ri.Hunk_Alloc( sum + numShaders*2, h_low );
+ s_shaderText = ri.Hunk_Alloc( sum + numShaderFiles*2, h_low );
+ s_shaderText[ 0 ] = '\0';
// free in reverse order, so the temp files are all dumped
- for ( i = numShaders - 1; i >= 0 ; i-- ) {
- strcat( s_shaderText, "\n" );
+ for ( i = numShaderFiles - 1; i >= 0 ; i-- ) {
p = &s_shaderText[strlen(s_shaderText)];
strcat( s_shaderText, buffers[i] );
ri.FS_FreeFile( buffers[i] );
- buffers[i] = p;
COM_Compress(p);
+ strcat( s_shaderText, "\n" );
}
// free up memory
@@ -2916,28 +2916,19 @@ static void ScanAndLoadShaderFiles( void )
Com_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes));
size = 0;
- //
- for ( i = 0; i < numShaders; i++ ) {
- // pointer to the first shader file
- p = buffers[i];
- // look for label
- while ( 1 ) {
- token = COM_ParseExt( &p, qtrue );
- if ( token[0] == 0 ) {
- break;
- }
- hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
- shaderTextHashTableSizes[hash]++;
- size++;
- SkipBracedSection(&p);
- // if we passed the pointer to the next shader file
- if ( i < numShaders - 1 ) {
- if ( p > buffers[i+1] ) {
- break;
- }
- }
+ p = s_shaderText;
+ // look for shader names
+ while ( 1 ) {
+ token = COM_ParseExt( &p, qtrue );
+ if ( token[0] == 0 ) {
+ break;
}
+
+ hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
+ shaderTextHashTableSizes[hash]++;
+ size++;
+ SkipBracedSection(&p);
}
size += MAX_SHADERTEXT_HASH;
@@ -2950,29 +2941,20 @@ static void ScanAndLoadShaderFiles( void )
}
Com_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes));
- //
- for ( i = 0; i < numShaders; i++ ) {
- // pointer to the first shader file
- p = buffers[i];
- // look for label
- while ( 1 ) {
- oldp = p;
- token = COM_ParseExt( &p, qtrue );
- if ( token[0] == 0 ) {
- break;
- }
-
- hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
- shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp;
- SkipBracedSection(&p);
- // if we passed the pointer to the next shader file
- if ( i < numShaders - 1 ) {
- if ( p > buffers[i+1] ) {
- break;
- }
- }
+ p = s_shaderText;
+ // look for shader names
+ while ( 1 ) {
+ oldp = p;
+ token = COM_ParseExt( &p, qtrue );
+ if ( token[0] == 0 ) {
+ break;
}
+
+ hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
+ shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp;
+
+ SkipBracedSection(&p);
}
return;