- // if the game is not run from the source directory, try to find
- // the global install location
- datadir = datadir.substr(0, datadir.rfind(INSTALL_SUBDIR_BIN));
- datadir = FileSystem::join(datadir, INSTALL_SUBDIR_SHARE);
+ // check if we run from source dir
+ char* basepath_c = SDL_GetBasePath();
+ std::string basepath = basepath_c;
+ SDL_free(basepath_c);
+
+ datadir = FileSystem::join(basepath, "data");
+ std::string testfname = FileSystem::join(datadir, "credits.txt");
+ if (!FileSystem::exists(testfname))
+ {
+ // if the game is not run from the source directory, try to find
+ // the global install location
+ datadir = datadir.substr(0, datadir.rfind(INSTALL_SUBDIR_BIN));
+ datadir = FileSystem::join(datadir, INSTALL_SUBDIR_SHARE);
+ }