1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-25 15:33:57 +00:00

show better errors when we fail to start up

This commit is contained in:
fgenesis 2022-06-20 04:25:18 +02:00
parent af6c6a31aa
commit f01db61292
8 changed files with 73 additions and 12 deletions

View file

@ -805,6 +805,11 @@ void DSQ::init()
// steam gets inited in here // steam gets inited in here
Core::init(); Core::init();
#ifdef AQUARIA_DEBUG_SHOW_PATHS
errorLog("AQUARIA_DEBUG_SHOW_PATHS:\n" + getPathInfoStr());
#endif
loadStringBank(); loadStringBank();
vars = &v; 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); particleManager->setSize(user.video.numParticles);

View file

@ -23,6 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h> #include <assert.h>
#include "OSFunctions.h" #include "OSFunctions.h"
#if SDL_VERSION_ATLEAST(2,0,0)
#include "SDL_filesystem.h"
#endif
#ifdef BBGE_BUILD_VFS #ifdef BBGE_BUILD_VFS
# include "ttvfs.h" # include "ttvfs.h"
# ifndef VFS_IGNORE_CASE # 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) void exit_error(const std::string &message)
{ {
fprintf(stderr, "FATAL: %s\n", message.c_str()); std::string out = message + "\n\n++ Path info for debugging aid: ++\n" + getPathInfoStr();
errorLog(message); fprintf(stderr, "FATAL: %s\n", out.c_str());
errorLog(out);
exit(1); exit(1);
} }

View file

@ -154,7 +154,7 @@ bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius=1
void drawCircle(float radius, int steps=1); void drawCircle(float radius, int steps=1);
std::string getPathInfoStr();
void exit_error(const std::string &message); void exit_error(const std::string &message);
unsigned hash(const std::string &string); unsigned hash(const std::string &string);

View file

@ -412,7 +412,7 @@ void Core::initPlatform(const std::string &filesystem)
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{ {
// error! // error!
debugLog("CFURLGetFileSystemRepresentation"); errorLog("Core::initPlatform: CFURLGetFileSystemRepresentation error");
} }
CFRelease(resourcesURL); CFRelease(resourcesURL);
debugLog(path); debugLog(path);
@ -423,13 +423,13 @@ void Core::initPlatform(const std::string &filesystem)
if (chdir(filesystem.c_str()) == 0) if (chdir(filesystem.c_str()) == 0)
return; return;
else else
debugLog("Failed to chdir to filesystem path " + filesystem); errorLog("Core::initPlatform: Failed to chdir to filesystem path " + filesystem);
} }
#ifdef BBGE_DATA_PREFIX #ifdef BBGE_DATA_PREFIX
if (chdir(BBGE_DATA_PREFIX) == 0 && chdir(appName.c_str()) == 0) if (chdir(BBGE_DATA_PREFIX) == 0 && chdir(appName.c_str()) == 0)
return; return;
else 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 #endif
char path[PATH_MAX]; char path[PATH_MAX];
// always a symlink to this process's binary, on modern Linux systems. // 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)) ) if ( (rc == -1) || (rc >= (ssize_t) sizeof (path)) )
{ {
// error! // error!
debugLog("readlink"); errorLog("Core::initPlatform: readlink error");
} }
else else
{ {
@ -448,7 +448,7 @@ void Core::initPlatform(const std::string &filesystem)
*ptr = '\0'; *ptr = '\0';
debugLog(path); debugLog(path);
if (chdir(path) != 0) 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 #endif
@ -457,7 +457,7 @@ void Core::initPlatform(const std::string &filesystem)
{ {
if(_chdir(filesystem.c_str()) != 0) if(_chdir(filesystem.c_str()) != 0)
{ {
debugLog("chdir failed: " + filesystem); errorLog("chdir failed: " + filesystem);
} }
} }
// FIXME: filesystem not handled // FIXME: filesystem not handled
@ -479,6 +479,11 @@ std::string Core::getUserDataFolder()
return userDataFolder; return userDataFolder;
} }
std::string Core::getDebugLogPath()
{
return debugLogPath;
}
Core::~Core() Core::~Core()
{ {
clearActionButtons(); clearActionButtons();

View file

@ -216,6 +216,7 @@ public:
std::string getPreferencesFolder(); std::string getPreferencesFolder();
std::string getUserDataFolder(); std::string getUserDataFolder();
std::string getDebugLogPath();
void resetCamera(); void resetCamera();

View file

@ -469,3 +469,14 @@ std::string getSystemLocale()
return localeStr; return localeStr;
} }
std::string getWorkingDir()
{
char buf[1024*2] = {0};
#ifdef _WIN32
GetCurrentDirectoryA(sizeof(buf), buf);
#else
getcwd(buf, sizeof(buf))
#endif
return buf;
}

View file

@ -13,5 +13,6 @@ bool createDir(const std::string& d);
void triggerBreakpoint(); void triggerBreakpoint();
void openURL(const std::string &url); void openURL(const std::string &url);
std::string getSystemLocale(); std::string getSystemLocale();
std::string getWorkingDir();
#endif #endif

View file

@ -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_SDL2 "Use SDL2" TRUE)
OPTION(AQUARIA_USE_GLM "Use GLM for matrix math" 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 ################ Look for external libraries
### Pick one: SDL 1.2 or SDL2 ### 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}\"") ADD_DEFINITIONS("-DAQUARIA_EXTRA_DATA_DIR=\"${AQUARIA_EXTRA_DATA_DIR}\"")
endif(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) 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 # Without #define VFS_ENABLE_C_API this is just stubbed out
include_directories(ttvfs_cfileapi) include_directories(ttvfs_cfileapi)
if(AQUARIA_USE_VFS) 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. # 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) CHECK_C_COMPILER_FLAG("-fno-stack-protector" AQUARIA_GCC_HAS_STACKPROT)
IF(AQUARIA_GCC_HAS_STACKPROT) IF(AQUARIA_GCC_HAS_STACKPROT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-stack-protector") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-stack-protector") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
ENDIF(AQUARIA_GCC_HAS_STACKPROT) ENDIF(AQUARIA_GCC_HAS_STACKPROT)
# !!! FIXME: probably not safe long-term. # !!! FIXME: probably not safe long-term.