From 13f319a26589b5b6420c104dc325f04a1b660eb9 Mon Sep 17 00:00:00 2001 From: ZakatTeamI2P Date: Tue, 26 May 2026 19:15:37 +0400 Subject: [PATCH] i think i broke something --- CMakeLists.txt | 4 +- binding-mri/binding-mri.cpp | 2 +- src/filesystem.cpp | 5 +- src/main.cpp | 5 +- src/meow.cpp | 92 +++++++++++++++++++++++++++++++++++++ src/meow.h | 1 + 6 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 src/meow.cpp create mode 100644 src/meow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 41064bd..a01397f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ set(MAIN_HEADERS chromasdk/RzErrors.h chromasdk/ChromaApi.h src/i18n.h + src/meow.h ) set(MAIN_SOURCE @@ -132,6 +133,7 @@ set(MAIN_SOURCE src/oneshot.cpp src/screen.cpp src/i18n.cpp + src/meow.cpp ) if(WIN32) @@ -294,7 +296,7 @@ set(BINDING_SOURCE binding-mri/module_rpg.cpp binding-mri/filesystem-binding.cpp binding-mri/oneshot-binding.cpp - binding-mri/sunshine-binding.cpp + binding-mri/sunshine-binding.cpp binding-mri/steam-binding.cpp binding-mri/wallpaper-binding.cpp binding-mri/journal-binding.cpp diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index a471ab4..34f99ce 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -115,7 +115,7 @@ static void mriBindingInit(){ wallpaperBindingInit(); nikoBindingInit(); oneshotBindingInit(); - SunshineBindingInit(); + SunshineBindingInit(); steamBindingInit(); chromaBindingInit(); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index dee894c..0371673 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -28,6 +28,7 @@ #include "sharedstate.h" #include "boost-hash.h" #include "debugwriter.h" +#include "meow.h" #include @@ -53,8 +54,8 @@ struct SDLRWIoContext{ filename(filename) { if (!ops) - throw Exception(Exception::SDLError, - "Failed to open file: %s", SDL_GetError()); + crash("Failed to open file", 0); + throw Exception(Exception::SDLError, "Failed to open file: %s", SDL_GetError()); } ~SDLRWIoContext(){ diff --git a/src/main.cpp b/src/main.cpp index dafe07f..18285d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,8 @@ #include "gl-fun.h" #include "i18n.h" +#include "meow.h" + #include "binding.h" #include "icon.png.xxd" @@ -95,7 +97,6 @@ int rgssThreadFun(void *userdata){ catch (const Exception &exc){ rgssThreadError(threadData, exc.msg); SDL_GL_DestroyContext(glCtx); - return 0; } @@ -375,7 +376,7 @@ int main(int argc, char *argv[]){ if (rtData.rqTermAck) SDL_WaitThread(rgssThread, 0); else - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and OneShot will now force quit", win); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and OneShot: Sunshine will now force quit", win); if (!rtData.rgssErrorMsg.empty()){ Debug() << rtData.rgssErrorMsg; diff --git a/src/meow.cpp b/src/meow.cpp new file mode 100644 index 0000000..78e1bc1 --- /dev/null +++ b/src/meow.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include "meow.h" +#include "config.h" +#include +#include +#include +#include + +#ifdef __LINUX__ + #include + #include +#endif + + +SDL_MessageBoxButtonData buttons[] = { + { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "Yes" }, + { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "No" } +}; + +int crash(const char* reason, int exit_code){ + const Config conf; + SDL_MessageBoxData messageboxdata = { + .flags = SDL_MESSAGEBOX_ERROR, + .window = NULL, + .title = "Crashdump", + .message = "Error occured! Want to create a crash log?", + .numbuttons = SDL_arraysize(buttons), + .buttons = buttons, + .colorScheme = NULL + }; + + + int buttonid = 0; + if (SDL_ShowMessageBox(&messageboxdata, &buttonid) == false) { + printf("[CRASHDUMP] %s\n", reason); + } + + if(buttonid == 1){ + std::ofstream out; + time_t mtime = time(NULL); + struct tm *now = localtime(&mtime); + std::string time = std::to_string(now->tm_hour) + "." + std::to_string(now->tm_min) + "." + std::to_string(now->tm_sec); + out.open("crash_" + time + ".txt"); + const int sdlcompiled = SDL_VERSION; + const int sdllinked = SDL_GetVersion(); + if (out.is_open()){ + out << "[SUNSHINE CRASHDUMP]" << std::endl; + out << "CONFIG" << std::endl; + out << "defScreenW: " << conf.defScreenW << std::endl; + out << "defScreenH: " << conf.defScreenH << std::endl; + out << "debugMode: " << conf.debugMode << std::endl; + out << "screenMode: " << conf.screenMode << std::endl; + out << "fullscreen: " << conf.fullscreen << std::endl; + out << "fixedAspectRatio: " << conf.fixedAspectRatio << std::endl; + out << "smoothScaling: " << conf.smoothScaling << std::endl; + out << "vsync: " << conf.vsync << std::endl; + out << "EnableSixteenByNine: " << conf.EnableSixteenByNine << std::endl; + out << "windowTitle: " << conf.windowTitle << std::endl; + out << "defSfixedFrameratecreenW: " << conf.fixedFramerate << std::endl; + out << "frameSkip: " << conf.frameSkip << std::endl; + out << "syncToRefreshrate: " << conf.syncToRefreshrate << std::endl; + out << "solidFonts: " << conf.solidFonts << std::endl; + out << "subImageFix: " << conf.subImageFix << std::endl; + out << "enableBlitting: " << conf.enableBlitting << std::endl; + out << "maxTextureSize: " << conf.maxTextureSize << std::endl; + out << "gameFolder: " << conf.gameFolder << std::endl; + out << "allowSymlinks: " << conf.allowSymlinks << std::endl; + out << "pathCache: " << conf.pathCache << std::endl; + out << "iconPath: " << conf.iconPath << std::endl; + out << "useScriptNames: " << conf.useScriptNames << std::endl; + out << "customScript: " << conf.customScript << std::endl; + out << "customDataPath: " << conf.customDataPath << std::endl; + out << "commonDataPath: " << conf.commonDataPath << std::endl; + out << "" << std::endl; + out << "Ruby version: " << rb_gv_get("ruby_version") << std::endl; + out << "SDL(compiled) version: " << SDL_VERSIONNUM_MAJOR(sdlcompiled) << "." << SDL_VERSIONNUM_MINOR(sdlcompiled) << "." << SDL_VERSIONNUM_MICRO(sdlcompiled) << std::endl; + out << "SDL(linked) version: " << SDL_VERSIONNUM_MAJOR(sdllinked) << "." << SDL_VERSIONNUM_MINOR(sdllinked) << "." << SDL_VERSIONNUM_MICRO(sdllinked) << std::endl; + out << "Detected OS: " << SDL_GetPlatform() << std::endl; + #ifdef __LINUX__ + out << "GTK(compiled) version: " << GTK_MAJOR_VERSION << "." << GTK_MINOR_VERSION << "." << GTK_MICRO_VERSION << std::endl; + #endif + out.close(); + }else{ + printf("[CRASHLOG] Failed to write crashdump file\n"); + } + } + + return exit_code; +} diff --git a/src/meow.h b/src/meow.h new file mode 100644 index 0000000..d919f70 --- /dev/null +++ b/src/meow.h @@ -0,0 +1 @@ +int crash(const char* reason, int exit_code);