mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
i hate my live
This commit is contained in:
parent
4660b3afc8
commit
958b9c246d
19 changed files with 116 additions and 96 deletions
|
|
@ -380,7 +380,7 @@ static void runCustomScript(const std::string &filename){
|
||||||
std::string scriptData;
|
std::string scriptData;
|
||||||
|
|
||||||
if (!readFileSDL(filename.c_str(), 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -401,7 +401,7 @@ static void runRMXPScripts(BacktraceData &btData){
|
||||||
const std::string &scriptPack = conf.game.scripts;
|
const std::string &scriptPack = conf.game.scripts;
|
||||||
|
|
||||||
if (!shState->fileSystem().exists(scriptPack.c_str())){
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,12 +412,12 @@ static void runRMXPScripts(BacktraceData &btData){
|
||||||
try{
|
try{
|
||||||
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
|
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
|
||||||
}catch (const Exception &e){
|
}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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -455,7 +455,7 @@ static void runRMXPScripts(BacktraceData &btData){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != Z_OK){
|
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;
|
break;
|
||||||
}
|
}
|
||||||
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
|
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.resize(SDL_strlen(file.c_str()));
|
||||||
file = btData.scriptNames.value(file, file);
|
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));
|
crash(Exception::RUBYError, true, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mriBindingExecute(){
|
static void mriBindingExecute(){
|
||||||
|
|
@ -566,7 +565,6 @@ static void mriBindingExecute(){
|
||||||
* stdio streams on some platforms (eg. Windows) */
|
* stdio streams on some platforms (eg. Windows) */
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char **argv = 0;
|
char **argv = 0;
|
||||||
//options_argv3[] = "--jit"
|
|
||||||
char options_argv1[] = "oneshot", options_argv2[] = "-ev";
|
char options_argv1[] = "oneshot", options_argv2[] = "-ev";
|
||||||
char* options_argv[] = {options_argv1, options_argv2, NULL};
|
char* options_argv[] = {options_argv1, options_argv2, NULL};
|
||||||
ruby_sysinit(&argc, &argv);
|
ruby_sysinit(&argc, &argv);
|
||||||
|
|
|
||||||
|
|
@ -25,3 +25,4 @@ fixed segfault while to fast window size changing
|
||||||
updated cg_blue picture
|
updated cg_blue picture
|
||||||
Deleted useless hooks
|
Deleted useless hooks
|
||||||
fix crash on game exit
|
fix crash on game exit
|
||||||
|
Error hadnling updated
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ inline uint8_t formatSampleSize(int sdlFormat){
|
||||||
case SDL_AUDIO_S16BE :
|
case SDL_AUDIO_S16BE :
|
||||||
return 2;
|
return 2;
|
||||||
default :
|
default :
|
||||||
crash(Exception::MEOW, "Unhandled sample format");
|
crash(Exception::SDLError, true, "Unhandled sample format");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -201,7 +201,7 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount){
|
||||||
case 2 : return AL_FORMAT_STEREO16;
|
case 2 : return AL_FORMAT_STEREO16;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
crash(Exception::MEOW, "Unhandled sample size / channel count");
|
crash(Exception::SDLError, true, "Unhandled sample size / channel count");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,8 @@ void ALStream::openSource(const std::string &filename){
|
||||||
shState->fileSystem().openRead(handler, filename.c_str());
|
shState->fileSystem().openRead(handler, filename.c_str());
|
||||||
source = handler.source;
|
source = handler.source;
|
||||||
needsRewind.clear();
|
needsRewind.clear();
|
||||||
|
|
||||||
if (!source)
|
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(){
|
void ALStream::stopStream(){
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
#define GUARD_MEGA \
|
#define GUARD_MEGA \
|
||||||
{ \
|
{ \
|
||||||
if (p->megaSurface) \
|
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
|
#define OUTLINE_SIZE 1
|
||||||
|
|
@ -221,12 +221,11 @@ struct BitmapOpenHandler : FileSystem::OpenHandler{
|
||||||
|
|
||||||
Bitmap::Bitmap(const char *filename){
|
Bitmap::Bitmap(const char *filename){
|
||||||
BitmapOpenHandler handler;
|
BitmapOpenHandler handler;
|
||||||
char msg[1024];
|
|
||||||
shState->fileSystem().openRead(handler, filename);
|
shState->fileSystem().openRead(handler, filename);
|
||||||
SDL_Surface *imgSurf = handler.surf;
|
SDL_Surface *imgSurf = handler.surf;
|
||||||
|
|
||||||
if (!imgSurf)
|
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);
|
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
|
||||||
|
|
||||||
|
|
@ -262,7 +261,7 @@ Bitmap::Bitmap(const char *filename){
|
||||||
|
|
||||||
Bitmap::Bitmap(int width, int height){
|
Bitmap::Bitmap(int width, int height){
|
||||||
if (width <= 0 || height <= 0)
|
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);
|
TEXFBO tex = shState->texPool().request(width, height);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ void Color::serialize(char *buffer) const{
|
||||||
|
|
||||||
Color *Color::deserialize(const char *data, int len){
|
Color *Color::deserialize(const char *data, int len){
|
||||||
if (len != 32)
|
if (len != 32)
|
||||||
crash(Exception::ArgumentError, "Color: Serialized data invalid");
|
crash(Exception::ArgumentError, true, "Color: Serialized data invalid");
|
||||||
|
|
||||||
Color *c = new Color();
|
Color *c = new Color();
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ void Tone::serialize(char *buffer) const{
|
||||||
|
|
||||||
Tone *Tone::deserialize(const char *data, int len){
|
Tone *Tone::deserialize(const char *data, int len){
|
||||||
if (len != 32)
|
if (len != 32)
|
||||||
crash(Exception::ArgumentError, "Tone: Serialized data invalid");
|
crash(Exception::ArgumentError, true, "Tone: Serialized data invalid");
|
||||||
|
|
||||||
Tone *t = new Tone();
|
Tone *t = new Tone();
|
||||||
|
|
||||||
|
|
@ -350,7 +350,7 @@ void Rect::serialize(char *buffer) const{
|
||||||
|
|
||||||
Rect *Rect::deserialize(const char *data, int len){
|
Rect *Rect::deserialize(const char *data, int len){
|
||||||
if (len != 16)
|
if (len != 16)
|
||||||
crash(Exception::ArgumentError, "Rect: Serialized data invalid");
|
crash(Exception::ArgumentError, true, "Rect: Serialized data invalid");
|
||||||
|
|
||||||
Rect *r = new Rect();
|
Rect *r = new Rect();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
struct Exception{
|
struct Exception{
|
||||||
enum Type{
|
enum Type{
|
||||||
RGSSError,
|
RGSSError,
|
||||||
|
RUBYError,
|
||||||
NoFileError,
|
NoFileError,
|
||||||
IOError,
|
IOError,
|
||||||
|
|
||||||
|
|
@ -42,9 +43,6 @@ struct Exception{
|
||||||
|
|
||||||
//modloader
|
//modloader
|
||||||
ModLoaderError,
|
ModLoaderError,
|
||||||
|
|
||||||
// For crash()
|
|
||||||
MEOW
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
|
|
|
||||||
|
|
@ -127,22 +127,20 @@ TTF_Font *SharedFontState::getFont(std::string family, unsigned int size){
|
||||||
SDL_IOStream *ops;
|
SDL_IOStream *ops;
|
||||||
|
|
||||||
if (family.empty()){
|
if (family.empty()){
|
||||||
crash(Exception::RGSSError, "font does not exist");
|
crash(Exception::RGSSError, true, "font does not exist");
|
||||||
}else{
|
}else{
|
||||||
/* Use 'other' path as alternative in case
|
/* Use 'other' path as alternative in case
|
||||||
* we have no 'regular' styled font asset */
|
* we have no 'regular' styled font asset */
|
||||||
const char *path = !req.regular.empty()
|
const char *path = !req.regular.empty()
|
||||||
? req.regular.c_str() : req.other.c_str();
|
? req.regular.c_str() : req.other.c_str();
|
||||||
|
|
||||||
//ops = SDL_OpenIO();
|
|
||||||
// SDL_IOStream* ops;
|
|
||||||
shState->fileSystem().openReadRaw(ops, path);
|
shState->fileSystem().openReadRaw(ops, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
font = TTF_OpenFontIO(ops, 1, size);
|
font = TTF_OpenFontIO(ops, 1, size);
|
||||||
|
|
||||||
if (!font){
|
if (!font){
|
||||||
crash(Exception::SDLError, "%s", SDL_GetError());
|
crash(Exception::SDLError, true, "%s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
p->pool.insert(key, font);
|
p->pool.insert(key, font);
|
||||||
|
|
@ -303,7 +301,7 @@ void Font::setSize(int value){
|
||||||
|
|
||||||
/* Catch illegal values (according to RMXP) */
|
/* Catch illegal values (according to RMXP) */
|
||||||
if (value < 6 || value > 96)
|
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->size = value;
|
||||||
p->sdlFont = 0;
|
p->sdlFont = 0;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ void initGLFunctions(){
|
||||||
int glMajor = *ver - '0';
|
int glMajor = *ver - '0';
|
||||||
|
|
||||||
if (glMajor < 2)
|
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){
|
if (gles){
|
||||||
GL_ES_FUN;
|
GL_ES_FUN;
|
||||||
|
|
@ -126,7 +126,7 @@ void initGLFunctions(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
crash(Exception::MKXPError, "No FBO support available");
|
crash(Exception::MKXPError, false, "No FBO support available");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* VAO entrypoints */
|
/* VAO entrypoints */
|
||||||
|
|
|
||||||
32
src/main.cpp
32
src/main.cpp
|
|
@ -99,7 +99,7 @@ int rgssThreadFun(void *userdata){
|
||||||
glCtx = SDL_GL_CreateContext(win);
|
glCtx = SDL_GL_CreateContext(win);
|
||||||
|
|
||||||
if (!glCtx){
|
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));
|
rgssThreadError(threadData, std::string(msg));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +108,7 @@ int rgssThreadFun(void *userdata){
|
||||||
initGLFunctions();
|
initGLFunctions();
|
||||||
}
|
}
|
||||||
catch (const Exception &exc){
|
catch (const Exception &exc){
|
||||||
crash(Exception::MEOW, exc.msg.c_str());
|
crash(Exception::RGSSError, false, exc.msg.c_str());
|
||||||
rgssThreadError(threadData, exc.msg);
|
rgssThreadError(threadData, exc.msg);
|
||||||
SDL_GL_DestroyContext(glCtx);
|
SDL_GL_DestroyContext(glCtx);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -136,7 +136,6 @@ int rgssThreadFun(void *userdata){
|
||||||
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
|
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
|
||||||
|
|
||||||
if (!alcCtx){
|
if (!alcCtx){
|
||||||
crash(Exception::MEOW, "Error creating OpenAL context");
|
|
||||||
rgssThreadError(threadData, "Error creating OpenAL context");
|
rgssThreadError(threadData, "Error creating OpenAL context");
|
||||||
SDL_GL_DestroyContext(glCtx);
|
SDL_GL_DestroyContext(glCtx);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -147,11 +146,9 @@ int rgssThreadFun(void *userdata){
|
||||||
try{
|
try{
|
||||||
SharedState::initInstance(threadData);
|
SharedState::initInstance(threadData);
|
||||||
}catch (const Exception &exc){
|
}catch (const Exception &exc){
|
||||||
crash(Exception::MEOW, exc.msg.c_str());
|
|
||||||
rgssThreadError(threadData, exc.msg);
|
rgssThreadError(threadData, exc.msg);
|
||||||
alcDestroyContext(alcCtx);
|
alcDestroyContext(alcCtx);
|
||||||
SDL_GL_DestroyContext(glCtx);
|
SDL_GL_DestroyContext(glCtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +162,6 @@ int rgssThreadFun(void *userdata){
|
||||||
|
|
||||||
alcDestroyContext(alcCtx);
|
alcDestroyContext(alcCtx);
|
||||||
SDL_GL_DestroyContext(glCtx);
|
SDL_GL_DestroyContext(glCtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,13 +220,11 @@ int main(int argc, char *argv[]){
|
||||||
#if dos
|
#if dos
|
||||||
__djgpp_nearptr_enable();
|
__djgpp_nearptr_enable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SecurityManagerInit();
|
SecurityManagerInit();
|
||||||
startTime = boost::chrono::high_resolution_clock::now();
|
startTime = boost::chrono::high_resolution_clock::now();
|
||||||
loadLanguageMetadata(); //there will be a segfault on fclose if I don't move it here
|
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_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!
|
//X11 work on *BSD,Solaris too!
|
||||||
#if unix_like
|
#if unix_like
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
||||||
|
|
@ -250,19 +244,19 @@ int main(int argc, char *argv[]){
|
||||||
#endif
|
#endif
|
||||||
/* initialize SDL first */
|
/* initialize SDL first */
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STEAM
|
#ifdef STEAM
|
||||||
if (!STEAMSHIM_init()){
|
if (!STEAMSHIM_init()){
|
||||||
crash(Exception::MEOW, "Could not initialize Steamworks API");
|
crash(Exception::SDLError, false, "Could not initialize Steamworks API");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!EventThread::allocUserEvents()){
|
if (!EventThread::allocUserEvents()){
|
||||||
crash(Exception::MEOW, "Error allocating SDL user events");
|
crash(Exception::SDLError, false, "Error allocating SDL user events");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,7 +287,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
if (!conf.gameFolder.empty()){
|
if (!conf.gameFolder.empty()){
|
||||||
if (chdir(conf.gameFolder.c_str()) != 0){
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -306,12 +300,12 @@ int main(int argc, char *argv[]){
|
||||||
conf.windowTitle = conf.game.title;
|
conf.windowTitle = conf.game.title;
|
||||||
|
|
||||||
if (TTF_Init() == false){
|
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();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Sound_Init() == false){
|
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();
|
TTF_Quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
|
|
@ -326,7 +320,7 @@ int main(int argc, char *argv[]){
|
||||||
SDL_SetWindowFullscreen(win, true);
|
SDL_SetWindowFullscreen(win, true);
|
||||||
|
|
||||||
if (!win){
|
if (!win){
|
||||||
crash(Exception::MEOW, "Error creating window: %s", SDL_GetError());
|
crash(Exception::SDLError, false,"Error creating window: %s", SDL_GetError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -342,7 +336,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
if (!alcDev){
|
if (!alcDev){
|
||||||
SDL_DestroyWindow(win);
|
SDL_DestroyWindow(win);
|
||||||
crash(Exception::MEOW, "Error opening OpenAL device");
|
crash(Exception::SDLError, false, "Error opening OpenAL device");
|
||||||
TTF_Quit();
|
TTF_Quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return 0;
|
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);
|
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())
|
if (!rtData.rgssErrorMsg.empty())
|
||||||
crash(Exception::MEOW, rtData.rgssErrorMsg.c_str());
|
crash(Exception::RGSSError, false, rtData.rgssErrorMsg.c_str());
|
||||||
|
|
||||||
/* Clean up any remainin events */
|
/* Clean up any remainin events */
|
||||||
eventThread.cleanup();
|
eventThread.cleanup();
|
||||||
|
|
@ -409,7 +403,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
Sound_Quit();
|
Sound_Quit();
|
||||||
TTF_Quit();
|
TTF_Quit();
|
||||||
SDL_Quit(); // i got "Thread 1 received signal ?, Unknown signal" here on windows after closing game
|
SDL_Quit();
|
||||||
|
|
||||||
#ifdef STEAM
|
#ifdef STEAM
|
||||||
STEAMSHIM_deinit();
|
STEAMSHIM_deinit();
|
||||||
|
|
|
||||||
94
src/meow.cpp
94
src/meow.cpp
|
|
@ -13,27 +13,36 @@
|
||||||
#include "gl-debug.h"
|
#include "gl-debug.h"
|
||||||
#include "gl-fun.h"
|
#include "gl-fun.h"
|
||||||
#include "debugwriter.h"
|
#include "debugwriter.h"
|
||||||
|
#include "define.h"
|
||||||
#include <SDL3/SDL_stdinc.h>
|
#include <SDL3/SDL_stdinc.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ruby/version.h>
|
#include <ruby/version.h>
|
||||||
|
#include <ruby/internal/intern/vm.h>
|
||||||
|
#include <ruby/internal/error.h>
|
||||||
|
#include <ruby/debug.h>
|
||||||
|
#include <ruby.h>
|
||||||
|
#undef vsnprintf
|
||||||
|
#undef snprintf
|
||||||
|
#include <boost/stacktrace.hpp>
|
||||||
|
#include <boost/version.hpp>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <AL/al.h>
|
#include <AL/al.h>
|
||||||
#include <boost/version.hpp>
|
|
||||||
#include <physfs.h>
|
#include <physfs.h>
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
#include <SDL3/SDL_system.h>
|
#include <SDL3/SDL_system.h>
|
||||||
#include <boost/stacktrace.hpp>
|
|
||||||
#include <SDL3/SDL_cpuinfo.h>
|
#include <SDL3/SDL_cpuinfo.h>
|
||||||
#include "sunshine.h"
|
#include "sunshine.h"
|
||||||
#ifdef __LINUX__
|
#ifdef unix_like
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "xdg-user-dir-lookup.h"
|
#include "xdg-user-dir-lookup.h"
|
||||||
#elif __ANDROID__
|
#elif android
|
||||||
#include <android/trace.h>
|
#include <android/trace.h>
|
||||||
#include <android/api-level.h>
|
#include <android/api-level.h>
|
||||||
#elif __EMSCRIPTEN__
|
#elif web
|
||||||
#include <emscripten/console.h>
|
#include <emscripten/console.h>
|
||||||
|
#elif dos
|
||||||
|
#include <dpmi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_MessageBoxButtonData buttons[] = {
|
SDL_MessageBoxButtonData buttons[] = {
|
||||||
|
|
@ -45,8 +54,10 @@ static inline const char* glGetStringInt(GLenum name){
|
||||||
return (const char*) gl.GetString(name);
|
return (const char*) gl.GetString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void crash(Exception::Type t, const char *fmt, ...){
|
void crash(Exception::Type t, bool do_crash, const char *fmt, ...){
|
||||||
char msg[1024];
|
static char msg[1024];
|
||||||
|
static const char* reason = nullptr;
|
||||||
|
static const char* solution = nullptr;
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
va_list args_copy;
|
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);
|
char *buf = (char*)SDL_malloc((size_t)len + 1);
|
||||||
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
||||||
va_end(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 = {
|
SDL_MessageBoxData messageboxdata = {
|
||||||
.flags = SDL_MESSAGEBOX_ERROR,
|
.flags = SDL_MESSAGEBOX_ERROR,
|
||||||
.window = NULL,
|
.window = NULL,
|
||||||
|
|
@ -82,17 +104,6 @@ void crash(Exception::Type t, const char *fmt, ...){
|
||||||
o << "REASON: " << buf << std::endl;
|
o << "REASON: " << buf << std::endl;
|
||||||
o << "[BOOST stacktrace()]" << std::endl;
|
o << "[BOOST stacktrace()]" << std::endl;
|
||||||
o << boost::stacktrace::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;
|
o << "[Versions of libs]" << std::endl;
|
||||||
const int sdlcompiled = SDL_VERSION;
|
const int sdlcompiled = SDL_VERSION;
|
||||||
const int sdllinked = SDL_GetVersion();
|
const int sdllinked = SDL_GetVersion();
|
||||||
|
|
@ -112,10 +123,11 @@ void crash(Exception::Type t, const char *fmt, ...){
|
||||||
}catch(const std::exception& e){
|
}catch(const std::exception& e){
|
||||||
o << "Detected OS: " << e.what() << std::endl;
|
o << "Detected OS: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
if(!SDL_getenv("XDG_CURRENT_DESKTOP") == NULL){
|
#ifdef unix_like
|
||||||
|
if(SDL_getenv("XDG_CURRENT_DESKTOP") != nullptr){
|
||||||
o << "Desktop enviroment(XDG_CURRENT_DESKTOP): " << SDL_getenv("XDG_CURRENT_DESKTOP") << std::endl;
|
o << "Desktop enviroment(XDG_CURRENT_DESKTOP): " << SDL_getenv("XDG_CURRENT_DESKTOP") << std::endl;
|
||||||
}
|
}
|
||||||
#ifdef __ANDROID__
|
#elif android
|
||||||
o << "Android API version: " << android_get_device_api_level() << std::endl;
|
o << "Android API version: " << android_get_device_api_level() << std::endl;
|
||||||
o << "External storage State: " << SDL_GetAndroidExternalStorageState() << std::endl;
|
o << "External storage State: " << SDL_GetAndroidExternalStorageState() << std::endl;
|
||||||
o << "Internal storage path: " << SDL_GetAndroidInternalStoragePath() << 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 TV? " << SDL_IsTV() << std::endl;
|
||||||
o << "Is Ubuntu Touch? " << SDL_IsUbuntuTouch() << 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 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 end address of the stack: " << emscripten_stack_get_end() << std::endl;
|
||||||
o << "Emscripten current stack pointer: " << emscripten_stack_get_current() << 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;
|
o << "Emscripten number of free bytes left on stack: " << emscripten_stack_get_free() << std::endl;
|
||||||
#elif __PSP__
|
#elif psp
|
||||||
o << "PSPdev MIPS Stack Trace: " << int pspDebugGetStackTrace() << std::endl;
|
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
|
#endif
|
||||||
o << "[Hardware]" << std::endl;
|
o << "[Hardware]" << std::endl;
|
||||||
o << "number of logical CPU cores: " << SDL_GetNumLogicalCPUCores() << std::endl;
|
o << "number of logical CPU cores: " << SDL_GetNumLogicalCPUCores() << std::endl;
|
||||||
o << "System RAM size: " << SDL_GetSystemRAM() << " MiB" << 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();
|
o.close();
|
||||||
}else{
|
}else{
|
||||||
Debug() << "[CRASHLOG] Failed to write crashdump file";
|
ErrorMsg("[CRASHLOG] Failed to write crashdump file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(do_crash){
|
||||||
if(!t == Exception::MEOW)
|
rb_exit(-1);
|
||||||
throw Exception(t, msg);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ErrorMsg(const char* message){
|
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){
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "exception.h"
|
#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 ErrorMsg(const char* message);
|
||||||
void WarnMsg(const char* message);
|
void WarnMsg(const char* message);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ std::string sha512(const std::string str){
|
||||||
std::string sha256_file(const std::string &fn) {
|
std::string sha256_file(const std::string &fn) {
|
||||||
FILE *file = fopen(fn.c_str(), "rb");
|
FILE *file = fopen(fn.c_str(), "rb");
|
||||||
if (!file) {
|
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];
|
unsigned char buf[1024];
|
||||||
|
|
@ -98,7 +98,7 @@ void ModLoader(){
|
||||||
std::string full = p.string();
|
std::string full = p.string();
|
||||||
int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0);
|
int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
crash(Exception::ModLoaderError, "PhysFS_mount failed: %s", PHYSFS_getLastError());
|
crash(Exception::ModLoaderError, false, "PhysFS_mount failed: %s", PHYSFS_getLastError());
|
||||||
}
|
}
|
||||||
Debug() << "[MODLOADER] " << full;
|
Debug() << "[MODLOADER] " << full;
|
||||||
mod_list.push_back(full);
|
mod_list.push_back(full);
|
||||||
|
|
@ -112,6 +112,6 @@ void ModLoader(){
|
||||||
Debug() << "[MODLOADER] BuildID: " << buildID;
|
Debug() << "[MODLOADER] BuildID: " << buildID;
|
||||||
modloader_is_enabled = true;
|
modloader_is_enabled = true;
|
||||||
}catch(const std::exception& e){
|
}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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
win = SDL_CreateWindow("The Journal", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOW_RESIZABLE | SDL_WINDOW_TRANSPARENT);
|
||||||
|
|
||||||
if (!win){
|
if (!win){
|
||||||
crash(Exception::MEOW, "Error creating window: %s", SDL_GetError());
|
crash(Exception::SDLError, true, "Error creating window: %s", SDL_GetError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
inline char* securitystate = "unsandboxed";
|
inline const char* securitystate = "unsandboxed";
|
||||||
void SecurityManagerInit();
|
void SecurityManagerInit();
|
||||||
void SecurityManagerDeInit();
|
void SecurityManagerDeInit();
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){
|
||||||
buffer = handler.buffer;
|
buffer = handler.buffer;
|
||||||
|
|
||||||
if (!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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ void Table::serialize(char *buffer) const{
|
||||||
|
|
||||||
Table *Table::deserialize(const char *data, int len){
|
Table *Table::deserialize(const char *data, int len){
|
||||||
if (len < 20)
|
if (len < 20)
|
||||||
crash(Exception::RGSSError, "Marshal: Table: bad file format");
|
crash(Exception::RGSSError, true, "Marshal: Table: bad file format");
|
||||||
|
|
||||||
readInt32(&data);
|
readInt32(&data);
|
||||||
int x = readInt32(&data);
|
int x = readInt32(&data);
|
||||||
|
|
@ -123,10 +123,10 @@ Table *Table::deserialize(const char *data, int len){
|
||||||
int size = readInt32(&data);
|
int size = readInt32(&data);
|
||||||
|
|
||||||
if (size != x*y*z)
|
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)
|
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);
|
Table *t = new Table(x, y, z);
|
||||||
SDL_memcpy(dataPtr(t->data), data, sizeof(int16_t)*size);
|
SDL_memcpy(dataPtr(t->data), data, sizeof(int16_t)*size);
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ TEXFBO TexPool::request(int width, int height){
|
||||||
|
|
||||||
int maxSize = glState.caps.maxTexSize;
|
int maxSize = glState.caps.maxTexSize;
|
||||||
if (width > maxSize || height > maxSize){
|
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 */
|
/* Nope, create it instead */
|
||||||
|
|
@ -162,8 +162,7 @@ void TexPool::release(TEXFBO &obj){
|
||||||
|
|
||||||
CNodeList &bucket = p->poolHash[removedSize];
|
CNodeList &bucket = p->poolHash[removedSize];
|
||||||
|
|
||||||
std::list<CacheNode>::iterator toRemove =
|
std::list<CacheNode>::iterator toRemove = std::find(bucket.begin(), bucket.end(), last);
|
||||||
std::find(bucket.begin(), bucket.end(), last);
|
|
||||||
assert(toRemove != bucket.end());
|
assert(toRemove != bucket.end());
|
||||||
bucket.erase(toRemove);
|
bucket.erase(toRemove);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ struct VorbisSource : ALDataSource{
|
||||||
|
|
||||||
if (error){
|
if (error){
|
||||||
SDL_CloseIO(&src);
|
SDL_CloseIO(&src);
|
||||||
crash(Exception::MKXPError, "Vorbisfile: Cannot read ogg file");
|
crash(Exception::MKXPError, true, "Vorbisfile: Cannot read ogg file");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract bitstream info */
|
/* Extract bitstream info */
|
||||||
|
|
@ -89,7 +89,7 @@ struct VorbisSource : ALDataSource{
|
||||||
if (info.channels > 2){
|
if (info.channels > 2){
|
||||||
ov_clear(&vf);
|
ov_clear(&vf);
|
||||||
SDL_CloseIO(&src);
|
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);
|
info.alFormat = chooseALFormat(sizeof(int16_t), info.channels);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue