From 124d77c04109ba0b21ecad0ee40dc7f6c7c56d35 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 18 Aug 2021 09:57:55 -0700 Subject: [PATCH] Don't use PHYSFS_getRealDir() to check for .zip Not sure why the original implementation decided to do things this way instead of snprintf'ing a path to the .zip itself. Otherwise, if the level is from data.zip, PHYSFS_getRealDir() will return the path of data.zip, which then fails to mount for separate reasons. --- desktop_version/src/FileSystemUtils.cpp | 48 ++++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 683b6080..ffb6bd96 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -513,13 +513,10 @@ bool FILESYSTEM_mountAssets(const char* path) { char filename[MAX_PATH]; char virtual_path[MAX_PATH]; - const char* real_path; VVV_between(path, "levels/", filename, ".vvvvvv"); - real_path = PHYSFS_getRealDir(path); - - /* Check for a zipped up level pack first */ + /* Check for a zipped up pack only containing assets first */ SDL_snprintf( virtual_path, sizeof(virtual_path), @@ -537,30 +534,18 @@ bool FILESYSTEM_mountAssets(const char* path) MAYBE_FAIL(graphics.reloadresources()); } - else if (real_path != NULL && endsWith(real_path, ".zip")) - { - /* This is a base zip, probably the official data.zip */ - printf("Asset directory is .zip at %s\n", real_path); - - if (!FILESYSTEM_mountAssetsFrom(real_path)) - { - return false; - } - - MAYBE_FAIL(graphics.reloadresources()); - } else { - /* If it's not a level or base zip, look for a level folder */ SDL_snprintf( virtual_path, sizeof(virtual_path), - "levels/%s/", + "levels/%s.zip", filename ); if (FILESYSTEM_exists(virtual_path)) { - printf("Asset directory exists at %s\n", virtual_path); + /* This is a full zipped-up level including assets */ + printf("Asset directory is .zip at %s\n", virtual_path); if (!FILESYSTEM_mountAssetsFrom(virtual_path)) { @@ -571,8 +556,29 @@ bool FILESYSTEM_mountAssets(const char* path) } else { - /* Wasn't a level zip, base zip, or folder! */ - puts("Asset directory does not exist"); + /* If it's not a level or base zip, look for a level folder */ + SDL_snprintf( + virtual_path, + sizeof(virtual_path), + "levels/%s/", + filename + ); + if (FILESYSTEM_exists(virtual_path)) + { + printf("Asset directory exists at %s\n", virtual_path); + + if (!FILESYSTEM_mountAssetsFrom(virtual_path)) + { + return false; + } + + MAYBE_FAIL(graphics.reloadresources()); + } + else + { + /* Wasn't a level zip, base zip, or folder! */ + puts("Asset directory does not exist"); + } } }