From 958b9c246db10525728bb6028df2144946318592 Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Sun, 2 Aug 2026 12:17:34 +0400 Subject: [PATCH] i hate my live --- binding-mri/binding-mri.cpp | 14 +++-- changelogs/0.1.2.txt | 1 + src/al-util.h | 4 +- src/alstream.cpp | 3 +- src/bitmap.cpp | 7 ++- src/etc.cpp | 6 +-- src/exception.h | 4 +- src/font.cpp | 8 ++- src/gl-fun.cpp | 4 +- src/main.cpp | 32 +++++------- src/meow.cpp | 100 ++++++++++++++++++++++++------------ src/meow.h | 2 +- src/modloader.cpp | 6 +-- src/screen.cpp | 2 +- src/security.h | 2 +- src/soundemitter.cpp | 2 +- src/table.cpp | 6 +-- src/texpool.cpp | 5 +- src/vorbissource.cpp | 4 +- 19 files changed, 116 insertions(+), 96 deletions(-) diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 6975ecc..fd1b4fe 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -380,7 +380,7 @@ static void runCustomScript(const std::string &filename){ std::string scriptData; if (!readFileSDL(filename.c_str(), scriptData)){ - crash(Exception::MEOW, "Unable to open %s", filename); + crash(Exception::NoFileError, false, "Unable to open %s", filename); return; } @@ -401,7 +401,7 @@ static void runRMXPScripts(BacktraceData &btData){ const std::string &scriptPack = conf.game.scripts; if (!shState->fileSystem().exists(scriptPack.c_str())){ - crash(Exception::MEOW, "Unable to open '%s'", scriptPack.c_str()); + crash(Exception::IOError, false, "Unable to open '%s'", scriptPack.c_str()); return; } @@ -412,12 +412,12 @@ static void runRMXPScripts(BacktraceData &btData){ try{ scriptArray = kernelLoadDataInt(scriptPack.c_str(), false); }catch (const Exception &e){ - crash(Exception::MEOW, "Failed to read script data: %s", e.msg); + crash(Exception::IOError, false ,"Failed to read script data: %s", e.msg); return; } if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){ - crash(Exception::MEOW, "Failed to read script data"); + crash(Exception::IOError, false, "Failed to read script data"); return; } @@ -455,7 +455,7 @@ static void runRMXPScripts(BacktraceData &btData){ } if (result != Z_OK){ - crash(Exception::MEOW, "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName)); + crash(Exception::IOError, false, "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName)); break; } rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str())); @@ -556,8 +556,7 @@ static void showExc(VALUE exc, const BacktraceData &btData){ file.resize(SDL_strlen(file.c_str())); file = btData.scriptNames.value(file, file); - crash(Exception::MEOW, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg)); - exit(0); + crash(Exception::RUBYError, true, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg)); } static void mriBindingExecute(){ @@ -566,7 +565,6 @@ static void mriBindingExecute(){ * stdio streams on some platforms (eg. Windows) */ int argc = 0; char **argv = 0; - //options_argv3[] = "--jit" char options_argv1[] = "oneshot", options_argv2[] = "-ev"; char* options_argv[] = {options_argv1, options_argv2, NULL}; ruby_sysinit(&argc, &argv); diff --git a/changelogs/0.1.2.txt b/changelogs/0.1.2.txt index f3d31fa..7370a95 100644 --- a/changelogs/0.1.2.txt +++ b/changelogs/0.1.2.txt @@ -25,3 +25,4 @@ fixed segfault while to fast window size changing updated cg_blue picture Deleted useless hooks fix crash on game exit +Error hadnling updated diff --git a/src/al-util.h b/src/al-util.h index 8d8ffb2..aa2a2fb 100644 --- a/src/al-util.h +++ b/src/al-util.h @@ -182,7 +182,7 @@ inline uint8_t formatSampleSize(int sdlFormat){ case SDL_AUDIO_S16BE : return 2; default : - crash(Exception::MEOW, "Unhandled sample format"); + crash(Exception::SDLError, true, "Unhandled sample format"); } return 0; @@ -201,7 +201,7 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount){ case 2 : return AL_FORMAT_STEREO16; } default : - crash(Exception::MEOW, "Unhandled sample size / channel count"); + crash(Exception::SDLError, true, "Unhandled sample size / channel count"); } return 0; diff --git a/src/alstream.cpp b/src/alstream.cpp index 5cc77de..7cd9b53 100644 --- a/src/alstream.cpp +++ b/src/alstream.cpp @@ -223,9 +223,8 @@ void ALStream::openSource(const std::string &filename){ shState->fileSystem().openRead(handler, filename.c_str()); source = handler.source; needsRewind.clear(); - if (!source) - crash(Exception::MEOW, "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str()); + crash(Exception::SDLError, true, "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str()); } void ALStream::stopStream(){ diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 4c335bf..fa5aad7 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -48,7 +48,7 @@ #define GUARD_MEGA \ { \ if (p->megaSurface) \ - crash(Exception::MKXPError, "Operation not supported for mega surfaces"); \ + crash(Exception::MKXPError, true, "Operation not supported for mega surfaces"); \ } #define OUTLINE_SIZE 1 @@ -221,12 +221,11 @@ struct BitmapOpenHandler : FileSystem::OpenHandler{ Bitmap::Bitmap(const char *filename){ BitmapOpenHandler handler; - char msg[1024]; shState->fileSystem().openRead(handler, filename); SDL_Surface *imgSurf = handler.surf; if (!imgSurf) - crash(Exception::SDLError, "Error loading image '%s': %s", filename, SDL_GetError()); + crash(Exception::SDLError, true, "Error loading image '%s': %s", filename, SDL_GetError()); p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888); @@ -262,7 +261,7 @@ Bitmap::Bitmap(const char *filename){ Bitmap::Bitmap(int width, int height){ if (width <= 0 || height <= 0) - crash(Exception::RGSSError, "failed to create bitmap"); + crash(Exception::RGSSError, true, "failed to create bitmap"); TEXFBO tex = shState->texPool().request(width, height); diff --git a/src/etc.cpp b/src/etc.cpp index 127457b..bf1341a 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -100,7 +100,7 @@ void Color::serialize(char *buffer) const{ Color *Color::deserialize(const char *data, int len){ if (len != 32) - crash(Exception::ArgumentError, "Color: Serialized data invalid"); + crash(Exception::ArgumentError, true, "Color: Serialized data invalid"); Color *c = new Color(); @@ -219,7 +219,7 @@ void Tone::serialize(char *buffer) const{ Tone *Tone::deserialize(const char *data, int len){ if (len != 32) - crash(Exception::ArgumentError, "Tone: Serialized data invalid"); + crash(Exception::ArgumentError, true, "Tone: Serialized data invalid"); Tone *t = new Tone(); @@ -350,7 +350,7 @@ void Rect::serialize(char *buffer) const{ Rect *Rect::deserialize(const char *data, int len){ if (len != 16) - crash(Exception::ArgumentError, "Rect: Serialized data invalid"); + crash(Exception::ArgumentError, true, "Rect: Serialized data invalid"); Rect *r = new Rect(); diff --git a/src/exception.h b/src/exception.h index 982d864..d932cbe 100644 --- a/src/exception.h +++ b/src/exception.h @@ -28,6 +28,7 @@ struct Exception{ enum Type{ RGSSError, + RUBYError, NoFileError, IOError, @@ -42,9 +43,6 @@ struct Exception{ //modloader ModLoaderError, - - // For crash() - MEOW }; Type type; diff --git a/src/font.cpp b/src/font.cpp index 8cc1f4b..d0e9346 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -127,22 +127,20 @@ TTF_Font *SharedFontState::getFont(std::string family, unsigned int size){ SDL_IOStream *ops; if (family.empty()){ - crash(Exception::RGSSError, "font does not exist"); + crash(Exception::RGSSError, true, "font does not exist"); }else{ /* Use 'other' path as alternative in case * we have no 'regular' styled font asset */ const char *path = !req.regular.empty() ? req.regular.c_str() : req.other.c_str(); - //ops = SDL_OpenIO(); - // SDL_IOStream* ops; shState->fileSystem().openReadRaw(ops, path); } font = TTF_OpenFontIO(ops, 1, size); if (!font){ - crash(Exception::SDLError, "%s", SDL_GetError()); + crash(Exception::SDLError, true, "%s", SDL_GetError()); } p->pool.insert(key, font); @@ -303,7 +301,7 @@ void Font::setSize(int value){ /* Catch illegal values (according to RMXP) */ if (value < 6 || value > 96) - crash(Exception::ArgumentError, "%s", "bad value for size"); + crash(Exception::ArgumentError, true, "%s", "bad value for size"); p->size = value; p->sdlFont = 0; diff --git a/src/gl-fun.cpp b/src/gl-fun.cpp index 20b5835..9c0f602 100644 --- a/src/gl-fun.cpp +++ b/src/gl-fun.cpp @@ -91,7 +91,7 @@ void initGLFunctions(){ int glMajor = *ver - '0'; if (glMajor < 2) - crash(Exception::MKXPError, "At least OpenGL (ES) 2.0 is required"); + crash(Exception::MKXPError, false, "At least OpenGL (ES) 2.0 is required"); if (gles){ GL_ES_FUN; @@ -126,7 +126,7 @@ void initGLFunctions(){ } } else{ - crash(Exception::MKXPError, "No FBO support available"); + crash(Exception::MKXPError, false, "No FBO support available"); } /* VAO entrypoints */ diff --git a/src/main.cpp b/src/main.cpp index 7444034..136ea5a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,7 +99,7 @@ int rgssThreadFun(void *userdata){ glCtx = SDL_GL_CreateContext(win); if (!glCtx){ - crash(Exception::MEOW, "Error creating context: %s", SDL_GetError()); + crash(Exception::SDLError, false, "Error creating context: %s", SDL_GetError()); rgssThreadError(threadData, std::string(msg)); return 0; } @@ -108,7 +108,7 @@ int rgssThreadFun(void *userdata){ initGLFunctions(); } catch (const Exception &exc){ - crash(Exception::MEOW, exc.msg.c_str()); + crash(Exception::RGSSError, false, exc.msg.c_str()); rgssThreadError(threadData, exc.msg); SDL_GL_DestroyContext(glCtx); return 0; @@ -136,7 +136,6 @@ int rgssThreadFun(void *userdata){ ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0); if (!alcCtx){ - crash(Exception::MEOW, "Error creating OpenAL context"); rgssThreadError(threadData, "Error creating OpenAL context"); SDL_GL_DestroyContext(glCtx); return 0; @@ -147,11 +146,9 @@ int rgssThreadFun(void *userdata){ try{ SharedState::initInstance(threadData); }catch (const Exception &exc){ - crash(Exception::MEOW, exc.msg.c_str()); rgssThreadError(threadData, exc.msg); alcDestroyContext(alcCtx); SDL_GL_DestroyContext(glCtx); - return 0; } @@ -165,7 +162,6 @@ int rgssThreadFun(void *userdata){ alcDestroyContext(alcCtx); SDL_GL_DestroyContext(glCtx); - return 0; } @@ -224,13 +220,11 @@ int main(int argc, char *argv[]){ #if dos __djgpp_nearptr_enable(); #endif - SecurityManagerInit(); startTime = boost::chrono::high_resolution_clock::now(); loadLanguageMetadata(); //there will be a segfault on fclose if I don't move it here - SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); - SDL_SetAppMetadata("Oneshot: Sunshine", "0.1.1", "com.catwindowteam.sunshine"); + SDL_SetAppMetadata("Oneshot: Sunshine", "0.1.2", "com.catwindowteam.sunshine"); //X11 work on *BSD,Solaris too! #if unix_like SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); @@ -250,19 +244,19 @@ int main(int argc, char *argv[]){ #endif /* initialize SDL first */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){ - crash(Exception::MEOW, "Error initializing SDL: %s", SDL_GetError()); + crash(Exception::SDLError, false, "Error initializing SDL: %s", SDL_GetError()); return 0; } #ifdef STEAM if (!STEAMSHIM_init()){ - crash(Exception::MEOW, "Could not initialize Steamworks API"); + crash(Exception::SDLError, false, "Could not initialize Steamworks API"); return 0; } #endif if (!EventThread::allocUserEvents()){ - crash(Exception::MEOW, "Error allocating SDL user events"); + crash(Exception::SDLError, false, "Error allocating SDL user events"); return 0; } @@ -293,7 +287,7 @@ int main(int argc, char *argv[]){ if (!conf.gameFolder.empty()){ if (chdir(conf.gameFolder.c_str()) != 0){ - crash(Exception::MEOW, "Unable to switch into gameFolder %s", conf.gameFolder); + crash(Exception::SDLError, false, "Unable to switch into gameFolder %s", conf.gameFolder); return 0; } } @@ -306,12 +300,12 @@ int main(int argc, char *argv[]){ conf.windowTitle = conf.game.title; if (TTF_Init() == false){ - crash(Exception::MEOW, "Error initializing SDL_ttf: %s", SDL_GetError()); + crash(Exception::SDLError, false,"Error initializing SDL_ttf: %s", SDL_GetError()); SDL_Quit(); } if (Sound_Init() == false){ - crash(Exception::MEOW, "Error initializing SDL_sound: %s", Sound_GetError()); + crash(Exception::SDLError, false,"Error initializing SDL_sound: %s", Sound_GetError()); TTF_Quit(); SDL_Quit(); @@ -326,7 +320,7 @@ int main(int argc, char *argv[]){ SDL_SetWindowFullscreen(win, true); if (!win){ - crash(Exception::MEOW, "Error creating window: %s", SDL_GetError()); + crash(Exception::SDLError, false,"Error creating window: %s", SDL_GetError()); return 0; } @@ -342,7 +336,7 @@ int main(int argc, char *argv[]){ if (!alcDev){ SDL_DestroyWindow(win); - crash(Exception::MEOW, "Error opening OpenAL device"); + crash(Exception::SDLError, false, "Error opening OpenAL device"); TTF_Quit(); SDL_Quit(); return 0; @@ -394,7 +388,7 @@ int main(int argc, char *argv[]){ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and Sunshine will now force quit", win); if (!rtData.rgssErrorMsg.empty()) - crash(Exception::MEOW, rtData.rgssErrorMsg.c_str()); + crash(Exception::RGSSError, false, rtData.rgssErrorMsg.c_str()); /* Clean up any remainin events */ eventThread.cleanup(); @@ -409,7 +403,7 @@ int main(int argc, char *argv[]){ Sound_Quit(); TTF_Quit(); - SDL_Quit(); // i got "Thread 1 received signal ?, Unknown signal" here on windows after closing game + SDL_Quit(); #ifdef STEAM STEAMSHIM_deinit(); diff --git a/src/meow.cpp b/src/meow.cpp index 58a3b62..35caba2 100644 --- a/src/meow.cpp +++ b/src/meow.cpp @@ -13,27 +13,36 @@ #include "gl-debug.h" #include "gl-fun.h" #include "debugwriter.h" +#include "define.h" #include #include #include #include +#include +#include +#include +#include +#undef vsnprintf +#undef snprintf +#include +#include #include #include -#include #include #include #include -#include #include #include "sunshine.h" -#ifdef __LINUX__ +#ifdef unix_like #include #include "xdg-user-dir-lookup.h" -#elif __ANDROID__ +#elif android #include #include -#elif __EMSCRIPTEN__ +#elif web #include +#elif dos + #include #endif SDL_MessageBoxButtonData buttons[] = { @@ -45,8 +54,10 @@ static inline const char* glGetStringInt(GLenum name){ return (const char*) gl.GetString(name); } -void crash(Exception::Type t, const char *fmt, ...){ - char msg[1024]; +void crash(Exception::Type t, bool do_crash, const char *fmt, ...){ + static char msg[1024]; + static const char* reason = nullptr; + static const char* solution = nullptr; va_list args; va_start(args, fmt); va_list args_copy; @@ -56,7 +67,18 @@ void crash(Exception::Type t, const char *fmt, ...){ char *buf = (char*)SDL_malloc((size_t)len + 1); SDL_vsnprintf(buf, (size_t)len + 1, fmt, args); va_end(args); - SDL_snprintf(msg, sizeof msg, "Error occured! Error message: %s\n\n Want to create a crash SDL_log? You can share the crash SDL_log with the developers and help resolve the issue.", buf); + if(t == Exception::ModLoaderError){ + reason = "Broken mod"; + solution = "Fix mode manualy or ask developer to fix it or delete mod"; + }else if(t == Exception::NoFileError){ + reason = "Broken installation"; + solution = "Try reinstall game"; + }else{ + reason = "Unknown"; + solution = "Unknown"; + } + + SDL_snprintf(msg, sizeof msg, "Error occured! Error message: %s\n\nWant to create a crash log? You can share the crash log with the developers and help resolve the issue.\n\nPossible reason:%s\n\nPossible solution: %s", buf, reason, solution); SDL_MessageBoxData messageboxdata = { .flags = SDL_MESSAGEBOX_ERROR, .window = NULL, @@ -82,17 +104,6 @@ void crash(Exception::Type t, const char *fmt, ...){ o << "REASON: " << buf << std::endl; o << "[BOOST stacktrace()]" << std::endl; o << boost::stacktrace::stacktrace() << std::endl; - o << "[OpenGL]" << std::endl; - try{ - o << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl; - o << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl; - o << "GL Version: " << glGetStringInt(GL_VERSION) << std::endl; - o << "GLSL Version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl; - o << "Shading language version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl; - o << "GL Extensions: " << glGetStringInt(GL_EXTENSIONS) << std::endl; - }catch(const std::exception& e){ - o << "Crashed before OpenGL initialization: " << e.what() << std::endl; - } o << "[Versions of libs]" << std::endl; const int sdlcompiled = SDL_VERSION; const int sdllinked = SDL_GetVersion(); @@ -112,10 +123,11 @@ void crash(Exception::Type t, const char *fmt, ...){ }catch(const std::exception& e){ o << "Detected OS: " << e.what() << std::endl; } - if(!SDL_getenv("XDG_CURRENT_DESKTOP") == NULL){ - o << "Desktop enviroment(XDG_CURRENT_DESKTOP): " << SDL_getenv("XDG_CURRENT_DESKTOP") << std::endl; - } - #ifdef __ANDROID__ + #ifdef unix_like + if(SDL_getenv("XDG_CURRENT_DESKTOP") != nullptr){ + o << "Desktop enviroment(XDG_CURRENT_DESKTOP): " << SDL_getenv("XDG_CURRENT_DESKTOP") << std::endl; + } + #elif android o << "Android API version: " << android_get_device_api_level() << std::endl; o << "External storage State: " << SDL_GetAndroidExternalStorageState() << std::endl; o << "Internal storage path: " << SDL_GetAndroidInternalStoragePath() << std::endl; @@ -129,32 +141,54 @@ void crash(Exception::Type t, const char *fmt, ...){ o << "Is TV? " << SDL_IsTV() << std::endl; o << "Is Ubuntu Touch? " << SDL_IsUbuntuTouch() << std::endl; } - #elif __EMSCRIPTEN__ + #elif web o << "Emscripten start address of the stack: " << emscripten_stack_get_base() << std::endl; o << "Emscripten end address of the stack: " << emscripten_stack_get_end() << std::endl; o << "Emscripten current stack pointer: " << emscripten_stack_get_current() << std::endl; o << "Emscripten number of free bytes left on stack: " << emscripten_stack_get_free() << std::endl; - #elif __PSP__ - o << "PSPdev MIPS Stack Trace: " << int pspDebugGetStackTrace() << std::endl; + #elif psp + o << "PSPdev MIPS Stack Trace: " << pspDebugGetStackTrace() << std::endl; + #elif dos + o << "DPMI virtual interrupt state: " << __dpmi_get_virtual_interrupt_state() << std::endl; + o << "DPMI selector increment value: " << __dpmi_get_selector_increment_value() << std::endl; + o << "DPMI coprocessor status: " << __dpmi_get_coprocessor_status() << std::endl; + o << "DPMI is 80387 processor?: " << _detect_80387() << std::endl; #endif o << "[Hardware]" << std::endl; o << "number of logical CPU cores: " << SDL_GetNumLogicalCPUCores() << std::endl; o << "System RAM size: " << SDL_GetSystemRAM() << " MiB" << std::endl; + o << "[Ruby]" << std::endl; + o << "Is GC was busy? " << rb_during_gc() << std::endl; + o << "[OpenGL]" << std::endl; + try{ + o << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl; + o << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl; + o << "GL Version: " << glGetStringInt(GL_VERSION) << std::endl; + o << "GLSL Version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl; + o << "Shading language version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl; + o << "GL Extensions: " << glGetStringInt(GL_EXTENSIONS) << std::endl; + }catch(const std::exception& e){ + o << "Crashed before OpenGL initialization: " << e.what() << std::endl; + } o.close(); }else{ - Debug() << "[CRASHLOG] Failed to write crashdump file"; - } + ErrorMsg("[CRASHLOG] Failed to write crashdump file"); + } + } + if(do_crash){ + rb_exit(-1); } - - if(!t == Exception::MEOW) - throw Exception(t, msg); } void ErrorMsg(const char* message){ - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", message, NULL); + if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", message, NULL)){ + //TODO: error handling + } } void WarnMsg(const char* message){ - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", message, NULL); + if(SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", message, NULL)){ + //TODO: error handling + } } diff --git a/src/meow.h b/src/meow.h index 55093fe..82b6f01 100644 --- a/src/meow.h +++ b/src/meow.h @@ -1,5 +1,5 @@ #include "exception.h" -void crash(Exception::Type t, const char *fmt, ...); +void crash(Exception::Type t, bool do_crash, const char *fmt, ...); void ErrorMsg(const char* message); void WarnMsg(const char* message); diff --git a/src/modloader.cpp b/src/modloader.cpp index b641ffe..9507b56 100644 --- a/src/modloader.cpp +++ b/src/modloader.cpp @@ -47,7 +47,7 @@ std::string sha512(const std::string str){ std::string sha256_file(const std::string &fn) { FILE *file = fopen(fn.c_str(), "rb"); if (!file) { - crash(Exception::ModLoaderError, "Failed to load mod, filesystem error."); + crash(Exception::IOError, true, "Failed to load mod, filesystem error."); } unsigned char buf[1024]; @@ -98,7 +98,7 @@ void ModLoader(){ std::string full = p.string(); int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0); if (!ok) { - crash(Exception::ModLoaderError, "PhysFS_mount failed: %s", PHYSFS_getLastError()); + crash(Exception::ModLoaderError, false, "PhysFS_mount failed: %s", PHYSFS_getLastError()); } Debug() << "[MODLOADER] " << full; mod_list.push_back(full); @@ -112,6 +112,6 @@ void ModLoader(){ Debug() << "[MODLOADER] BuildID: " << buildID; modloader_is_enabled = true; }catch(const std::exception& e){ - crash(Exception::ModLoaderError, "Something is wrong, Exception: %s ", e.what()); + crash(Exception::ModLoaderError, true, "Something is wrong, Exception: %s ", e.what()); } } diff --git a/src/screen.cpp b/src/screen.cpp index 974761c..17252b1 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -33,7 +33,7 @@ int screenMain(Config &conf){ win = SDL_CreateWindow("The Journal", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOW_RESIZABLE | SDL_WINDOW_TRANSPARENT); if (!win){ - crash(Exception::MEOW, "Error creating window: %s", SDL_GetError()); + crash(Exception::SDLError, true, "Error creating window: %s", SDL_GetError()); return 0; } diff --git a/src/security.h b/src/security.h index b058803..fadf256 100644 --- a/src/security.h +++ b/src/security.h @@ -1,3 +1,3 @@ -inline char* securitystate = "unsandboxed"; +inline const char* securitystate = "unsandboxed"; void SecurityManagerInit(); void SecurityManagerDeInit(); diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp index 811a2e0..ee712c6 100644 --- a/src/soundemitter.cpp +++ b/src/soundemitter.cpp @@ -222,7 +222,7 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){ buffer = handler.buffer; if (!buffer){ - crash(Exception::MEOW, "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError()); + crash(Exception::SDLError, false, "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError()); return 0; } diff --git a/src/table.cpp b/src/table.cpp index 5d1d9c0..830ccf5 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -114,7 +114,7 @@ void Table::serialize(char *buffer) const{ Table *Table::deserialize(const char *data, int len){ if (len < 20) - crash(Exception::RGSSError, "Marshal: Table: bad file format"); + crash(Exception::RGSSError, true, "Marshal: Table: bad file format"); readInt32(&data); int x = readInt32(&data); @@ -123,10 +123,10 @@ Table *Table::deserialize(const char *data, int len){ int size = readInt32(&data); if (size != x*y*z) - crash(Exception::RGSSError, "Marshal: Table: bad file format"); + crash(Exception::RGSSError, true, "Marshal: Table: bad file format"); if (len != 20 + x*y*z*2) - crash(Exception::RGSSError, "Marshal: Table: bad file format"); + crash(Exception::RGSSError, true, "Marshal: Table: bad file format"); Table *t = new Table(x, y, z); SDL_memcpy(dataPtr(t->data), data, sizeof(int16_t)*size); diff --git a/src/texpool.cpp b/src/texpool.cpp index a6e481f..95ed82b 100644 --- a/src/texpool.cpp +++ b/src/texpool.cpp @@ -117,7 +117,7 @@ TEXFBO TexPool::request(int width, int height){ int maxSize = glState.caps.maxTexSize; if (width > maxSize || height > maxSize){ - crash(Exception::MKXPError, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height); + crash(Exception::MKXPError, true, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height); } /* Nope, create it instead */ @@ -162,8 +162,7 @@ void TexPool::release(TEXFBO &obj){ CNodeList &bucket = p->poolHash[removedSize]; - std::list::iterator toRemove = - std::find(bucket.begin(), bucket.end(), last); + std::list::iterator toRemove = std::find(bucket.begin(), bucket.end(), last); assert(toRemove != bucket.end()); bucket.erase(toRemove); diff --git a/src/vorbissource.cpp b/src/vorbissource.cpp index d3c454c..bef5e5f 100644 --- a/src/vorbissource.cpp +++ b/src/vorbissource.cpp @@ -79,7 +79,7 @@ struct VorbisSource : ALDataSource{ if (error){ SDL_CloseIO(&src); - crash(Exception::MKXPError, "Vorbisfile: Cannot read ogg file"); + crash(Exception::MKXPError, true, "Vorbisfile: Cannot read ogg file"); } /* Extract bitstream info */ @@ -89,7 +89,7 @@ struct VorbisSource : ALDataSource{ if (info.channels > 2){ ov_clear(&vf); SDL_CloseIO(&src); - crash(Exception::MKXPError, "Cannot handle audio with more than 2 channels"); + crash(Exception::MKXPError, true, "Cannot handle audio with more than 2 channels"); } info.alFormat = chooseALFormat(sizeof(int16_t), info.channels);