mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
'
This commit is contained in:
parent
84e5d24398
commit
5352c63336
6 changed files with 120 additions and 83 deletions
|
|
@ -17,7 +17,6 @@ end
|
|||
|
||||
begin
|
||||
RPG::Mod.exec_hooks("hooks/Main/start", binding)
|
||||
print PhysFS.exist?("gaysex")
|
||||
$console = Graphics.fullscreen
|
||||
Graphics.frame_rate = 60
|
||||
Font.default_size = 20
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ void Config::read(int argc, char *argv[]){
|
|||
#define PO_DESC_ALL \
|
||||
PO_DESC(debugMode, bool, false) \
|
||||
PO_DESC(screenMode, bool, false) \
|
||||
PO_DESC(printFPS, bool, false) \
|
||||
PO_DESC(fullscreen, bool, false) \
|
||||
PO_DESC(fixedAspectRatio, bool, true) \
|
||||
PO_DESC(smoothScaling, bool, false) \
|
||||
|
|
@ -97,7 +96,7 @@ void Config::read(int argc, char *argv[]){
|
|||
PO_DESC(SecurityEngine, bool, true) \
|
||||
PO_DESC(journal_address, std::string, "127.0.0.1") \
|
||||
PO_DESC(journal_port, int, 23821)
|
||||
|
||||
|
||||
// Not gonna take your shit boost
|
||||
#define GUARD_ALL( SDL_exp ) try { SDL_exp } catch(...) {}
|
||||
#define PO_DESC(key, type, def) (#key, po::value< type >()->default_value(def))
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ enum{
|
|||
REQUEST_MESSAGEBOX,
|
||||
REQUEST_SETCURSORVISIBLE,
|
||||
REQUEST_VSYNC,
|
||||
|
||||
|
||||
UPDATE_FPS,
|
||||
UPDATE_SCREEN_RECT,
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ void EventThread::process(RGSSThreadData &rtData){
|
|||
case SDL_EVENT_QUIT:
|
||||
if (rtData.allowExit) {
|
||||
terminate = true;
|
||||
Debug() << "[EventThread::process] EventThread termination requested";
|
||||
Debug() << "EventThread termination requested";
|
||||
} else {
|
||||
rtData.triedExit.set();
|
||||
}
|
||||
|
|
@ -385,7 +385,7 @@ void EventThread::process(RGSSThreadData &rtData){
|
|||
default :
|
||||
/* Handle user events */
|
||||
switch(event.type - usrIdStart){
|
||||
case REQUEST_VSYNC:
|
||||
case REQUEST_VSYNC:
|
||||
SDL_GL_SetSwapInterval(event.user.code);
|
||||
break;
|
||||
case REQUEST_SETFULLSCREEN :
|
||||
|
|
@ -530,7 +530,6 @@ void EventThread::setFullscreen(SDL_Window *win, bool mode){
|
|||
void EventThread::updateCursorState(bool inWindow, const SDL_Rect &screen){
|
||||
SDL_Point pos = { mouseState.x, mouseState.y };
|
||||
bool inScreen = inWindow && SDL_PointInRect(&pos, &screen);
|
||||
|
||||
if (inScreen)
|
||||
SDL_ShowCursor();
|
||||
else
|
||||
|
|
|
|||
68
src/main.cpp
68
src/main.cpp
|
|
@ -264,7 +264,6 @@ int main(int argc, char *argv[]){
|
|||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OSX and Windows have their own native ways of
|
||||
* dealing with icons; don't interfere with them */
|
||||
#ifdef unix_like
|
||||
|
|
@ -279,7 +278,6 @@ int main(int argc, char *argv[]){
|
|||
spec.freq = 44100;
|
||||
|
||||
MIX_Mixer* mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec);
|
||||
|
||||
if (!mixer){
|
||||
SDL_DestroyWindow(win);
|
||||
WarnMsg("Error creating Mixer Device, check your system audio configuration");
|
||||
|
|
@ -307,49 +305,41 @@ int main(int argc, char *argv[]){
|
|||
/* Load and post key bindings */
|
||||
rtData.bindingUpdateMsg.post(loadBindings(conf));
|
||||
/* Start RGSS thread */
|
||||
try{
|
||||
SDL_Thread *rgssThread = SDL_CreateThread(rgssThreadFun, "rgss", &rtData);
|
||||
if(rgssThread){
|
||||
WarnMsg("Thread creation failed: %s", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
/* Start event processing */
|
||||
eventThread.process(rtData);
|
||||
SDL_Thread *rgssThread = SDL_CreateThread(rgssThreadFun, "rgss", &rtData);
|
||||
/* Start event processing */
|
||||
eventThread.process(rtData);
|
||||
|
||||
/* Request RGSS thread to stop */
|
||||
rtData.rqTerm.set();
|
||||
/* Request RGSS thread to stop */
|
||||
rtData.rqTerm.set();
|
||||
|
||||
/* Wait for RGSS thread response */
|
||||
for (int i = 0; i < 1000; ++i){
|
||||
/* We can stop waiting when the request was ack'd */
|
||||
if (rtData.rqTermAck){
|
||||
Debug() << "[main] RGSS thread ack'd request after" << i*10 << "ms";
|
||||
break;
|
||||
}
|
||||
|
||||
/* Give RGSS thread some time to respond */
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
/* If RGSS thread ack'd request, wait for it to shutdown,
|
||||
* otherwise abandon hope and just end the process as is. */
|
||||
/* Wait for RGSS thread response */
|
||||
for (int i = 0; i < 1000; ++i){
|
||||
/* We can stop waiting when the request was ack'd */
|
||||
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 Sunshine will now force quit", win);
|
||||
Debug() << "[main] RGSS thread ack'd request after" << i*10 << "ms";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!rtData.rgssErrorMsg.empty())
|
||||
ErrorMsg(rtData.rgssErrorMsg.c_str());
|
||||
|
||||
/* Clean up any remainin events */
|
||||
eventThread.cleanup();
|
||||
|
||||
unloadLocale();
|
||||
unloadLanguageMetadata();
|
||||
}catch(const char* msg){
|
||||
ErrorMsg(msg);
|
||||
/* Give RGSS thread some time to respond */
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
/* If RGSS thread ack'd request, wait for it to shutdown,
|
||||
* otherwise abandon hope and just end the process as is. */
|
||||
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 Sunshine will now force quit", win);
|
||||
}
|
||||
|
||||
if (!rtData.rgssErrorMsg.empty())
|
||||
ErrorMsg(rtData.rgssErrorMsg.c_str());
|
||||
|
||||
/* Clean up any remainin events */
|
||||
eventThread.cleanup();
|
||||
|
||||
unloadLocale();
|
||||
unloadLanguageMetadata();
|
||||
if(show_crash_sceen){
|
||||
crash_screen(win);
|
||||
}
|
||||
|
|
|
|||
114
src/meow.cpp
114
src/meow.cpp
|
|
@ -24,6 +24,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ios>
|
||||
#include <ruby/version.h>
|
||||
#include <ruby/internal/interpreter.h>
|
||||
#undef vsnprintf
|
||||
|
|
@ -48,6 +49,7 @@
|
|||
#include "crash.png.xxd"
|
||||
using namespace std;
|
||||
|
||||
//help functions
|
||||
static inline const char* glGetStringInt(GLenum name){
|
||||
return (const char*) gl.GetString(name);
|
||||
}
|
||||
|
|
@ -72,6 +74,53 @@ static inline const char* glGetStringInt(GLenum name){
|
|||
#define COMPILER_VER "n/a"
|
||||
#endif
|
||||
|
||||
// https://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time
|
||||
const static char* get_processor(){
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
return "x86_64";
|
||||
#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
|
||||
return "x86_32";
|
||||
#elif defined(__ARM_ARCH_2__)
|
||||
return "ARM2";
|
||||
#elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__)
|
||||
return "ARM3";
|
||||
#elif defined(__ARM_ARCH_4T__) || defined(__TARGET_ARM_4T)
|
||||
return "ARM4T";
|
||||
#elif defined(__ARM_ARCH_5_) || defined(__ARM_ARCH_5E_)
|
||||
return "ARM5"
|
||||
#elif defined(__ARM_ARCH_6T2_) || defined(__ARM_ARCH_6T2_)
|
||||
return "ARM6T2";
|
||||
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
|
||||
return "ARM6";
|
||||
#elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
|
||||
return "ARM7";
|
||||
#elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
|
||||
return "ARM7A";
|
||||
#elif defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
|
||||
return "ARM7R";
|
||||
#elif defined(__ARM_ARCH_7M__)
|
||||
return "ARM7M";
|
||||
#elif defined(__ARM_ARCH_7S__)
|
||||
return "ARM7S";
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
return "ARM64";
|
||||
#elif defined(mips) || defined(__mips__) || defined(__mips)
|
||||
return "MIPS";
|
||||
#elif defined(__sh__)
|
||||
return "SUPERH";
|
||||
#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC)
|
||||
return "POWERPC";
|
||||
#elif defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
|
||||
return "POWERPC64";
|
||||
#elif defined(__sparc__) || defined(__sparc)
|
||||
return "SPARC";
|
||||
#elif defined(__m68k__)
|
||||
return "M68K";
|
||||
#else
|
||||
return "UNKNOWN";
|
||||
#endif
|
||||
}
|
||||
|
||||
static void get_reason_and_solution(Exception::Type t) {
|
||||
switch (t) {
|
||||
case Exception::ModLoaderError:
|
||||
|
|
@ -138,9 +187,10 @@ void crash(Exception::Type t, const char *fmt, ...) {
|
|||
va_end(args);
|
||||
get_reason_and_solution(t);
|
||||
show_crash_sceen = true;
|
||||
//Protect against segfaults
|
||||
if(is_ruby_initialized)
|
||||
//Protect against segfaults
|
||||
if(is_ruby_initialized){
|
||||
ruby_stop(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void crash_screen(SDL_Window* win){
|
||||
|
|
@ -158,7 +208,7 @@ void crash_screen(SDL_Window* win){
|
|||
skip_crash_screen = true;
|
||||
}
|
||||
SDL_Texture* tex = SDL_CreateTextureFromSurface(ren, crash_img);
|
||||
SDL_DestroySurface(crash_img);
|
||||
SDL_DestroySurface(crash_img);
|
||||
if (tex == nullptr) {
|
||||
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;
|
||||
|
|
@ -179,30 +229,26 @@ void crash_screen(SDL_Window* win){
|
|||
//collecting info and writing to crashdump
|
||||
if (o.is_open()){
|
||||
#ifdef DEVBUILD
|
||||
o << "EXPEREMENTAL BUILD" << endl;
|
||||
o << "EXPEREMENTAL BUILD\n";
|
||||
#endif
|
||||
o << "VERSION: " << VERSION_STRING << endl;
|
||||
o << "REASON: " << crash_message << endl;
|
||||
o << "Compiler info: " << COMPILER_NAME << " " << COMPILER_VER << endl << endl;
|
||||
|
||||
o << "[BOOST stacktrace()]" << endl << endl;
|
||||
o << "[BOOST stacktrace()]\n\n";
|
||||
o << boost::stacktrace::stacktrace() << endl;
|
||||
|
||||
o << "[LOG BUFFER]" << endl << endl;
|
||||
o << "[LOG BUFFER]\n\n";
|
||||
for (const auto& s : logs) {
|
||||
o << s << endl;
|
||||
}
|
||||
|
||||
o << endl;
|
||||
o << "[AUDIO]" << endl;
|
||||
|
||||
o << "\n[AUDIO]\n";
|
||||
o << "Driver used: " << SDL_GetCurrentAudioDriver() << endl;
|
||||
|
||||
o << endl;
|
||||
o << "[VIDEO]" << endl;
|
||||
o << "\n[VIDEO]\n";
|
||||
o << "Driver used: " << SDL_GetCurrentVideoDriver() << endl;
|
||||
|
||||
o << endl;
|
||||
o << "[VERSIONS OF LIBS]" << endl;
|
||||
o << "\n[VERSIONS OF LIBS]\n";
|
||||
const static int sdlcompiled = SDL_VERSION;
|
||||
const static int sdllinked = SDL_GetVersion();
|
||||
o << "SDL(compiled) version: " << SDL_VERSIONNUM_MAJOR(sdlcompiled) << "." << SDL_VERSIONNUM_MINOR(sdlcompiled) << "." << SDL_VERSIONNUM_MICRO(sdlcompiled) << endl;
|
||||
|
|
@ -214,8 +260,7 @@ void crash_screen(SDL_Window* win){
|
|||
o << "Boost versino: " << BOOST_VERSION / 100000 << "." << BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << endl;
|
||||
o << "Pixman version: " << PIXMAN_VERSION_STRING << endl;
|
||||
|
||||
o << endl;
|
||||
o << "[Platform specific]" << endl;
|
||||
o << "\n[Platform specific]\n";
|
||||
try{
|
||||
o << "Detected OS: " << SDL_GetPlatform() << endl;
|
||||
}catch(const std::exception& e){
|
||||
|
|
@ -228,9 +273,6 @@ void crash_screen(SDL_Window* win){
|
|||
}
|
||||
#elif android
|
||||
o << "Android API version: " << android_get_device_api_level() << endl;
|
||||
o << "Internal storage path: " << SDL_GetAndroidInternalStoragePath() << endl;
|
||||
o << "External Storage path: " << SDL_GetAndroidExternalStoragePath() << endl;
|
||||
o << "Cache path: " << SDL_GetAndroidCachePath() << endl;
|
||||
if(!is_privacy_crashdump_enabled){
|
||||
o << "Is ChromeBook? " << SDL_IsChromebook() << endl;
|
||||
o << "Is Phone? " << SDL_IsPhone() << endl;
|
||||
|
|
@ -247,17 +289,16 @@ void crash_screen(SDL_Window* win){
|
|||
#elif psp
|
||||
o << "PSPdev MIPS Stack Trace: " << pspDebugGetStackTrace() << endl;
|
||||
#endif
|
||||
|
||||
o << endl;
|
||||
o << "[Hardware]" << endl;
|
||||
|
||||
o << "\n[Hardware]\n";
|
||||
o << "number of logical CPU cores: " << SDL_GetNumLogicalCPUCores() << endl;
|
||||
o << "System RAM size: " << SDL_GetSystemRAM() << " MiB" << endl;
|
||||
if(!is_privacy_crashdump_enabled){
|
||||
o << "L1 cache size: " << SDL_GetCPUCacheLineSize() << endl;
|
||||
}
|
||||
|
||||
o << endl;
|
||||
o << "[OpenGL]" << endl;
|
||||
o << "CPU: " << get_processor() << endl;
|
||||
|
||||
o << "\n[OpenGL]\n";
|
||||
try{
|
||||
o << "GL Vendor: " << glGetStringInt(GL_VENDOR) << endl;
|
||||
o << "GL Renderer: " << glGetStringInt(GL_RENDERER) << endl;
|
||||
|
|
@ -271,7 +312,7 @@ void crash_screen(SDL_Window* win){
|
|||
o.close();
|
||||
}else{
|
||||
WarnMsg("[CRASHLOG] Failed to write crashdump file");
|
||||
}
|
||||
}
|
||||
|
||||
if(!skip_crash_screen){
|
||||
SDL_Event e;
|
||||
|
|
@ -284,14 +325,13 @@ void crash_screen(SDL_Window* win){
|
|||
(float)((winW - 100) / 2),
|
||||
(float)((winH - 100) / 2),
|
||||
(float)100,
|
||||
(float)100
|
||||
};
|
||||
|
||||
(float)100};
|
||||
|
||||
while (!quit) {
|
||||
while (SDL_PollEvent(&e)) {
|
||||
if (e.type == SDL_EVENT_QUIT) quit = true;
|
||||
}
|
||||
|
||||
|
||||
SDL_SetRenderDrawColor(ren, 0, 0, 0, 255);
|
||||
SDL_RenderClear(ren);
|
||||
SDL_RenderTexture(ren, tex, NULL, &dst);
|
||||
|
|
@ -327,8 +367,8 @@ void ErrorMsg(const char *fmt, ...) {
|
|||
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
SDL_snprintf(crash_message, sizeof(crash_message), "%s", buf);
|
||||
show_crash_sceen = true;
|
||||
SDL_snprintf(crash_message, sizeof(crash_message), "%s", buf);
|
||||
show_crash_screen = true;
|
||||
}
|
||||
|
||||
void ErrorMsg(Exception::Type t, const char *fmt, ...) {
|
||||
|
|
@ -346,9 +386,10 @@ void ErrorMsg(Exception::Type t, const char *fmt, ...) {
|
|||
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
SDL_snprintf(crash_message, sizeof(crash_message), "%s", buf);
|
||||
get_reason_and_solution(t);
|
||||
show_crash_sceen = true;
|
||||
SDL_snprintf(crash_message, sizeof(crash_message), "%s", buf);
|
||||
get_reason_and_solution(t);
|
||||
show_crash_screen = true;
|
||||
SDL_free(buf);
|
||||
}
|
||||
|
||||
void WarnMsg(const char *fmt, ...) {
|
||||
|
|
@ -365,6 +406,7 @@ void WarnMsg(const char *fmt, ...) {
|
|||
|
||||
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
||||
va_end(args);
|
||||
Debug() << "[WARNMSG]" << buf;
|
||||
Debug() << "[WARNMSG]" << buf;
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", buf, NULL);
|
||||
SDL_free(buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdk.h>
|
||||
#elif android
|
||||
//idk
|
||||
#include <SDL3/SDL_system.h>
|
||||
#else
|
||||
#error "Operating system not detected or unsupported."
|
||||
#endif
|
||||
|
|
@ -263,6 +263,14 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData){
|
|||
|
||||
// Get documents path
|
||||
const char* path = SDL_GetUserFolder(SDL_FOLDER_DOCUMENTS);
|
||||
if(path == NULL){
|
||||
path = SDL_GetUserFolder(SDL_FOLDER_HOME);
|
||||
if(path == NULL){
|
||||
WarnMsg("Failed to get user dir's, using current sirectory as fallback.");
|
||||
//use SDL instead this
|
||||
path == ".";
|
||||
}
|
||||
}
|
||||
p->docsPath = path;
|
||||
#ifdef windows
|
||||
p->gamePath = std::string(path) + "\\My Games";
|
||||
|
|
|
|||
Loading…
Reference in a new issue