From f96527d3e10d40e06a7751a912c219b60f57ac0d Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Wed, 19 Aug 2026 09:24:15 +0400 Subject: [PATCH] a --- CMakeLists.txt | 32 +++++++++++++++++++++++------- binding-mri/audio-binding.cpp | 1 - binding-mri/binding-mri.cpp | 10 +++++++--- binding-mri/filesystem-binding.cpp | 3 --- binding-mri/input-binding.cpp | 1 - binding-mri/modloader-binding.cpp | 1 - binding-mri/steam-binding.cpp | 1 - binding-mri/wallpaper-binding.cpp | 1 - changelogs/0.1.2.txt | 1 + src/debugwriter.h | 12 +++++------ src/main.cpp | 27 ++++--------------------- src/meow.cpp | 3 +-- src/modloader.cpp | 9 ++++++--- 13 files changed, 50 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffd87ff..bc55a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,14 @@ project(oneshot) include(FindPackageHandleStandardArgs) include(CheckCXXCompilerFlag) include(CheckCCompilerFlag) +include(CheckIPOSupported) + +check_ipo_supported( + RESULT ipo_supported + OUTPUT ipo_error + LANGUAGES CXX C +) + # Helper for checking if options supported function(check_option var a) set(all ${a}) @@ -346,7 +354,8 @@ if(DEBUG) -g3 -fno-omit-frame-pointer -Og - -fcheck-new) + -fcheck-new + -fstrict-flex-arrays=3) add_compile_options(${OPTIONS_DEBUG}) if("${ARCH_DEBUG}" STREQUAL "") @@ -369,7 +378,9 @@ else() -frename-registers -fuse-linker-plugin -fipa-pta - -fext-dce) + -fext-dce + -fstrict-enums + -fimplicit-constexpr) add_compile_options(${OPTIONS_RELEASE}) add_link_options(-Wl,-O2 @@ -378,11 +389,7 @@ else() -Wl,--no-undefined -Wl,--strip-all -Wl,--no-copy-dt-needed-entries) - if(NOT WIN32) - check_option(OPTIONS_RELEASE_WIN32_FLTO -flto=thin) - add_compile_options(${OPTIONS_RELEASE_WIN32_FLTO}) - add_link_options(${OPTIONS_RELEASE_WIN32_FLTO}) - endif() + if("${ARCH_RELEASE}" STREQUAL "") message(STATUS "ARCH_RELEASE empty") else() @@ -409,6 +416,17 @@ else() ) endif() +if(NOT DEBUG) + if(ipo_supported) + set_property( + TARGET ${PROJECT_NAME} + PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE + ) + else() + message(WARNING "IPO/LTO is not supported: ${ipo_error}") + endif() +endif() + if(DEVBUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE DEVBUILD) endif() diff --git a/binding-mri/audio-binding.cpp b/binding-mri/audio-binding.cpp index ce301fa..30644b4 100644 --- a/binding-mri/audio-binding.cpp +++ b/binding-mri/audio-binding.cpp @@ -108,7 +108,6 @@ RB_METHOD(audioReset) { } void audioBindingInit(){ - printf("[audioBindingInit] Initialing Audio binding\n"); VALUE module = rb_define_module("Audio"); rb_define_singleton_method(module, "create_sound", RUBY_METHOD_FUNC(rb_audio_createAudioPlayback), -1); diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 2494989..4aa1e9a 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -423,9 +423,13 @@ static void runRMXPScripts(BacktraceData &btData){ } //Execute preloaded scripts - for (std::set::iterator i = preloadScripts.begin(); - i != preloadScripts.end(); ++i) - runCustomScript(*i); + if(modloader_is_enabled){ + for (std::set::iterator i = preloadScripts.begin(); + i != preloadScripts.end(); ++i){ + runCustomScript(*i); + } + } + VALUE exc = rb_gv_get("$!"); if (exc != Qnil) diff --git a/binding-mri/filesystem-binding.cpp b/binding-mri/filesystem-binding.cpp index 413e600..7028d55 100644 --- a/binding-mri/filesystem-binding.cpp +++ b/binding-mri/filesystem-binding.cpp @@ -139,9 +139,6 @@ RB_METHOD(kernelSaveData){ VALUE filename; rb_get_args(argc, argv, "oS", &obj, &filename); - #ifdef DEBUG - printf("[kernelSaveData] Filename: %s\n", rb_str_to_str(filename)); - #endif VALUE file = rb_file_open_str(filename, "wb"); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); diff --git a/binding-mri/input-binding.cpp b/binding-mri/input-binding.cpp index 87bf2ef..93507f8 100644 --- a/binding-mri/input-binding.cpp +++ b/binding-mri/input-binding.cpp @@ -343,7 +343,6 @@ static buttonCodes[] = { static elementsN(buttonCodes); void inputBindingInit(){ - printf("[inputBindingInit] Initializing Input binding\n"); VALUE module = rb_define_module("Input"); initGamepadBinding(module); diff --git a/binding-mri/modloader-binding.cpp b/binding-mri/modloader-binding.cpp index ba72bfe..c79c137 100644 --- a/binding-mri/modloader-binding.cpp +++ b/binding-mri/modloader-binding.cpp @@ -29,7 +29,6 @@ VALUE meow(const std::vector vec){ return ary; } - static VALUE hooks(int argc, VALUE *argv, VALUE self) { VALUE v_path = Qnil; rb_scan_args(argc, argv, "01", &v_path); diff --git a/binding-mri/steam-binding.cpp b/binding-mri/steam-binding.cpp index cbf869a..dfd055a 100644 --- a/binding-mri/steam-binding.cpp +++ b/binding-mri/steam-binding.cpp @@ -55,7 +55,6 @@ RB_METHOD(steamUnlocked){ } void steamBindingInit(){ - printf("[steamBindingInit] Initializing Steam binding\n"); VALUE module = rb_define_module("Steam"); /* Constants */ diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 8bbddea..0504db4 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -83,7 +83,6 @@ } void desktopEnvironmentInit(){ - printf("[desktopEnvironmentInit] desktopEnvironmentInit()\n"); if (desktop != "uninitialized") return; diff --git a/changelogs/0.1.2.txt b/changelogs/0.1.2.txt index 9aa84bd..e8add12 100644 --- a/changelogs/0.1.2.txt +++ b/changelogs/0.1.2.txt @@ -67,3 +67,4 @@ GNOME support fixed Fixed small defect on cg_wake5 Added ModLoader loading screen Added [Function():string number] debug information in logs +SecurityEngine now enabled only when Modloader is active diff --git a/src/debugwriter.h b/src/debugwriter.h index 6ef61d6..1af794f 100644 --- a/src/debugwriter.h +++ b/src/debugwriter.h @@ -67,19 +67,19 @@ public: ~Debug(){ std::ostringstream result; - result << "[" << location.line() << ":" << location.function_name() << "] " << buf.str(); + result << "[" << location.line() << ":" << location.function_name() << "] " << buf.view(); #ifdef __ANDROID__ - __android_log_write(ANDROID_LOG_DEBUG, "sunshine", result.str().c_str()); + __android_log_write(ANDROID_LOG_DEBUG, "sunshine", result.view().c_str()); #elif __EMSCRIPTEN__ - emscripten_console_log(result.str().c_str()); + emscripten_console_log(result.view().c_str()); #else - logs.push_back(result.str()); - std::cout << result.str() << "\n"; + logs.emplace_back(result.view()); + std::cout << std::move(result).str() << '\n'; #endif } private: - std::stringstream buf; + std::ostringstream buf; std::source_location location; }; diff --git a/src/main.cpp b/src/main.cpp index ab343dd..4a47001 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,6 @@ #else #include #endif -#include #include #include #include @@ -48,7 +47,6 @@ #include "exception.h" #include "gl-fun.h" #include "i18n.h" -#include "security.h" #include "sunshine.h" #include "modloader.h" @@ -59,19 +57,12 @@ #include "binding.h" #include "icon.png.xxd" -#include #ifdef STEAM #include "steamshim/steamshim_child.h" #else #include "gamecontrollerdb.txt.xxd" #endif -#ifdef ps2 - #ifdef DEBUG - SDL_PS2_SKIP_IOP_RESET(); - #endif -#endif - #ifndef VERSION_STRING #define VERSION_STRING ">w<" #endif @@ -82,10 +73,6 @@ static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg){ rtData->rqTermAck.set(); } -static inline const char* glGetStringInt(GLenum name){ - return (const char*) gl.GetString(name); -} - int rgssThreadFun(void *userdata){ RGSSThreadData *threadData = static_cast(userdata); const Config &conf = threadData->config; @@ -123,10 +110,6 @@ int rgssThreadFun(void *userdata){ gl.Clear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapWindow(win); - Debug() << "[main] GL Vendor :" << glGetStringInt(GL_VENDOR); - Debug() << "[main] GL Renderer :" << glGetStringInt(GL_RENDERER); - Debug() << "[main] GL Version :" << glGetStringInt(GL_VERSION); - Debug() << "[main] GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION); #ifndef NDEBUG GLDebugLogger dLogger; #endif @@ -168,10 +151,13 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win){ } int main(int argc, char *argv[]){ + //I WANT FUCKING OPTIMIZE EVERYFING IN THIS BULLSHIT + std::ios::sync_with_stdio(false); + std::cin.tie(nullptr); 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.2", "meow.catwindowteam.sunshine"); + SDL_SetAppMetadata("Oneshot: Sunshine", VERSION_STRING, "meow.catwindowteam.sunshine"); //X11 work on *BSD,Solaris too! #if unix_like SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); @@ -184,8 +170,6 @@ int main(int argc, char *argv[]){ SDL_SetHint(SDL_HINT_ANDROID_ALLOW_PERSISTENT_FOLDER_ACCESS, "1"); #elif vita SDL_SetHint(SDL_HINT_VITA_RESOLUTION, "1080"); - #elif ps2 - SFL_SetHint(SDL_HINT_PS2_GS_MODE, "NTSC"); #endif /* initialize SDL first */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){ @@ -219,9 +203,6 @@ int main(int argc, char *argv[]){ /* now we load the config */ Config conf; conf.read(argc, argv); - if(conf.SecurityEngine){ - SecurityManagerInit(); - } #if windows if(conf.Windows_AllocConsole == true){ AllocConsole(); diff --git a/src/meow.cpp b/src/meow.cpp index ce69ee1..f577b6e 100644 --- a/src/meow.cpp +++ b/src/meow.cpp @@ -163,7 +163,7 @@ void crash_screen(SDL_Window* win){ WarnMsg("Failed to create texture, please check if your device is too strong to run game or report bug.Error Message: ", SDL_GetError()); skip_crash_screen = true; }else{ - SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); + SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); } //creating file and timestamp ofstream o; @@ -368,4 +368,3 @@ void WarnMsg(const char *fmt, ...) { Debug() << "[WARNMSG]" << buf; SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", buf, NULL); } - diff --git a/src/modloader.cpp b/src/modloader.cpp index af763da..9a6d695 100644 --- a/src/modloader.cpp +++ b/src/modloader.cpp @@ -2,6 +2,7 @@ #include "debugwriter.h" #include "meow.h" #include "config.h" +#include "security.h" #include #include @@ -24,7 +25,7 @@ const static std::size_t N = 46; static void modloader_add_to_log(const std::string data){ Debug() << "[MODLOADER] " << data; - modloader_logs.push_back(data); + modloader_logs.emplace_back(data); } static int renderer_thread(void* data){ @@ -74,7 +75,9 @@ void ModLoader(Config conf, SDL_Window* win){ Debug() << "[MODLOADER] Mods directory empty, skip."; return; } - + if(conf.SecurityEngine){ + SecurityManagerInit(); + } SDL_Thread* render_thread_pointer = SDL_CreateThread(renderer_thread, "ModRenderer", win); if (!render_thread_pointer) { //TODO: Error handling @@ -92,7 +95,7 @@ void ModLoader(Config conf, SDL_Window* win){ if (ext == ".zip") { int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0); - mod_list.push_back(full); + mod_list.emplace_back(full); modloader_add_to_log("Added mod " + full); mods_count++; } else if (ext == ".rb") {