From 5b18134bf0b6ff1ac6b7bba9fdc92d8a2ed68379 Mon Sep 17 00:00:00 2001 From: Issac332 <119879937+Issac8658@users.noreply.github.com> Date: Sun, 31 May 2026 20:37:15 +0300 Subject: [PATCH] Revert "Meow" This reverts commit c5589bff11509092436841d75a3cc76d10177741. --- binding-mri/audio-binding.cpp | 5 +++- binding-mri/binding-mri.cpp | 23 ++++++++++++------- binding-mri/binding-util.cpp | 2 +- binding-mri/bitmap-binding.cpp | 33 +++++++++++++++++++++++---- binding-mri/font-binding.cpp | 8 +++++-- binding-mri/viewport-binding.cpp | 2 +- binding-mri/wallpaper-binding.cpp | 3 +-- binding-mri/window-binding.cpp | 3 +++ src/al-util.h | 6 +++-- src/alstream.cpp | 4 +++- src/audio.cpp | 4 ++++ src/bitmap.cpp | 12 ++++++---- src/config.cpp | 4 ++-- src/disposable.h | 7 +++--- src/etc.cpp | 9 +++++--- src/font.cpp | 13 +++++++---- src/input.cpp | 6 +++-- src/main.cpp | 38 ++++++++++++++++++------------- src/meow.cpp | 31 ++++--------------------- src/meow.h | 3 +-- src/scene.cpp | 8 +++++++ src/screen.cpp | 3 ++- src/sdlsoundsource.cpp | 5 ++-- src/shader.cpp | 15 +++++++++--- src/soundemitter.cpp | 4 +++- src/sprite.cpp | 10 +++++++- src/table.cpp | 6 ++--- src/texpool.cpp | 4 +++- src/tilemap.cpp | 26 +++++++++++++-------- src/tilequad.h | 18 +++++++++++---- src/vorbissource.cpp | 4 ++-- 31 files changed, 205 insertions(+), 114 deletions(-) diff --git a/binding-mri/audio-binding.cpp b/binding-mri/audio-binding.cpp index 1de027b..0c42f1f 100644 --- a/binding-mri/audio-binding.cpp +++ b/binding-mri/audio-binding.cpp @@ -32,7 +32,10 @@ int volume = 100; \ int pitch = 100; \ double pos = 0.0; \ - rb_get_args(argc, argv, "z|ii", &filename, &volume, &pitch RB_ARG_END); \ + if (rgssVer >= 3) \ + rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \ + else \ + rb_get_args(argc, argv, "z|ii", &filename, &volume, &pitch RB_ARG_END); \ GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \ return Qnil; \ } \ diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 32a8c78..ca671fb 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -322,7 +322,8 @@ static void runCustomScript(const std::string &filename){ char msg[1024]; if (!readFileSDL(filename.c_str(), scriptData)){ - crash(Exception::MEOW, false, "Unable to open %s", filename); + snprintf(msg, sizeof msg, "Unable to open %s", filename); + crash(msg, Exception::MEOW, false); return; } @@ -336,14 +337,16 @@ struct BacktraceData{ BoostHash scriptNames; }; -#define SCRIPT_SECTION_FMT ("Section%03ld") +#define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld") static void runRMXPScripts(BacktraceData &btData){ const Config &conf = shState->rtData().config; const std::string &scriptPack = conf.game.scripts; + char msg[1024]; if (!shState->fileSystem().exists(scriptPack.c_str())){ - crash(Exception::MEOW, false, "Unable to open '%s'", scriptPack.c_str()); + snprintf(msg, sizeof msg, "Unable to open '%s'", scriptPack.c_str()); + crash(msg, Exception::MEOW, false); return; } @@ -354,12 +357,13 @@ static void runRMXPScripts(BacktraceData &btData){ try{ scriptArray = kernelLoadDataInt(scriptPack.c_str(), false); }catch (const Exception &e){ - crash(Exception::MEOW, false, "Failed to read script data: %s", e.msg); + snprintf(msg, sizeof msg, "Failed to read script data: %s", e.msg); + crash(msg, Exception::MEOW, false); return; } if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){ - crash(Exception::MEOW, false, "Failed to read script data"); + crash("Failed to read script data", Exception::MEOW, false); return; } @@ -402,7 +406,8 @@ static void runRMXPScripts(BacktraceData &btData){ if (result != Z_OK){ static char buffer[256]; - crash(Exception::MEOW, false, "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName)); + snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName)); + crash(buffer, Exception::MEOW, false); break; } @@ -499,7 +504,9 @@ static void showExc(VALUE exc, const BacktraceData &btData){ file.resize(strlen(file.c_str())); file = btData.scriptNames.value(file, file); - crash(Exception::MEOW, false, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg)); + char ms[640]; + snprintf(&ms[0], 640, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg)); + crash(ms, Exception::MEOW, false); exit(0); } @@ -510,7 +517,7 @@ static void mriBindingExecute(){ //JIT for performance int argc = 0; char **argv = 0; - char options_argv1[] = "oneshot", options_argv2[] = "-ev", options_argv3[] = "--jit"; + char options_argv1[] = "oneshot", options_argv2[] = "-evd", options_argv3[] = "--jit"; char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL}; ruby_sysinit(&argc, &argv); RUBY_INIT_STACK; diff --git a/binding-mri/binding-util.cpp b/binding-mri/binding-util.cpp index 38a7d9e..91426a3 100644 --- a/binding-mri/binding-util.cpp +++ b/binding-mri/binding-util.cpp @@ -48,7 +48,7 @@ RbData::RbData(){ exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException); exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError); - exc[Reset] = rb_define_class("Reset", rb_eException); + exc[Reset] = rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException); exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT")); exc[IOError] = rb_eIOError; diff --git a/binding-mri/bitmap-binding.cpp b/binding-mri/bitmap-binding.cpp index 40a245a..fd4b0c9 100644 --- a/binding-mri/bitmap-binding.cpp +++ b/binding-mri/bitmap-binding.cpp @@ -238,7 +238,14 @@ RB_METHOD(bitmapDrawText){ VALUE rectObj; Rect *rect; - rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END); + if (rgssVer >= 2){ + VALUE strObj; + rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END); + + str = objAsStringPtr(strObj); + }else{ + rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END); + } rect = getPrivateDataCheck(rectObj, RectType); @@ -246,7 +253,14 @@ RB_METHOD(bitmapDrawText){ }else{ int x, y, width, height; - rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END); + if (rgssVer >= 2){ + VALUE strObj; + rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END); + + str = objAsStringPtr(strObj); + }else{ + rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END); + } GUARD_EXC( b->drawText(x, y, width, height, str, align); ); } @@ -259,7 +273,14 @@ RB_METHOD(bitmapTextSize){ const char *str; - rb_get_args(argc, argv, "z", &str RB_ARG_END); + if (rgssVer >= 2){ + VALUE strObj; + rb_get_args(argc, argv, "o", &strObj RB_ARG_END); + + str = objAsStringPtr(strObj); + }else{ + rb_get_args(argc, argv, "z", &str RB_ARG_END); + } IntRect value; GUARD_EXC( value = b->textSize(str); ); @@ -282,7 +303,8 @@ RB_METHOD(bitmapGradientFillRect){ VALUE rectObj; Rect *rect; - rb_get_args(argc, argv, "ooo|b", &rectObj, &color1Obj, &color2Obj, &vertical RB_ARG_END); + rb_get_args(argc, argv, "ooo|b", &rectObj, + &color1Obj, &color2Obj, &vertical RB_ARG_END); rect = getPrivateDataCheck(rectObj, RectType); color1 = getPrivateDataCheck(color1Obj, ColorType); @@ -292,7 +314,8 @@ RB_METHOD(bitmapGradientFillRect){ }else{ int x, y, width, height; - rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height, &color1Obj, &color2Obj, &vertical RB_ARG_END); + rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height, + &color1Obj, &color2Obj, &vertical RB_ARG_END); color1 = getPrivateDataCheck(color1Obj, ColorType); color2 = getPrivateDataCheck(color2Obj, ColorType); diff --git a/binding-mri/font-binding.cpp b/binding-mri/font-binding.cpp index eba13fa..b6b8e00 100644 --- a/binding-mri/font-binding.cpp +++ b/binding-mri/font-binding.cpp @@ -93,7 +93,9 @@ RB_METHOD(fontInitialize){ f->initDynAttribs(); wrapProperty(self, &f->getColor(), "color", ColorType); - wrapProperty(self, &f->getOutColor(), "out_color", ColorType); + + if (rgssVer >= 3) + wrapProperty(self, &f->getOutColor(), "out_color", ColorType); return self; } @@ -113,7 +115,9 @@ RB_METHOD(fontInitializeCopy){ f->initDynAttribs(); wrapProperty(self, &f->getColor(), "color", ColorType); - wrapProperty(self, &f->getOutColor(), "out_color", ColorType); + + if (rgssVer >= 3) + wrapProperty(self, &f->getOutColor(), "out_color", ColorType); return self; } diff --git a/binding-mri/viewport-binding.cpp b/binding-mri/viewport-binding.cpp index b720eff..b9e0d01 100644 --- a/binding-mri/viewport-binding.cpp +++ b/binding-mri/viewport-binding.cpp @@ -32,7 +32,7 @@ DEF_TYPE(Viewport); RB_METHOD(viewportInitialize){ Viewport *v; - if (argc == 0){ + if (argc == 0 && rgssVer >= 3){ v = new Viewport(); } else if (argc == 1){ diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 9a49684..bfc1848 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -188,8 +188,7 @@ desktop = "kde_error"; } } else { - //not all linux enviroment show dekstop icons + need translation support - fallbackPath = std::string(getenv("HOME")) + "/ONESHOT_hint.png"; + fallbackPath = std::string(getenv("HOME")) + "/Desktop/ONESHOT_hint.png"; } } #endif diff --git a/binding-mri/window-binding.cpp b/binding-mri/window-binding.cpp index a8cf07e..0ea04ad 100644 --- a/binding-mri/window-binding.cpp +++ b/binding-mri/window-binding.cpp @@ -27,6 +27,9 @@ DEF_TYPE(Window); RB_METHOD(windowInitialize){ + #ifdef DEBUG + printf("[windowInitialize] Creating window\n"); + #endif Window *w = viewportElementInitialize(argc, argv, self); setPrivateData(self, w); diff --git a/src/al-util.h b/src/al-util.h index 385e6cb..41a59db 100644 --- a/src/al-util.h +++ b/src/al-util.h @@ -177,7 +177,8 @@ inline uint8_t formatSampleSize(int sdlFormat){ case SDL_AUDIO_S16BE : return 2; default : - crash(Exception::MEOW, true, "Unhandled sample format"); + crash("Unhandled sample format", Exception::MEOW, false); + assert(!"Unhandled sample format"); } return 0; @@ -196,7 +197,8 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount){ case 2 : return AL_FORMAT_STEREO16; } default : - crash(Exception::SDLError, true, "Unhandled sample size / channel count"); + crash("Unhandled sample size / channel count", Exception::MEOW, false); + assert(!"Unhandled sample size / channel count"); } return 0; diff --git a/src/alstream.cpp b/src/alstream.cpp index 6348b34..eea6f4d 100644 --- a/src/alstream.cpp +++ b/src/alstream.cpp @@ -231,7 +231,9 @@ void ALStream::openSource(const std::string &filename){ needsRewind.clear(); if (!source){ - crash(Exception::MEOW, false, "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str()); + char buf[512]; + snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str()); + crash(buf, Exception::MEOW, false); } } diff --git a/src/audio.cpp b/src/audio.cpp index 344f5d4..2898a72 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -231,6 +231,7 @@ Audio::Audio(RGSSThreadData &rtData) : p(new AudioPrivate(rtData)) {} + void Audio::bgmPlay(const char *filename, int volume, int pitch, float pos){ p->current_bgm_volume = volume; p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos); @@ -244,6 +245,7 @@ void Audio::bgmFade(int time){ p->bgm.fadeOut(time); } + void Audio::bgsPlay(const char *filename, int volume, int pitch, float pos){ p->current_bgs_volume = volume; p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos); @@ -257,6 +259,7 @@ void Audio::bgsFade(int time){ p->bgs.fadeOut(time); } + void Audio::mePlay(const char *filename, int volume, int pitch){ p->current_me_volume = volume; p->me.play(filename, (volume*p->bgm_volume)/100, pitch); @@ -270,6 +273,7 @@ void Audio::meFade(int time){ p->me.fadeOut(time); } + void Audio::sePlay(const char *filename, int volume, int pitch){ p->se.play(filename, (volume*p->sfx_volume)/100, pitch); } diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 9fff340..32b7299 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -48,7 +48,7 @@ #define GUARD_MEGA \ { \ if (p->megaSurface) \ - crash(Exception::MKXPError, true, "Operation not supported for mega surfaces"); \ + crash("Operation not supported for mega surfaces", Exception::MKXPError, true); \ } #define OUTLINE_SIZE 1 @@ -222,11 +222,13 @@ 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, true, "Error loading image '%s': %s", filename, SDL_GetError()); + snprintf(msg, sizeof msg, "Error loading image '%s': %s", filename, SDL_GetError()); + throw Exception(Exception::SDLError, msg); } p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888); @@ -262,7 +264,8 @@ Bitmap::Bitmap(const char *filename){ Bitmap::Bitmap(int width, int height){ if (width <= 0 || height <= 0){ - crash(Exception::RGSSError, true, "failed to create bitmap"); + //rash("failed to create bitmap"); + throw Exception(Exception::RGSSError, "failed to create bitmap"); } TEXFBO tex = shState->texPool().request(width, height); @@ -1047,7 +1050,8 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align){ GLMeta::blitBegin(p->gl); GLMeta::blitSource(gpTF); - GLMeta::blitRectangle(IntRect(0, 0, txtSurf->w, txtSurf->h), posRect, true); + GLMeta::blitRectangle(IntRect(0, 0, txtSurf->w, txtSurf->h), + posRect, true); GLMeta::blitEnd(); } } diff --git a/src/config.cpp b/src/config.cpp index 91f701d..42df465 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -35,8 +35,6 @@ #include "util.h" #include "sdl-util.h" -#define CONF_FILE "oneshot.conf" - namespace std{ std::ostream& operator<<(std::ostream &os, const std::vector &vec){ for (auto item : vec){ @@ -63,6 +61,8 @@ std::set setFromVec(const std::vector &vec){ typedef std::vector StringVec; namespace po = boost::program_options; +#define CONF_FILE "oneshot.conf" + Config::Config() {} diff --git a/src/disposable.h b/src/disposable.h index 5fa338f..ad63f03 100644 --- a/src/disposable.h +++ b/src/disposable.h @@ -26,14 +26,13 @@ #include "exception.h" #include "sharedstate.h" #include "graphics.h" -#include "meow.h" #include #include +// #include #include - - +// #include class Disposable{ public: @@ -66,7 +65,7 @@ public: protected: void guardDisposed() const{ if (isDisposed()) - crash(Exception::RGSSError, true, "disposed %s", klassName()); + throw Exception(Exception::RGSSError, "disposed %s", klassName()); } private: diff --git a/src/etc.cpp b/src/etc.cpp index 93ae6a7..ba62cfe 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -24,6 +24,9 @@ #include "serial-util.h" #include "exception.h" #include "meow.h" + +// this file doesn't exist, idk what to do if it, so i'll comment it. +// #include #include Color::Color(double red, double green, double blue, double alpha) @@ -101,7 +104,7 @@ void Color::serialize(char *buffer) const{ Color *Color::deserialize(const char *data, int len){ if (len != 32) - crash(Exception::ArgumentError, true, "Color: Serialized data invalid"); + crash("Color: Serialized data invalid", Exception::ArgumentError, true); Color *c = new Color(); @@ -220,7 +223,7 @@ void Tone::serialize(char *buffer) const{ Tone *Tone::deserialize(const char *data, int len){ if (len != 32) - crash(Exception::ArgumentError, true, "Tone: Serialized data invalid"); + crash("Tone: Serialized data invalid", Exception::ArgumentError, true); Tone *t = new Tone(); @@ -351,7 +354,7 @@ void Rect::serialize(char *buffer) const{ Rect *Rect::deserialize(const char *data, int len){ if (len != 16) - crash(Exception::ArgumentError, true, "Rect: Serialized data invalid"); + crash("Rect: Serialized data invalid", Exception::ArgumentError, true); Rect *r = new Rect(); diff --git a/src/font.cpp b/src/font.cpp index 9e99651..894bc5e 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -128,7 +128,7 @@ TTF_Font *SharedFontState::getFont(std::string family, int size){ SDL_IOStream *ops; if (family.empty()){ - crash(Exception::RGSSError, true, "font does not exist"); + crash("font does not exist", Exception::RGSSError, true); }else{ /* Use 'other' path as alternative in case * we have no 'regular' styled font asset */ @@ -142,8 +142,10 @@ TTF_Font *SharedFontState::getFont(std::string family, int size){ font = TTF_OpenFontIO(ops, 1, size); - if (!font) - crash(Exception::SDLError, true, "%s", SDL_GetError()); + if (!font){ + snprintf(msg, sizeof msg, "%s", SDL_GetError()); + crash(msg, Exception::SDLError, true); + } p->pool.insert(key, font); return font; @@ -159,7 +161,10 @@ bool SharedFontState::fontPresent(std::string family) const{ return !(set.regular.empty() && set.other.empty()); } -void pickExistingFontName(const std::vector &names, std::string &out, const SharedFontState &sfs) { +void pickExistingFontName(const std::vector &names, + std::string &out, + const SharedFontState &sfs) +{ /* Note: In RMXP, a names array with no existing entry * results in no text being drawn at all (same for "" and []); * we can't replicate this in mkxp due to the default substitute. */ diff --git a/src/input.cpp b/src/input.cpp index 8c240f6..6a8bd3d 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -646,8 +646,10 @@ void Input::update(){ p->repeatCount++; bool repeated; - - repeated = p->repeatCount >= 15 && ((p->repeatCount+1) % 4) == 0; + if (rgssVer >= 2) + repeated = p->repeatCount >= 23 && ((p->repeatCount+1) % 6) == 0; + else + repeated = p->repeatCount >= 15 && ((p->repeatCount+1) % 4) == 0; p->getState(p->repeating).repeated |= repeated; diff --git a/src/main.cpp b/src/main.cpp index 860330e..e999e1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,7 +88,8 @@ int rgssThreadFun(void *userdata){ glCtx = SDL_GL_CreateContext(win); if (!glCtx){ - crash(Exception::MEOW, false, "Error creating context: %s", SDL_GetError()); + SDL_snprintf(msg, sizeof msg, "Error creating context: %s", SDL_GetError()); + crash(msg, Exception::MEOW, false); rgssThreadError(threadData, std::string(msg)); return 0; } @@ -97,7 +98,7 @@ int rgssThreadFun(void *userdata){ initGLFunctions(); } catch (const Exception &exc){ - crash(Exception::MEOW, false, exc.msg.c_str()); + crash(exc.msg.c_str(), Exception::MEOW, false); rgssThreadError(threadData, exc.msg); SDL_GL_DestroyContext(glCtx); return 0; @@ -126,7 +127,7 @@ int rgssThreadFun(void *userdata){ ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0); if (!alcCtx){ - crash(Exception::MEOW, false, "Error creating OpenAL context"); + crash("Error creating OpenAL context", Exception::MEOW, false); rgssThreadError(threadData, "Error creating OpenAL context"); SDL_GL_DestroyContext(glCtx); return 0; @@ -137,7 +138,7 @@ int rgssThreadFun(void *userdata){ try{ SharedState::initInstance(threadData); }catch (const Exception &exc){ - crash(Exception::MEOW, false, exc.msg.c_str()); + crash(exc.msg.c_str(), Exception::MEOW, false); rgssThreadError(threadData, exc.msg); alcDestroyContext(alcCtx); SDL_GL_DestroyContext(glCtx); @@ -189,7 +190,7 @@ static void setGamePathInRegistry() { long keyCreateError = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\OneShot\\"), 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL); if (keyCreateError != ERROR_SUCCESS){ - crash(Exception::MEOW, false, "Unable to create key in registry"); + crash("Unable to create key in registry", Exception::MEOW, false); } else { keyOpenError = ERROR_SUCCESS; @@ -197,12 +198,12 @@ static void setGamePathInRegistry() { } if (keyOpenError != ERROR_SUCCESS){ - crash(Exception::MEOW, false, "Unable to open registry."); + crash("Unable to open registry.", Exception::MEOW, false); } else { DWORD dataSize = (strlen(dataDir) + 1) * sizeof(char); if (RegSetValueEx(key, TEXT("GameDirectory"), 0, REG_SZ, (LPBYTE)dataDir, dataSize) != ERROR_SUCCESS){ - crash(Exception::MEOW, false, "Unable to set GameDirectory registry value"); + crash("Unable to set GameDirectory registry value", Exception::MEOW, false); } RegCloseKey(key); } @@ -229,19 +230,20 @@ int main(int argc, char *argv[]){ /* initialize SDL first */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){ - crash(Exception::MEOW, false, "Error initializing SDL: %s", SDL_GetError()); + SDL_snprintf(msg, sizeof msg, "Error initializing SDL: %s", SDL_GetError()); + crash(msg, Exception::MEOW, false); return 0; } #ifdef STEAM if (!STEAMSHIM_init()){ - crash(Exception::MEOW, false, "Could not initialize Steamworks API"); + crash("Could not initialize Steamworks API", Exception::MEOW, false); return 0; } #endif if (!EventThread::allocUserEvents()){ - crash(Exception::MEOW, false, "Error allocating SDL user events"); + crash("Error allocating SDL user events", Exception::MEOW, false); return 0; } @@ -274,7 +276,8 @@ int main(int argc, char *argv[]){ if (!conf.gameFolder.empty()){ if (chdir(conf.gameFolder.c_str()) != 0){ - crash(Exception::MEOW, false, "Unable to switch into gameFolder %s", conf.gameFolder); + SDL_snprintf(msg, sizeof msg, "Unable to switch into gameFolder %s", conf.gameFolder); + crash(msg, Exception::MEOW, false); return 0; } } @@ -287,12 +290,14 @@ int main(int argc, char *argv[]){ conf.windowTitle = conf.game.title; if (TTF_Init() == false){ - crash(Exception::MEOW, false, "Error initializing SDL_ttf: %s", SDL_GetError()); + SDL_snprintf(msg, sizeof msg, "Error initializing SDL_ttf: %s", SDL_GetError()); + crash(msg, Exception::MEOW, false); SDL_Quit(); } if (Sound_Init() == false){ - crash(Exception::MEOW, false, "Error initializing SDL_sound: %s", Sound_GetError()); + SDL_snprintf(msg, sizeof msg, "Error initializing SDL_sound: %s", Sound_GetError()); + crash(msg, Exception::MEOW, false); TTF_Quit(); SDL_Quit(); @@ -311,7 +316,8 @@ int main(int argc, char *argv[]){ SDL_SetWindowFullscreen(win, true); if (!win){ - crash(Exception::MEOW, false, "Error creating window: %s", SDL_GetError()); + SDL_snprintf(msg, sizeof msg, "Error creating window: %s", SDL_GetError()); + crash(msg, Exception::MEOW, false); return 0; } @@ -327,7 +333,7 @@ int main(int argc, char *argv[]){ if (!alcDev){ SDL_DestroyWindow(win); - crash(Exception::MEOW, false, "Error opening OpenAL device"); + crash("Error opening OpenAL device", Exception::MEOW, false); TTF_Quit(); SDL_Quit(); @@ -384,7 +390,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, false, rtData.rgssErrorMsg.c_str()); + crash(rtData.rgssErrorMsg.c_str(), Exception::MEOW, false); /* Clean up any remainin events */ eventThread.cleanup(); diff --git a/src/meow.cpp b/src/meow.cpp index 9b14158..cea695b 100644 --- a/src/meow.cpp +++ b/src/meow.cpp @@ -17,15 +17,12 @@ #include #include #include -#include #include +#include #include #include #include #include -#include -#include -#include #ifdef __LINUX__ #include @@ -41,23 +38,9 @@ static inline const char* glGetStringInt(GLenum name){ return (const char*) gl.GetString(name); } -void crash(Exception::Type t, bool do_exp, const char *fmt, ...){ - va_list ap; - va_start(ap, fmt); - va_list ap2; - va_copy(ap2, ap); - unsigned short len = vsnprintf(NULL, 0, fmt, ap2); - va_end(ap2); - - char *buf = (char*)malloc(len + 1); - if (!buf) - va_end(ap); - - vsnprintf(buf, len + 1, fmt, ap); - va_end(ap); - - char msg[256 + len]; - 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.", buf); +void crash(const char* reason, Exception::Type t, bool do_exp){ + char msg[1024]; + SDL_snprintf(msg, sizeof msg, "Error occured! Error message: %s\n\n Want to create a crash log? You can share the crash log with the developers and help resolve the issue.", reason); SDL_MessageBoxData messageboxdata = { .flags = SDL_MESSAGEBOX_ERROR, .window = NULL, @@ -71,7 +54,7 @@ void crash(Exception::Type t, bool do_exp, const char *fmt, ...){ int buttonid = 0; if (SDL_ShowMessageBox(&messageboxdata, &buttonid) == false) { - printf("[CRASHDUMP] %s\n", buf); + printf("[CRASHDUMP] %s\n", reason); } if(buttonid == 1){ @@ -127,7 +110,3 @@ void crash(Exception::Type t, bool do_exp, const char *fmt, ...){ throw Exception(t, msg); } } - -void ShowError(const char* m){ - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Sunshine Error", m, NULL); -} diff --git a/src/meow.h b/src/meow.h index 2178efd..897e512 100644 --- a/src/meow.h +++ b/src/meow.h @@ -1,3 +1,2 @@ #include "exception.h" -void crash(Exception::Type t, bool do_exp, const char *fmt, ...); -void ShowError(const char* m); +void crash(const char* reason, Exception::Type t, bool do_exp); diff --git a/src/scene.cpp b/src/scene.cpp index a1b61aa..90cd03e 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -148,6 +148,14 @@ bool SceneElement::operator<(const SceneElement &o) const{ if (z <= o.z){ if (z == o.z){ + if (rgssVer >= 2){ + /* RGSS2: If two sprites' Z values collide, + * their Y coordinates decide draw order. Only + * on equal Y does the creation time take effect */ + if (spriteY != o.spriteY) + return (spriteY < o.spriteY); + } + return (creationStamp < o.creationStamp); } diff --git a/src/screen.cpp b/src/screen.cpp index 4e1e125..6c8d959 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -34,7 +34,8 @@ 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, false, "Error creating window: %s", SDL_GetError()); + snprintf(msg, sizeof msg, "Error creating window: %s", SDL_GetError()); + crash(msg, Exception::MEOW, false); return 0; } diff --git a/src/sdlsoundsource.cpp b/src/sdlsoundsource.cpp index cc228d9..28c6eba 100644 --- a/src/sdlsoundsource.cpp +++ b/src/sdlsoundsource.cpp @@ -45,8 +45,9 @@ struct SDLSoundSource : ALDataSource{ sample = Sound_NewSample(&srcOps, extension, 0, maxBufSize); if (!sample){ - SDL_CloseIO(&ops); - crash(Exception::SDLError, true, "SDL_sound: %s", Sound_GetError()); + SDL_CloseIO(&ops); + snprintf(msg, sizeof msg, "SDL_sound: %s", Sound_GetError()); + crash(msg, Exception::SDLError, true); } sampleSize = formatSampleSize(sample->actual.format); diff --git a/src/shader.cpp b/src/shader.cpp index 6a4f2ea..177ef64 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -152,7 +152,8 @@ void Shader::init(const unsigned char *vert, int vertSize, const unsigned char * if (!success){ printShaderLog(vertShader); - crash(Exception::MKXPError , true, "GLSL: An error occured while compiling vertex shader '%s' in program '%s'", vertName, programName); + snprintf(msg, sizeof msg, "GLSL: An error occured while compiling vertex shader '%s' in program '%s'", vertName, programName); + crash(msg, Exception::MKXPError ,true); } /* Compile fragment shader */ @@ -163,7 +164,8 @@ void Shader::init(const unsigned char *vert, int vertSize, const unsigned char * if (!success){ printShaderLog(fragShader); - crash(Exception::MKXPError, true, "GLSL: An error occured while compiling fragment shader '%s' in program '%s'", fragName, programName); + snprintf(msg, sizeof msg, "GLSL: An error occured while compiling fragment shader '%s' in program '%s'", fragName, programName); + crash(msg, Exception::MKXPError, true); } /* Link shader program */ @@ -180,7 +182,8 @@ void Shader::init(const unsigned char *vert, int vertSize, const unsigned char * if (!success){ printProgramLog(program); - crash(Exception::MKXPError, true, "GLSL: An error occured while linking program '%s' (vertex '%s', fragment '%s')", programName, vertName, fragName); + snprintf(msg, sizeof msg, "GLSL: An error occured while linking program '%s' (vertex '%s', fragment '%s')", programName, vertName, fragName); + crash(msg, Exception::MKXPError, true); } } @@ -375,6 +378,7 @@ void SimpleTransShader::setProg(float value){ gl.Uniform1f(u_prog, value); } + void SpriteShaderBase::SpriteShaderInit(){ ShaderBase::init(); @@ -461,6 +465,7 @@ void PlaneShader::setOpacity(float value){ gl.Uniform1f(u_opacity, value); } + GrayShader::GrayShader(){ INIT_SHADER(simple, gray, GrayShader); @@ -473,6 +478,7 @@ void GrayShader::setGray(float value){ gl.Uniform1f(u_gray, value); } + TilemapShader::TilemapShader(){ INIT_SHADER(tilemap, simple, TilemapShader); @@ -485,6 +491,7 @@ void TilemapShader::setAniIndex(int value){ gl.Uniform1f(u_aniIndex, value); } + TilemapWaterShader::TilemapWaterShader(){ INIT_SHADER(tilemap, tilemapWater, TilemapWaterShader); @@ -502,6 +509,8 @@ void TilemapWaterShader::setOffset(const Vec2i &value){ gl.Uniform2f(u_offset, value.x, value.y); } + + FlashMapShader::FlashMapShader(){ INIT_SHADER(simpleColor, flashMap, FlashMapShader); diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp index 29df061..f46a802 100644 --- a/src/soundemitter.cpp +++ b/src/soundemitter.cpp @@ -206,6 +206,7 @@ struct SoundOpenHandler : FileSystem::OpenHandler{ }; SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){ + char msg[512]; SoundBuffer *buffer = bufferHash.value(filename, 0); if (buffer){ @@ -223,7 +224,8 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){ if (!buffer){ char buf[512]; - crash(Exception::MEOW, false, "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError()); + snprintf(buf, sizeof(buf), "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError()); + crash(msg, Exception::MEOW, false); return 0; } diff --git a/src/sprite.cpp b/src/sprite.cpp index 7e345a4..d3cd7f2 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -360,6 +360,11 @@ void Sprite::setY(int value){ return; p->trans.setPosition(Vec2(getX(), value)); + + if (rgssVer >= 2){ + p->wave.dirty = true; + setSpriteY(value); + } } void Sprite::setOX(int value){ @@ -397,6 +402,9 @@ void Sprite::setZoomY(float value){ p->trans.setScale(Vec2(getZoomX(), value)); p->recomputeBushDepth(); + + if (rgssVer >= 2) + p->wave.dirty = true; } void Sprite::setAngle(float value){ @@ -620,4 +628,4 @@ void Sprite::defaultSpriteShaderInit(SpriteShaderBase &shader){ shader.setColor(*blend); shader.setModulate(p->modulate->norm); -} +} \ No newline at end of file diff --git a/src/table.cpp b/src/table.cpp index 908f249..9f1e6c9 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, true, "Marshal: Table: bad file format"); + crash("Marshal: Table: bad file format", Exception::RGSSError, true); 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, true, "Marshal: Table: bad file format"); + crash("Marshal: Table: bad file format", Exception::RGSSError, true); if (len != 20 + x*y*z*2) - crash(Exception::RGSSError, true, "Marshal: Table: bad file format"); + crash("Marshal: Table: bad file format", Exception::RGSSError, true); Table *t = new Table(x, y, z); memcpy(dataPtr(t->data), data, sizeof(int16_t)*size); diff --git a/src/texpool.cpp b/src/texpool.cpp index 137a3f8..e4f9ea9 100644 --- a/src/texpool.cpp +++ b/src/texpool.cpp @@ -97,6 +97,7 @@ TexPool::~TexPool(){ TEXFBO TexPool::request(int width, int height){ CacheNode cnode; Size size(width, height); + char msg[512]; /* See if we can statisfy request from cache */ CNodeList &bucket = p->poolHash[size]; @@ -117,7 +118,8 @@ TEXFBO TexPool::request(int width, int height){ int maxSize = glState.caps.maxTexSize; if (width > maxSize || height > maxSize){ - crash(Exception::MKXPError, true, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height); + snprintf(msg, sizeof msg, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height); + crash(msg, Exception::MKXPError, true); } /* Nope, create it instead */ diff --git a/src/tilemap.cpp b/src/tilemap.cpp index 47c949e..6d56430 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -357,7 +357,8 @@ struct TilemapPrivate { for (size_t i = 0; i < zlayersMax; ++i) elem.zlayers[i] = new ZLayer(this, viewport); - prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &TilemapPrivate::prepare)); + prepareCon = shState->prepareDraw.connect + (sigc::mem_fun(this, &TilemapPrivate::prepare)); updateFlashMapViewport(); } @@ -402,7 +403,7 @@ struct TilemapPrivate { atlas.size = TileAtlas::minSize(atlas.efTilesetH, glState.caps.maxTexSize); if (atlas.size.x < 0) - crash(Exception::MKXPError, true, "Cannot allocate big enough texture for tileset atlas"); + throw Exception(Exception::MKXPError, "Cannot allocate big enough texture for tileset atlas"); } void updateAutotileInfo(){ @@ -498,11 +499,13 @@ struct TilemapPrivate { if (blitW <= autotileW && tiles.animated){ /* Static autotile */ for (int j = 0; j < 4; ++j) - GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH), Vec2i(autotileW*j, atInd*autotileH)); + GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH), + Vec2i(autotileW*j, atInd*autotileH)); } else{ /* Animated autotile */ - GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH), Vec2i(0, atInd*autotileH)); + GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH), + Vec2i(0, atInd*autotileH)); } } @@ -532,7 +535,8 @@ struct TilemapPrivate { Vec2i texSize; shState->ensureTexSize(tsLaneW, blitOp.h, texSize); shState->bindTex(); - GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y, 0, 0, tsLaneW, blitOp.h, tsSurf, GL_RGBA); + GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y, + 0, 0, tsLaneW, blitOp.h, tsSurf, GL_RGBA); shader.setTexSize(texSize); quad.setTexRect(FloatRect(0, 0, tsLaneW, blitOp.h)); @@ -552,7 +556,8 @@ struct TilemapPrivate { for (size_t i = 0; i < blits.size(); ++i){ const TileAtlas::Blit &blitOp = blits[i]; - GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y, blitOp.dst.x, blitOp.dst.y, tsLaneW, blitOp.h, tsSurf, GL_RGBA); + GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y, + blitOp.dst.x, blitOp.dst.y, tsLaneW, blitOp.h, tsSurf, GL_RGBA); } GLMeta::subRectImageEnd(); @@ -567,7 +572,8 @@ struct TilemapPrivate { for (size_t i = 0; i < blits.size(); ++i){ const TileAtlas::Blit &blitOp = blits[i]; - GLMeta::blitRectangle(IntRect(blitOp.src.x, blitOp.src.y, tsLaneW, blitOp.h), blitOp.dst); + GLMeta::blitRectangle(IntRect(blitOp.src.x, blitOp.src.y, tsLaneW, blitOp.h), + blitOp.dst); } GLMeta::blitEnd(); @@ -1112,7 +1118,8 @@ void Tilemap::setMapData(Table *value){ p->invalidateBuffers(); p->mapDataCon.disconnect(); - p->mapDataCon = value->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers)); + p->mapDataCon = value->modified.connect + (sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers)); } void Tilemap::setFlashData(Table *value){ @@ -1134,7 +1141,8 @@ void Tilemap::setPriorities(Table *value){ p->invalidateBuffers(); p->prioritiesCon.disconnect(); - p->prioritiesCon = value->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers)); + p->prioritiesCon = value->modified.connect + (sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers)); } void Tilemap::setVisible(bool value){ diff --git a/src/tilequad.h b/src/tilequad.h index b35b7d2..da40ae4 100644 --- a/src/tilequad.h +++ b/src/tilequad.h @@ -35,15 +35,23 @@ namespace TileQuads{ /* Calculate needed quad counts */ - int oneDimCount(int tileDimension, int destDimension); - int twoDimCount(int tileW, int tileH, int destW, int destH); + int oneDimCount(int tileDimension, + int destDimension); + int twoDimCount(int tileW, int tileH, + int destW, int destH); /* Build tiling quads */ - int buildH(const IntRect &sourceRect, int width, int x, int y, Vertex *verts); + int buildH(const IntRect &sourceRect, + int width, int x, int y, + Vertex *verts); - int buildV(const IntRect &sourceRect, int height, int ox, int oy, Vertex *verts); + int buildV(const IntRect &sourceRect, + int height, int ox, int oy, + Vertex *verts); - int build(const IntRect &sourceRect, const IntRect &destRect, Vertex *verts); + int build(const IntRect &sourceRect, + const IntRect &destRect, + Vertex *verts); /* Build a quad "frame" (see Window cursor_rect) */ int buildFrame(const IntRect &rect, Vertex vert[36]); diff --git a/src/vorbissource.cpp b/src/vorbissource.cpp index a603e65..59af03b 100644 --- a/src/vorbissource.cpp +++ b/src/vorbissource.cpp @@ -80,7 +80,7 @@ struct VorbisSource : ALDataSource{ if (error){ SDL_CloseIO(&src); - crash(Exception::MKXPError, true, "Vorbisfile: Cannot read ogg file"); + crash("Vorbisfile: Cannot read ogg file", Exception::MKXPError, true); } /* Extract bitstream info */ @@ -90,7 +90,7 @@ struct VorbisSource : ALDataSource{ if (info.channels > 2){ ov_clear(&vf); SDL_CloseIO(&src); - crash(Exception::MKXPError, true, "Cannot handle audio with more than 2 channels"); + crash("Cannot handle audio with more than 2 channels", Exception::MKXPError, true); } info.alFormat = chooseALFormat(sizeof(int16_t), info.channels);