diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 8fea5e2..6d6cc0e 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -805,6 +805,11 @@ void DSQ::init() // steam gets inited in here Core::init(); +#ifdef AQUARIA_DEBUG_SHOW_PATHS + errorLog("AQUARIA_DEBUG_SHOW_PATHS:\n" + getPathInfoStr()); +#endif + + loadStringBank(); vars = &v; @@ -848,7 +853,15 @@ void DSQ::init() - user.load(false); + if(!user.load(false)) + { + errorLog("Failed to load user settings, loading defaults"); + + if(!user.loadDefaults(false)) + { + errorLog("Failed to load default user settings (default_usersettings.xml)! Controls may be broken.\n"); + } + } particleManager->setSize(user.video.numParticles); diff --git a/BBGE/Base.cpp b/BBGE/Base.cpp index 6f89763..9c4d0d4 100644 --- a/BBGE/Base.cpp +++ b/BBGE/Base.cpp @@ -23,6 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "OSFunctions.h" +#if SDL_VERSION_ATLEAST(2,0,0) +#include "SDL_filesystem.h" +#endif + #ifdef BBGE_BUILD_VFS # include "ttvfs.h" # ifndef VFS_IGNORE_CASE @@ -253,10 +257,29 @@ bool exists(const std::string &f, bool makeFatal, bool skipVFS) +std::string getPathInfoStr() +{ + std::ostringstream os; + os << "Working dir (expecting game data there):\n" << getWorkingDir() << "\n"; + if(core) + { + os << "Preferences folder:\n" << core->getPreferencesFolder() << "\n"; + os << "User data folder:\n" << core->getUserDataFolder() << "\n"; + os << "Debug log path:\n" << core->getDebugLogPath() << "\n"; + } +#if SDL_VERSION_ATLEAST(2,0,1) + char *base = SDL_GetBasePath(); + os << "SDL_GetBasePath():\n" << base << "\n"; + SDL_free(base); +#endif + return os.str(); +} + void exit_error(const std::string &message) { - fprintf(stderr, "FATAL: %s\n", message.c_str()); - errorLog(message); + std::string out = message + "\n\n++ Path info for debugging aid: ++\n" + getPathInfoStr(); + fprintf(stderr, "FATAL: %s\n", out.c_str()); + errorLog(out); exit(1); } diff --git a/BBGE/Base.h b/BBGE/Base.h index 01f06f8..2211ccd 100644 --- a/BBGE/Base.h +++ b/BBGE/Base.h @@ -154,7 +154,7 @@ bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius=1 void drawCircle(float radius, int steps=1); - +std::string getPathInfoStr(); void exit_error(const std::string &message); unsigned hash(const std::string &string); diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index ab43062..f3e39d4 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -412,7 +412,7 @@ void Core::initPlatform(const std::string &filesystem) if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { // error! - debugLog("CFURLGetFileSystemRepresentation"); + errorLog("Core::initPlatform: CFURLGetFileSystemRepresentation error"); } CFRelease(resourcesURL); debugLog(path); @@ -423,13 +423,13 @@ void Core::initPlatform(const std::string &filesystem) if (chdir(filesystem.c_str()) == 0) return; else - debugLog("Failed to chdir to filesystem path " + filesystem); + errorLog("Core::initPlatform: Failed to chdir to filesystem path " + filesystem); } #ifdef BBGE_DATA_PREFIX if (chdir(BBGE_DATA_PREFIX) == 0 && chdir(appName.c_str()) == 0) return; else - debugLog("Failed to chdir to filesystem path " BBGE_DATA_PREFIX + appName); + errorLog("Core::initPlatform: Failed to chdir to filesystem path " BBGE_DATA_PREFIX + appName); #endif char path[PATH_MAX]; // always a symlink to this process's binary, on modern Linux systems. @@ -437,7 +437,7 @@ void Core::initPlatform(const std::string &filesystem) if ( (rc == -1) || (rc >= (ssize_t) sizeof (path)) ) { // error! - debugLog("readlink"); + errorLog("Core::initPlatform: readlink error"); } else { @@ -448,7 +448,7 @@ void Core::initPlatform(const std::string &filesystem) *ptr = '\0'; debugLog(path); if (chdir(path) != 0) - debugLog("Failed to chdir to executable path" + std::string(path)); + errorLog("Core::initPlatform: Failed to chdir to executable path" + std::string(path)); } } #endif @@ -457,7 +457,7 @@ void Core::initPlatform(const std::string &filesystem) { if(_chdir(filesystem.c_str()) != 0) { - debugLog("chdir failed: " + filesystem); + errorLog("chdir failed: " + filesystem); } } // FIXME: filesystem not handled @@ -479,6 +479,11 @@ std::string Core::getUserDataFolder() return userDataFolder; } +std::string Core::getDebugLogPath() +{ + return debugLogPath; +} + Core::~Core() { clearActionButtons(); diff --git a/BBGE/Core.h b/BBGE/Core.h index c332c59..dbd85e3 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -216,6 +216,7 @@ public: std::string getPreferencesFolder(); std::string getUserDataFolder(); + std::string getDebugLogPath(); void resetCamera(); diff --git a/BBGE/OSFunctions.cpp b/BBGE/OSFunctions.cpp index c5721ad..6db9022 100644 --- a/BBGE/OSFunctions.cpp +++ b/BBGE/OSFunctions.cpp @@ -469,3 +469,14 @@ std::string getSystemLocale() return localeStr; } + +std::string getWorkingDir() +{ + char buf[1024*2] = {0}; +#ifdef _WIN32 + GetCurrentDirectoryA(sizeof(buf), buf); +#else + getcwd(buf, sizeof(buf)) +#endif + return buf; +} diff --git a/BBGE/OSFunctions.h b/BBGE/OSFunctions.h index a0ab45b..b65dfba 100644 --- a/BBGE/OSFunctions.h +++ b/BBGE/OSFunctions.h @@ -13,5 +13,6 @@ bool createDir(const std::string& d); void triggerBreakpoint(); void openURL(const std::string &url); std::string getSystemLocale(); +std::string getWorkingDir(); #endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b79dc4..a68cbd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,9 @@ OPTION(AQUARIA_USE_VFS "Use Virtual File System? Required for some additional fe OPTION(AQUARIA_USE_SDL2 "Use SDL2" TRUE) OPTION(AQUARIA_USE_GLM "Use GLM for matrix math" TRUE) +OPTION(AQUARIA_DEBUG_SHOW_PATHS "Show important paths upon game start to aid in finding path problems" FALSE) +mark_as_advanced(AQUARIA_DEBUG_SHOW_PATHS) + ################ Look for external libraries ### Pick one: SDL 1.2 or SDL2 @@ -95,6 +98,10 @@ if(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) ADD_DEFINITIONS("-DAQUARIA_EXTRA_DATA_DIR=\"${AQUARIA_EXTRA_DATA_DIR}\"") endif(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) +if(AQUARIA_DEBUG_SHOW_PATHS) + ADD_DEFINITIONS(-DAQUARIA_DEBUG_SHOW_PATHS) +endif(AQUARIA_DEBUG_SHOW_PATHS) + # Without #define VFS_ENABLE_C_API this is just stubbed out include_directories(ttvfs_cfileapi) if(AQUARIA_USE_VFS) @@ -155,8 +162,8 @@ IF(CMAKE_COMPILER_IS_GNUCC) # It doesn't seem to work well, and it adds bulk to the binary. CHECK_C_COMPILER_FLAG("-fno-stack-protector" AQUARIA_GCC_HAS_STACKPROT) IF(AQUARIA_GCC_HAS_STACKPROT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-stack-protector") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-stack-protector") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector") ENDIF(AQUARIA_GCC_HAS_STACKPROT) # !!! FIXME: probably not safe long-term.