mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Replace other usage of PHYSFS_getBaseDir() with SDL_GetBasePath()
Ethan, you forgot this other one. I do have to rejiggle the control flow of the function a bit, so it doesn't leak memory upon failure. (Although the SDL message box leaks memory anyway because of X11 so... whatever.) Also, there's a NULL check for if SDL_GetBasePath() fails now.
This commit is contained in:
parent
051fe9eba9
commit
a405635cb2
1 changed files with 18 additions and 5 deletions
|
@ -54,7 +54,9 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
|
||||||
{
|
{
|
||||||
char output[MAX_PATH];
|
char output[MAX_PATH];
|
||||||
int mkdirResult;
|
int mkdirResult;
|
||||||
|
int retval;
|
||||||
const char* pathSep = PHYSFS_getDirSeparator();
|
const char* pathSep = PHYSFS_getDirSeparator();
|
||||||
|
char* basePath;
|
||||||
|
|
||||||
PHYSFS_setAllocator(&allocator);
|
PHYSFS_setAllocator(&allocator);
|
||||||
PHYSFS_init(argvZero);
|
PHYSFS_init(argvZero);
|
||||||
|
@ -110,6 +112,14 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
|
||||||
PLATFORM_migrateSaveData(output);
|
PLATFORM_migrateSaveData(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
basePath = SDL_GetBasePath();
|
||||||
|
|
||||||
|
if (basePath == NULL)
|
||||||
|
{
|
||||||
|
puts("Unable to get base path!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mount the stock content last */
|
/* Mount the stock content last */
|
||||||
if (assetsPath)
|
if (assetsPath)
|
||||||
{
|
{
|
||||||
|
@ -117,12 +127,10 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *basePath = SDL_GetBasePath();
|
|
||||||
SDL_snprintf(output, sizeof(output), "%s%s",
|
SDL_snprintf(output, sizeof(output), "%s%s",
|
||||||
basePath,
|
basePath,
|
||||||
"data.zip"
|
"data.zip"
|
||||||
);
|
);
|
||||||
SDL_free(basePath);
|
|
||||||
}
|
}
|
||||||
if (!PHYSFS_mount(output, NULL, 1))
|
if (!PHYSFS_mount(output, NULL, 1))
|
||||||
{
|
{
|
||||||
|
@ -139,15 +147,20 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
|
||||||
"\nor get it from the free Make and Play Edition.",
|
"\nor get it from the free Make and Play Edition.",
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
return 0;
|
retval = 0;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_snprintf(output, sizeof(output), "%s%s", PHYSFS_getBaseDir(), "gamecontrollerdb.txt");
|
SDL_snprintf(output, sizeof(output), "%s%s", basePath, "gamecontrollerdb.txt");
|
||||||
if (SDL_GameControllerAddMappingsFromFile(output) < 0)
|
if (SDL_GameControllerAddMappingsFromFile(output) < 0)
|
||||||
{
|
{
|
||||||
printf("gamecontrollerdb.txt not found!\n");
|
printf("gamecontrollerdb.txt not found!\n");
|
||||||
}
|
}
|
||||||
return 1;
|
retval = 1;
|
||||||
|
|
||||||
|
end:
|
||||||
|
SDL_free(basePath);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FILESYSTEM_deinit(void)
|
void FILESYSTEM_deinit(void)
|
||||||
|
|
Loading…
Reference in a new issue