Revert "Meow"

This reverts commit c5589bff11.
This commit is contained in:
Issac332 2026-05-31 20:37:15 +03:00
parent 1e47bce1c4
commit 5b18134bf0
31 changed files with 205 additions and 114 deletions

View file

@ -32,6 +32,9 @@
int volume = 100; \
int pitch = 100; \
double pos = 0.0; \
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; \

View file

@ -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<std::string, std::string> 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;

View file

@ -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;

View file

@ -238,7 +238,14 @@ RB_METHOD(bitmapDrawText){
VALUE rectObj;
Rect *rect;
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<Rect>(rectObj, RectType);
@ -246,7 +253,14 @@ RB_METHOD(bitmapDrawText){
}else{
int x, y, width, height;
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;
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<Rect>(rectObj, RectType);
color1 = getPrivateDataCheck<Color>(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<Color>(color1Obj, ColorType);
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);

View file

@ -93,6 +93,8 @@ RB_METHOD(fontInitialize){
f->initDynAttribs();
wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
return self;
@ -113,6 +115,8 @@ RB_METHOD(fontInitializeCopy){
f->initDynAttribs();
wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
return self;

View file

@ -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){

View file

@ -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

View file

@ -27,6 +27,9 @@
DEF_TYPE(Window);
RB_METHOD(windowInitialize){
#ifdef DEBUG
printf("[windowInitialize] Creating window\n");
#endif
Window *w = viewportElementInitialize<Window>(argc, argv, self);
setPrivateData(self, w);

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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();
}
}

View file

@ -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<std::string> &vec){
for (auto item : vec){
@ -63,6 +61,8 @@ std::set<T> setFromVec(const std::vector<T> &vec){
typedef std::vector<std::string> StringVec;
namespace po = boost::program_options;
#define CONF_FILE "oneshot.conf"
Config::Config()
{}

View file

@ -26,14 +26,13 @@
#include "exception.h"
#include "sharedstate.h"
#include "graphics.h"
#include "meow.h"
#include <assert.h>
#include <sigc++/signal.h>
// #include <sigc++2.0/sigc++/signal.h>
#include <sigc++/connection.h>
// #include <sigc++2.0/sigc++/connection.h>
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:

View file

@ -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 <SDL3/SDL_types.h>
#include <SDL3/SDL_pixels.h>
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();

View file

@ -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<std::string> &names, std::string &out, const SharedFontState &sfs) {
void pickExistingFontName(const std::vector<std::string> &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. */

View file

@ -646,7 +646,9 @@ void Input::update(){
p->repeatCount++;
bool repeated;
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;

View file

@ -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();

View file

@ -17,15 +17,12 @@
#include <time.h>
#include <fstream>
#include <ruby.h>
#include <zlib.h>
#include <ruby/version.h>
#include <zlib.h>
#include <AL/al.h>
#include <boost/version.hpp>
#include <physfs.h>
#include <pixman.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef __LINUX__
#include <gtk/gtk.h>
@ -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);
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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;
}

View file

@ -46,7 +46,8 @@ struct SDLSoundSource : ALDataSource{
if (!sample){
SDL_CloseIO(&ops);
crash(Exception::SDLError, true, "SDL_sound: %s", Sound_GetError());
snprintf(msg, sizeof msg, "SDL_sound: %s", Sound_GetError());
crash(msg, Exception::SDLError, true);
}
sampleSize = formatSampleSize(sample->actual.format);

View file

@ -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);

View file

@ -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;
}

View file

@ -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){

View file

@ -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);

View file

@ -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 */

View file

@ -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){

View file

@ -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]);

View file

@ -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);