X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fmain.cpp;h=5958a92ae59b9cee7d571f40ae56818dd1507310;hb=b4ffa23e2beb6d10f8f5f2fccd4b41fb3e344759;hp=b1d0cedb55bfd8e2cd1e3572db4d99927d014195;hpb=d6070419a90f036f00b640d5a9d0efdd8a2975a4;p=supertux.git diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index b1d0cedb5..5958a92ae 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -31,12 +31,6 @@ extern "C" { #include "video/renderer.hpp" #include "supertux/main.hpp" -#ifdef MACOSX -namespace supertux_apple { -# include -} // namespace supertux_apple -#endif - #include "addon/addon_manager.hpp" #include "audio/sound_manager.hpp" #include "control/joystickkeyboardcontroller.hpp" @@ -149,7 +143,10 @@ Main::init_physfs(const char* argv0) PHYSFS_addToSearchPath(writedir.c_str(), 0); // when started from source dir... - std::string dir = PHYSFS_getBaseDir(); + char* base_path = SDL_GetBasePath(); + std::string dir = base_path; + SDL_free(base_path); + if (dir[dir.length() - 1] != '/') dir += "/"; dir += "data"; @@ -166,44 +163,6 @@ Main::init_physfs(const char* argv0) } } -#ifdef MACOSX - { - using namespace supertux_apple; - - // when started from Application file on Mac OS X... - char path[PATH_MAX]; - CFBundleRef mainBundle = CFBundleGetMainBundle(); - if(mainBundle == 0) - throw "Assertion failed: mainBundle != 0"; - CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); - if(mainBundleURL == 0) - throw "Assertion failed: mainBundleURL != 0"; - CFStringRef pathStr = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle); - if(pathStr == 0) - throw "Assertion failed: pathStr != 0"; - CFStringGetCString(pathStr, path, PATH_MAX, kCFStringEncodingUTF8); - CFRelease(mainBundleURL); - CFRelease(pathStr); - - dir = std::string(path) + "/Contents/Resources/data"; - testfname = dir + "/credits.txt"; - sourcedir = false; - f = fopen(testfname.c_str(), "r"); - if(f) { - fclose(f); - if(!PHYSFS_addToSearchPath(dir.c_str(), 1)) { - log_warning << "Couldn't add '" << dir << "' to physfs searchpath: " << PHYSFS_getLastError() << std::endl; - } else { - sourcedir = true; - } - } - } -#endif - -#ifdef _WIN32 - PHYSFS_addToSearchPath(".\\data", 1); -#endif - if(!sourcedir) { std::string datadir = PHYSFS_getBaseDir(); datadir = datadir.substr(0, datadir.rfind(INSTALL_SUBDIR_BIN)); @@ -422,7 +381,6 @@ Main::parse_commandline(int argc, char** argv) g_config->start_level = arg; } else { log_warning << "Unknown option '" << arg << "'. Use --help to see a list of options" << std::endl; - return true; } } @@ -623,6 +581,11 @@ Main::run(int argc, char** argv) // we have a normal path specified at commandline, not a physfs path. // So we simply mount that path here... std::string dir = FileSystem::dirname(g_config->start_level); + std::string fileProtocol = "file://"; + int position = dir.find(fileProtocol); + if(position != std::string::npos) { + dir = dir.replace(position, fileProtocol.length(), ""); + } log_debug << "Adding dir: " << dir << std::endl; PHYSFS_addToSearchPath(dir.c_str(), true);