mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Return early if FILESYSTEM_mountassets() fails
This way, we avoid the unnecessary graphics.reloadresources() call - if we can't mount assets, why bother reloading resources? The return type of FILESYSTEM_mount() has been changed from void to bool to indicate success, accomodating its callers accordingly.
This commit is contained in:
parent
1e375f9ecf
commit
9c8ecdb0f4
1 changed files with 19 additions and 13 deletions
|
@ -213,7 +213,7 @@ static bool FILESYSTEM_exists(const char *fname)
|
|||
return PHYSFS_exists(fname);
|
||||
}
|
||||
|
||||
static void FILESYSTEM_mount(const char *fname)
|
||||
static bool FILESYSTEM_mount(const char *fname)
|
||||
{
|
||||
const char* real_dir = PHYSFS_getRealDir(fname);
|
||||
const char* dir_separator;
|
||||
|
@ -225,7 +225,7 @@ static void FILESYSTEM_mount(const char *fname)
|
|||
"Could not mount %s: real directory doesn't exist\n",
|
||||
fname
|
||||
);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
dir_separator = PHYSFS_getDirSeparator();
|
||||
|
@ -235,11 +235,11 @@ static void FILESYSTEM_mount(const char *fname)
|
|||
if (!PHYSFS_mount(path, NULL, 0))
|
||||
{
|
||||
printf("Error mounting: %s\n", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SDL_strlcpy(assetDir, path, sizeof(assetDir));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FILESYSTEM_loadZip(const char* filename)
|
||||
|
@ -298,7 +298,10 @@ void FILESYSTEM_mountassets(const char* path)
|
|||
{
|
||||
printf("Custom asset directory is .data.zip at %s\n", zip_data);
|
||||
|
||||
FILESYSTEM_mount(zip_data);
|
||||
if (!FILESYSTEM_mount(zip_data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.reloadresources();
|
||||
}
|
||||
|
@ -321,18 +324,18 @@ void FILESYSTEM_mountassets(const char* path)
|
|||
"Error loading .zip: %s\n",
|
||||
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
|
||||
);
|
||||
return;
|
||||
}
|
||||
else if (PHYSFS_mountHandle(zip, zip_data, "/", 0) == 0)
|
||||
if (PHYSFS_mountHandle(zip, zip_data, "/", 0) == 0)
|
||||
{
|
||||
printf(
|
||||
"Error mounting .zip: %s\n",
|
||||
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
|
||||
);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SDL_strlcpy(assetDir, zip_data, sizeof(assetDir));
|
||||
}
|
||||
|
||||
graphics.reloadresources();
|
||||
}
|
||||
|
@ -340,7 +343,10 @@ void FILESYSTEM_mountassets(const char* path)
|
|||
{
|
||||
printf("Custom asset directory exists at %s\n", dir);
|
||||
|
||||
FILESYSTEM_mount(dir);
|
||||
if (!FILESYSTEM_mount(dir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.reloadresources();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue