1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Add -basedir option to specify base user directory (#154)

Useful for maintaining multiple save files or for debugging
This commit is contained in:
Matt Penny 2020-02-08 18:49:03 -05:00 committed by GitHub
parent 93ec5783d5
commit dd7170dc59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 7 deletions

View file

@ -3,6 +3,7 @@ Contributors
(Ordered alphabetically by last name.)
* Matt "Stelpjo" Aaldenberg
* Christoph Böhmwalder (@chrboe)
* Charlie Bruce (@charliebruce)
* Brian Callahan (@ibara)
@ -10,6 +11,7 @@ Contributors
* Allison Fleischer (AllisonFleischer)
* Daniel Lee (@ddm999)
* Fredrik Ljungdahl (@FredrIQ)
* Matt Penny (@mwpenny)
* Elliott Saltar (@eboyblue3)
* Marvin Scholz (@ePirat)
* Keith Stellyes (@keithstellyes)
@ -22,4 +24,3 @@ Contributors
* Rémi Verschelde (@akien-mga)
* viri (viri.me)
* Wouter (Xesxen)
* Matt "Stelpjo" Aaldenberg

View file

@ -39,16 +39,30 @@ void PLATFORM_getOSDirectory(char* output);
void PLATFORM_migrateSaveData(char* output);
void PLATFORM_copyFile(const char *oldLocation, const char *newLocation);
int FILESYSTEM_init(char *argvZero, char *assetsPath)
int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
{
char output[MAX_PATH];
int mkdirResult;
const char* pathSep = PHYSFS_getDirSeparator();
PHYSFS_init(argvZero);
PHYSFS_permitSymbolicLinks(1);
/* Determine the OS user directory */
if (baseDir && strlen(baseDir) > 0)
{
strcpy(output, baseDir);
/* We later append to this path and assume it ends in a slash */
if (strcmp(std::string(1, output[strlen(output) - 1]).c_str(), pathSep) != 0)
{
strcat(output, pathSep);
}
}
else
{
PLATFORM_getOSDirectory(output);
}
/* Create base user directory, mount */
mkdirResult = mkdir(output, 0777);

View file

@ -6,7 +6,7 @@
#include "tinyxml.h"
int FILESYSTEM_init(char *argvZero, char* assetsPath);
int FILESYSTEM_init(char *argvZero, char* baseDir, char* assetsPath);
void FILESYSTEM_deinit();
char *FILESYSTEM_getUserSaveDirectory();

View file

@ -468,12 +468,15 @@ void Game::init(void)
patrons.push_back("Timothy Bragan");
/* CONTRIBUTORS.txt, again listed alphabetically (according to `sort`) by last name */
githubfriends.push_back("Matt \"Stelpjo\" Aaldenberg");
githubfriends.push_back("Christoph B{hmwalder");
githubfriends.push_back("Charlie Bruce");
githubfriends.push_back("Brian Callahan");
githubfriends.push_back("Dav999");
githubfriends.push_back("Allison Fleischer");
githubfriends.push_back("Daniel Lee");
githubfriends.push_back("Fredrik Ljungdahl");
githubfriends.push_back("Matt Penny");
githubfriends.push_back("Elliott Saltar");
githubfriends.push_back("Marvin Scholz");
githubfriends.push_back("Keith Stellyes");

View file

@ -51,19 +51,23 @@ int main(int argc, char *argv[])
SDL_INIT_GAMECONTROLLER
);
char* assets = NULL;
char* baseDir = NULL;
char* assetsPath = NULL;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-renderer") == 0) {
++i;
SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, argv[i], SDL_HINT_OVERRIDE);
} else if (strcmp(argv[i], "-basedir") == 0) {
++i;
baseDir = argv[i];
} else if (strcmp(argv[i], "-assets") == 0) {
++i;
assets = argv[i];
assetsPath = argv[i];
}
}
if(!FILESYSTEM_init(argv[0], assets))
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath))
{
return 1;
}