Skip to content

Commit

Permalink
Fix EasyRPG#1175: Use default project-path under OSX
Browse files Browse the repository at this point in the history
This also tries to simplify project path finding it on all platforms.
  • Loading branch information
carstene1ns committed May 25, 2017
1 parent fc7f30a commit 74b02f6
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/main_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ void Main_Data::Init() {
"";

if (project_path.empty()) {
// first set to current directory for all platforms
project_path = ".";

#ifdef GEKKO
// Working directory not correctly handled under Wii
char gekko_dir[256];
Expand All @@ -88,8 +91,9 @@ void Main_Data::Init() {
#elif defined(PSP2)
// Check if app0 filesystem contains the title id reference file
FILE* f = fopen("app0:/titleid.txt","r");
if (f == NULL) project_path = "ux0:/data/easyrpg-player";
else{
if (f == NULL)
project_path = "ux0:/data/easyrpg-player";
else {
char titleID[10];
char psp2_dir[256];
fread(titleID, 1, 9, f);
Expand All @@ -104,10 +108,10 @@ void Main_Data::Init() {

}
#elif defined(_3DS)
# ifndef CITRA3DS_COMPATIBLE
# ifndef CITRA3DS_COMPATIBLE
// Check if romFs has some files inside or not
FILE* testfile = fopen("romfs:/RPG_RT.lmt","r");
if (testfile != NULL){
if (testfile != NULL) {
Output::Debug("Detected a project on romFs filesystem...");
fclose(testfile);
project_path = "romfs:";
Expand Down Expand Up @@ -136,33 +140,24 @@ void Main_Data::Init() {
} else if (!Player::is_3dsx) {
// No RomFS -> load games from hardcoded path
project_path = "sdmc:/3ds/easyrpg-player";
} else {
project_path = ".";
}
# else
project_path = ".";
# endif
# endif
#elif defined(__APPLE__) && defined(__MACH__)
# if SDL_MAJOR_VERSION>1
// Apple Finder does not set the working directory
// It points to HOME instead. When it is HOME change it to
// the application directory instead
char* home = getenv("HOME");
char current_dir[255] = { 0 };
getcwd(current_dir, sizeof(current_dir));
if (!strcmp(current_dir, home)) {
// Apple Finder does not set the working directory
// It points to HOME instead. When it is HOME change it to
// the application directory instead

// FIXME: Uses SDL API
char* data_dir = SDL_GetBasePath();
project_path = data_dir;

free(data_dir);
}
# else
project_path = ".";
# endif
#else
project_path = ".";
#endif
}
}
Expand Down

0 comments on commit 74b02f6

Please sign in to comment.