From baa6eb2cc408908a1382f2180cf96017baaa29e1 Mon Sep 17 00:00:00 2001 From: myT Date: Fri, 29 Mar 2019 23:34:37 +0100 Subject: [PATCH] added .shader to the pure client file read exception list --- changelog.txt | 2 ++ code/qcommon/files.cpp | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/changelog.txt b/changelog.txt index 37fe8a7..3930a2b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -40,6 +40,8 @@ chg: faster map loads by limiting the rendering back-end's frame-rate chg: on Windows, the upper limit of open stdio file handles was raised from 512 to 2048 +fix: the presence of .shader files outside of PK3s no longer triggers a drop error + fix: shader stage collapsing was happening in cases where it would yield incorrect results fix: map download improvements diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index 1e5cdf4..89f2c5c 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -837,19 +837,22 @@ qbool FS_FilenameCompare( const char *s1, const char *s2 ) { static qbool FS_IsPureClientReadException( const char* filename ) { - const int l = strlen( filename ); - if ( l < 5 ) + static const char* extensions[] = { ".cfg", ".ttf", ".dat", ".jpg", ".jpeg", ".tga", ".png", ".shader" }; + const int shortestExtLength = 3; + + const int nameLength = strlen(filename); + if (nameLength < shortestExtLength + 2) return qfalse; - const char* const s4 = filename + l - 4; - const char* const s5 = filename + l - 5; - return !Q_stricmp( s4, ".cfg" ) || - !Q_stricmp( s4, ".ttf" ) || - !Q_stricmp( s4, ".dat" ) || - !Q_stricmp( s4, ".jpg" ) || - !Q_stricmp( s4, ".tga" ) || - !Q_stricmp( s4, ".png" ) || - !Q_stricmp( s5, ".jpeg" ); + for (int i = 0; i < ARRAY_LEN(extensions); ++i) { + const char* const ext = extensions[i]; + const int extLength = strlen(ext); + + if (nameLength > extLength && !Q_strncmp(filename + nameLength - extLength, ext, extLength)) + return qtrue; + } + + return qfalse; }