]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
image: Check if file exists first to allow early out and avoid a slower codepath
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 Nov 2020 06:25:13 +0000 (06:25 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 Nov 2020 06:25:13 +0000 (06:25 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13040 d7cf8633-e32d-0410-b094-e92efae38249

image.c

diff --git a/image.c b/image.c
index ceecd249e999c3bf3998989c21026fb7b4e8da48..9f07ce60f174a955f89474114062eb19bb8358eb 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1084,8 +1084,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qbool complain, qbool
        for (format = firstformat;format->formatstring;format++)
        {
                dpsnprintf (name, sizeof(name), format->formatstring, basename);
-               f = FS_LoadFile(name, tempmempool, true, &filesize);
-               if (f)
+               if(FS_FileExists(name) && (f = FS_LoadFile(name, tempmempool, true, &filesize)) != NULL)
                {
                        mymiplevel = miplevel ? *miplevel : 0;
                        image_width = 0;