Meow
This commit is contained in:
parent
ea41dfa447
commit
c5589bff11
|
|
@ -32,10 +32,7 @@
|
||||||
int volume = 100; \
|
int volume = 100; \
|
||||||
int pitch = 100; \
|
int pitch = 100; \
|
||||||
double pos = 0.0; \
|
double pos = 0.0; \
|
||||||
if (rgssVer >= 3) \
|
rb_get_args(argc, argv, "z|ii", &filename, &volume, &pitch RB_ARG_END); \
|
||||||
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); ) \
|
GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \
|
||||||
return Qnil; \
|
return Qnil; \
|
||||||
} \
|
} \
|
||||||
|
|
|
||||||
|
|
@ -322,8 +322,7 @@ static void runCustomScript(const std::string &filename){
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
|
|
||||||
if (!readFileSDL(filename.c_str(), scriptData)){
|
if (!readFileSDL(filename.c_str(), scriptData)){
|
||||||
snprintf(msg, sizeof msg, "Unable to open %s", filename);
|
crash(Exception::MEOW, false, "Unable to open %s", filename);
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -337,16 +336,14 @@ struct BacktraceData{
|
||||||
BoostHash<std::string, std::string> scriptNames;
|
BoostHash<std::string, std::string> scriptNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld")
|
#define SCRIPT_SECTION_FMT ("Section%03ld")
|
||||||
|
|
||||||
static void runRMXPScripts(BacktraceData &btData){
|
static void runRMXPScripts(BacktraceData &btData){
|
||||||
const Config &conf = shState->rtData().config;
|
const Config &conf = shState->rtData().config;
|
||||||
const std::string &scriptPack = conf.game.scripts;
|
const std::string &scriptPack = conf.game.scripts;
|
||||||
char msg[1024];
|
|
||||||
|
|
||||||
if (!shState->fileSystem().exists(scriptPack.c_str())){
|
if (!shState->fileSystem().exists(scriptPack.c_str())){
|
||||||
snprintf(msg, sizeof msg, "Unable to open '%s'", scriptPack.c_str());
|
crash(Exception::MEOW, false, "Unable to open '%s'", scriptPack.c_str());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,13 +354,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){
|
||||||
snprintf(msg, sizeof msg, "Failed to read script data: %s", e.msg);
|
crash(Exception::MEOW, false, "Failed to read script data: %s", e.msg);
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
|
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
|
||||||
crash("Failed to read script data", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Failed to read script data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,8 +402,7 @@ static void runRMXPScripts(BacktraceData &btData){
|
||||||
|
|
||||||
if (result != Z_OK){
|
if (result != Z_OK){
|
||||||
static char buffer[256];
|
static char buffer[256];
|
||||||
snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName));
|
crash(Exception::MEOW, false, "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName));
|
||||||
crash(buffer, Exception::MEOW, false);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -504,9 +499,7 @@ static void showExc(VALUE exc, const BacktraceData &btData){
|
||||||
file.resize(strlen(file.c_str()));
|
file.resize(strlen(file.c_str()));
|
||||||
file = btData.scriptNames.value(file, file);
|
file = btData.scriptNames.value(file, file);
|
||||||
|
|
||||||
char ms[640];
|
crash(Exception::MEOW, false, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));
|
||||||
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);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -517,7 +510,7 @@ static void mriBindingExecute(){
|
||||||
//JIT for performance
|
//JIT for performance
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char **argv = 0;
|
char **argv = 0;
|
||||||
char options_argv1[] = "oneshot", options_argv2[] = "-evd", options_argv3[] = "--jit";
|
char options_argv1[] = "oneshot", options_argv2[] = "-ev", options_argv3[] = "--jit";
|
||||||
char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL};
|
char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL};
|
||||||
ruby_sysinit(&argc, &argv);
|
ruby_sysinit(&argc, &argv);
|
||||||
RUBY_INIT_STACK;
|
RUBY_INIT_STACK;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ RbData::RbData(){
|
||||||
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
|
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
|
||||||
|
|
||||||
exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError);
|
exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError);
|
||||||
exc[Reset] = rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException);
|
exc[Reset] = rb_define_class("Reset", rb_eException);
|
||||||
|
|
||||||
exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT"));
|
exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT"));
|
||||||
exc[IOError] = rb_eIOError;
|
exc[IOError] = rb_eIOError;
|
||||||
|
|
|
||||||
|
|
@ -238,14 +238,7 @@ RB_METHOD(bitmapDrawText){
|
||||||
VALUE rectObj;
|
VALUE rectObj;
|
||||||
Rect *rect;
|
Rect *rect;
|
||||||
|
|
||||||
if (rgssVer >= 2){
|
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
|
||||||
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);
|
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||||
|
|
||||||
|
|
@ -253,14 +246,7 @@ RB_METHOD(bitmapDrawText){
|
||||||
}else{
|
}else{
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
if (rgssVer >= 2){
|
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
|
||||||
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); );
|
GUARD_EXC( b->drawText(x, y, width, height, str, align); );
|
||||||
}
|
}
|
||||||
|
|
@ -273,14 +259,7 @@ RB_METHOD(bitmapTextSize){
|
||||||
|
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
if (rgssVer >= 2){
|
rb_get_args(argc, argv, "z", &str RB_ARG_END);
|
||||||
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;
|
IntRect value;
|
||||||
GUARD_EXC( value = b->textSize(str); );
|
GUARD_EXC( value = b->textSize(str); );
|
||||||
|
|
@ -303,8 +282,7 @@ RB_METHOD(bitmapGradientFillRect){
|
||||||
VALUE rectObj;
|
VALUE rectObj;
|
||||||
Rect *rect;
|
Rect *rect;
|
||||||
|
|
||||||
rb_get_args(argc, argv, "ooo|b", &rectObj,
|
rb_get_args(argc, argv, "ooo|b", &rectObj, &color1Obj, &color2Obj, &vertical RB_ARG_END);
|
||||||
&color1Obj, &color2Obj, &vertical RB_ARG_END);
|
|
||||||
|
|
||||||
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||||
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
|
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
|
||||||
|
|
@ -314,8 +292,7 @@ RB_METHOD(bitmapGradientFillRect){
|
||||||
}else{
|
}else{
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height,
|
rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height, &color1Obj, &color2Obj, &vertical RB_ARG_END);
|
||||||
&color1Obj, &color2Obj, &vertical RB_ARG_END);
|
|
||||||
|
|
||||||
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
|
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
|
||||||
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);
|
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,7 @@ RB_METHOD(fontInitialize){
|
||||||
f->initDynAttribs();
|
f->initDynAttribs();
|
||||||
|
|
||||||
wrapProperty(self, &f->getColor(), "color", ColorType);
|
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;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
@ -115,9 +113,7 @@ RB_METHOD(fontInitializeCopy){
|
||||||
f->initDynAttribs();
|
f->initDynAttribs();
|
||||||
|
|
||||||
wrapProperty(self, &f->getColor(), "color", ColorType);
|
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;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ DEF_TYPE(Viewport);
|
||||||
RB_METHOD(viewportInitialize){
|
RB_METHOD(viewportInitialize){
|
||||||
Viewport *v;
|
Viewport *v;
|
||||||
|
|
||||||
if (argc == 0 && rgssVer >= 3){
|
if (argc == 0){
|
||||||
v = new Viewport();
|
v = new Viewport();
|
||||||
}
|
}
|
||||||
else if (argc == 1){
|
else if (argc == 1){
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,8 @@
|
||||||
desktop = "kde_error";
|
desktop = "kde_error";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fallbackPath = std::string(getenv("HOME")) + "/Desktop/ONESHOT_hint.png";
|
//not all linux enviroment show dekstop icons + need translation support
|
||||||
|
fallbackPath = std::string(getenv("HOME")) + "/ONESHOT_hint.png";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,6 @@
|
||||||
DEF_TYPE(Window);
|
DEF_TYPE(Window);
|
||||||
|
|
||||||
RB_METHOD(windowInitialize){
|
RB_METHOD(windowInitialize){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[windowInitialize] Creating window\n");
|
|
||||||
#endif
|
|
||||||
Window *w = viewportElementInitialize<Window>(argc, argv, self);
|
Window *w = viewportElementInitialize<Window>(argc, argv, self);
|
||||||
|
|
||||||
setPrivateData(self, w);
|
setPrivateData(self, w);
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,7 @@ inline uint8_t formatSampleSize(int sdlFormat){
|
||||||
case SDL_AUDIO_S16BE :
|
case SDL_AUDIO_S16BE :
|
||||||
return 2;
|
return 2;
|
||||||
default :
|
default :
|
||||||
crash("Unhandled sample format", Exception::MEOW, false);
|
crash(Exception::MEOW, true, "Unhandled sample format");
|
||||||
assert(!"Unhandled sample format");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -197,8 +196,7 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount){
|
||||||
case 2 : return AL_FORMAT_STEREO16;
|
case 2 : return AL_FORMAT_STEREO16;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
crash("Unhandled sample size / channel count", Exception::MEOW, false);
|
crash(Exception::SDLError, true, "Unhandled sample size / channel count");
|
||||||
assert(!"Unhandled sample size / channel count");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -231,9 +231,7 @@ void ALStream::openSource(const std::string &filename){
|
||||||
needsRewind.clear();
|
needsRewind.clear();
|
||||||
|
|
||||||
if (!source){
|
if (!source){
|
||||||
char buf[512];
|
crash(Exception::MEOW, false, "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str());
|
||||||
snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str());
|
|
||||||
crash(buf, Exception::MEOW, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,6 @@ Audio::Audio(RGSSThreadData &rtData)
|
||||||
: p(new AudioPrivate(rtData))
|
: p(new AudioPrivate(rtData))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void Audio::bgmPlay(const char *filename, int volume, int pitch, float pos){
|
void Audio::bgmPlay(const char *filename, int volume, int pitch, float pos){
|
||||||
p->current_bgm_volume = volume;
|
p->current_bgm_volume = volume;
|
||||||
p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos);
|
p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos);
|
||||||
|
|
@ -245,7 +244,6 @@ void Audio::bgmFade(int time){
|
||||||
p->bgm.fadeOut(time);
|
p->bgm.fadeOut(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Audio::bgsPlay(const char *filename, int volume, int pitch, float pos){
|
void Audio::bgsPlay(const char *filename, int volume, int pitch, float pos){
|
||||||
p->current_bgs_volume = volume;
|
p->current_bgs_volume = volume;
|
||||||
p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos);
|
p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos);
|
||||||
|
|
@ -259,7 +257,6 @@ void Audio::bgsFade(int time){
|
||||||
p->bgs.fadeOut(time);
|
p->bgs.fadeOut(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Audio::mePlay(const char *filename, int volume, int pitch){
|
void Audio::mePlay(const char *filename, int volume, int pitch){
|
||||||
p->current_me_volume = volume;
|
p->current_me_volume = volume;
|
||||||
p->me.play(filename, (volume*p->bgm_volume)/100, pitch);
|
p->me.play(filename, (volume*p->bgm_volume)/100, pitch);
|
||||||
|
|
@ -273,7 +270,6 @@ void Audio::meFade(int time){
|
||||||
p->me.fadeOut(time);
|
p->me.fadeOut(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Audio::sePlay(const char *filename, int volume, int pitch){
|
void Audio::sePlay(const char *filename, int volume, int pitch){
|
||||||
p->se.play(filename, (volume*p->sfx_volume)/100, pitch);
|
p->se.play(filename, (volume*p->sfx_volume)/100, pitch);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
#define GUARD_MEGA \
|
#define GUARD_MEGA \
|
||||||
{ \
|
{ \
|
||||||
if (p->megaSurface) \
|
if (p->megaSurface) \
|
||||||
crash("Operation not supported for mega surfaces", Exception::MKXPError, true); \
|
crash(Exception::MKXPError, true, "Operation not supported for mega surfaces"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OUTLINE_SIZE 1
|
#define OUTLINE_SIZE 1
|
||||||
|
|
@ -222,13 +222,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){
|
||||||
snprintf(msg, sizeof msg, "Error loading image '%s': %s", filename, SDL_GetError());
|
crash(Exception::SDLError, true, "Error loading image '%s': %s", filename, SDL_GetError());
|
||||||
throw Exception(Exception::SDLError, msg);
|
|
||||||
}
|
}
|
||||||
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
|
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
|
||||||
|
|
||||||
|
|
@ -264,8 +262,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){
|
||||||
//rash("failed to create bitmap");
|
crash(Exception::RGSSError, true, "failed to create bitmap");
|
||||||
throw Exception(Exception::RGSSError, "failed to create bitmap");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXFBO tex = shState->texPool().request(width, height);
|
TEXFBO tex = shState->texPool().request(width, height);
|
||||||
|
|
@ -1050,8 +1047,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align){
|
||||||
|
|
||||||
GLMeta::blitBegin(p->gl);
|
GLMeta::blitBegin(p->gl);
|
||||||
GLMeta::blitSource(gpTF);
|
GLMeta::blitSource(gpTF);
|
||||||
GLMeta::blitRectangle(IntRect(0, 0, txtSurf->w, txtSurf->h),
|
GLMeta::blitRectangle(IntRect(0, 0, txtSurf->w, txtSurf->h), posRect, true);
|
||||||
posRect, true);
|
|
||||||
GLMeta::blitEnd();
|
GLMeta::blitEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "sdl-util.h"
|
#include "sdl-util.h"
|
||||||
|
|
||||||
|
#define CONF_FILE "oneshot.conf"
|
||||||
|
|
||||||
namespace std{
|
namespace std{
|
||||||
std::ostream& operator<<(std::ostream &os, const std::vector<std::string> &vec){
|
std::ostream& operator<<(std::ostream &os, const std::vector<std::string> &vec){
|
||||||
for (auto item : vec){
|
for (auto item : vec){
|
||||||
|
|
@ -61,8 +63,6 @@ std::set<T> setFromVec(const std::vector<T> &vec){
|
||||||
typedef std::vector<std::string> StringVec;
|
typedef std::vector<std::string> StringVec;
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
#define CONF_FILE "oneshot.conf"
|
|
||||||
|
|
||||||
Config::Config()
|
Config::Config()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,14 @@
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
#include "meow.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <sigc++/signal.h>
|
#include <sigc++/signal.h>
|
||||||
// #include <sigc++2.0/sigc++/signal.h>
|
|
||||||
#include <sigc++/connection.h>
|
#include <sigc++/connection.h>
|
||||||
// #include <sigc++2.0/sigc++/connection.h>
|
|
||||||
|
|
||||||
|
|
||||||
class Disposable{
|
class Disposable{
|
||||||
public:
|
public:
|
||||||
|
|
@ -65,7 +66,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void guardDisposed() const{
|
void guardDisposed() const{
|
||||||
if (isDisposed())
|
if (isDisposed())
|
||||||
throw Exception(Exception::RGSSError, "disposed %s", klassName());
|
crash(Exception::RGSSError, true, "disposed %s", klassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,6 @@
|
||||||
#include "serial-util.h"
|
#include "serial-util.h"
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "meow.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>
|
#include <SDL3/SDL_pixels.h>
|
||||||
|
|
||||||
Color::Color(double red, double green, double blue, double alpha)
|
Color::Color(double red, double green, double blue, double alpha)
|
||||||
|
|
@ -104,7 +101,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("Color: Serialized data invalid", Exception::ArgumentError, true);
|
crash(Exception::ArgumentError, true, "Color: Serialized data invalid");
|
||||||
|
|
||||||
Color *c = new Color();
|
Color *c = new Color();
|
||||||
|
|
||||||
|
|
@ -223,7 +220,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("Tone: Serialized data invalid", Exception::ArgumentError, true);
|
crash(Exception::ArgumentError, true, "Tone: Serialized data invalid");
|
||||||
|
|
||||||
Tone *t = new Tone();
|
Tone *t = new Tone();
|
||||||
|
|
||||||
|
|
@ -354,7 +351,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("Rect: Serialized data invalid", Exception::ArgumentError, true);
|
crash(Exception::ArgumentError, true, "Rect: Serialized data invalid");
|
||||||
|
|
||||||
Rect *r = new Rect();
|
Rect *r = new Rect();
|
||||||
|
|
||||||
|
|
|
||||||
13
src/font.cpp
13
src/font.cpp
|
|
@ -128,7 +128,7 @@ TTF_Font *SharedFontState::getFont(std::string family, int size){
|
||||||
SDL_IOStream *ops;
|
SDL_IOStream *ops;
|
||||||
|
|
||||||
if (family.empty()){
|
if (family.empty()){
|
||||||
crash("font does not exist", Exception::RGSSError, true);
|
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 */
|
||||||
|
|
@ -142,10 +142,8 @@ TTF_Font *SharedFontState::getFont(std::string family, int size){
|
||||||
|
|
||||||
font = TTF_OpenFontIO(ops, 1, size);
|
font = TTF_OpenFontIO(ops, 1, size);
|
||||||
|
|
||||||
if (!font){
|
if (!font)
|
||||||
snprintf(msg, sizeof msg, "%s", SDL_GetError());
|
crash(Exception::SDLError, true, "%s", SDL_GetError());
|
||||||
crash(msg, Exception::SDLError, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
p->pool.insert(key, font);
|
p->pool.insert(key, font);
|
||||||
return font;
|
return font;
|
||||||
|
|
@ -161,10 +159,7 @@ bool SharedFontState::fontPresent(std::string family) const{
|
||||||
return !(set.regular.empty() && set.other.empty());
|
return !(set.regular.empty() && set.other.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void pickExistingFontName(const std::vector<std::string> &names,
|
void pickExistingFontName(const std::vector<std::string> &names, std::string &out, const SharedFontState &sfs) {
|
||||||
std::string &out,
|
|
||||||
const SharedFontState &sfs)
|
|
||||||
{
|
|
||||||
/* Note: In RMXP, a names array with no existing entry
|
/* Note: In RMXP, a names array with no existing entry
|
||||||
* results in no text being drawn at all (same for "" and []);
|
* results in no text being drawn at all (same for "" and []);
|
||||||
* we can't replicate this in mkxp due to the default substitute. */
|
* we can't replicate this in mkxp due to the default substitute. */
|
||||||
|
|
|
||||||
|
|
@ -646,10 +646,8 @@ void Input::update(){
|
||||||
p->repeatCount++;
|
p->repeatCount++;
|
||||||
|
|
||||||
bool repeated;
|
bool repeated;
|
||||||
if (rgssVer >= 2)
|
|
||||||
repeated = p->repeatCount >= 23 && ((p->repeatCount+1) % 6) == 0;
|
repeated = p->repeatCount >= 15 && ((p->repeatCount+1) % 4) == 0;
|
||||||
else
|
|
||||||
repeated = p->repeatCount >= 15 && ((p->repeatCount+1) % 4) == 0;
|
|
||||||
|
|
||||||
p->getState(p->repeating).repeated |= repeated;
|
p->getState(p->repeating).repeated |= repeated;
|
||||||
|
|
||||||
|
|
|
||||||
38
src/main.cpp
38
src/main.cpp
|
|
@ -88,8 +88,7 @@ int rgssThreadFun(void *userdata){
|
||||||
glCtx = SDL_GL_CreateContext(win);
|
glCtx = SDL_GL_CreateContext(win);
|
||||||
|
|
||||||
if (!glCtx){
|
if (!glCtx){
|
||||||
SDL_snprintf(msg, sizeof msg, "Error creating context: %s", SDL_GetError());
|
crash(Exception::MEOW, false, "Error creating context: %s", SDL_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
rgssThreadError(threadData, std::string(msg));
|
rgssThreadError(threadData, std::string(msg));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +97,7 @@ int rgssThreadFun(void *userdata){
|
||||||
initGLFunctions();
|
initGLFunctions();
|
||||||
}
|
}
|
||||||
catch (const Exception &exc){
|
catch (const Exception &exc){
|
||||||
crash(exc.msg.c_str(), Exception::MEOW, false);
|
crash(Exception::MEOW, 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;
|
||||||
|
|
@ -127,7 +126,7 @@ int rgssThreadFun(void *userdata){
|
||||||
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
|
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
|
||||||
|
|
||||||
if (!alcCtx){
|
if (!alcCtx){
|
||||||
crash("Error creating OpenAL context", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "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;
|
||||||
|
|
@ -138,7 +137,7 @@ int rgssThreadFun(void *userdata){
|
||||||
try{
|
try{
|
||||||
SharedState::initInstance(threadData);
|
SharedState::initInstance(threadData);
|
||||||
}catch (const Exception &exc){
|
}catch (const Exception &exc){
|
||||||
crash(exc.msg.c_str(), Exception::MEOW, false);
|
crash(Exception::MEOW, false, exc.msg.c_str());
|
||||||
rgssThreadError(threadData, exc.msg);
|
rgssThreadError(threadData, exc.msg);
|
||||||
alcDestroyContext(alcCtx);
|
alcDestroyContext(alcCtx);
|
||||||
SDL_GL_DestroyContext(glCtx);
|
SDL_GL_DestroyContext(glCtx);
|
||||||
|
|
@ -190,7 +189,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);
|
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){
|
if (keyCreateError != ERROR_SUCCESS){
|
||||||
crash("Unable to create key in registry", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Unable to create key in registry");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
keyOpenError = ERROR_SUCCESS;
|
keyOpenError = ERROR_SUCCESS;
|
||||||
|
|
@ -198,12 +197,12 @@ static void setGamePathInRegistry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyOpenError != ERROR_SUCCESS){
|
if (keyOpenError != ERROR_SUCCESS){
|
||||||
crash("Unable to open registry.", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Unable to open registry.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWORD dataSize = (strlen(dataDir) + 1) * sizeof(char);
|
DWORD dataSize = (strlen(dataDir) + 1) * sizeof(char);
|
||||||
if (RegSetValueEx(key, TEXT("GameDirectory"), 0, REG_SZ, (LPBYTE)dataDir, dataSize) != ERROR_SUCCESS){
|
if (RegSetValueEx(key, TEXT("GameDirectory"), 0, REG_SZ, (LPBYTE)dataDir, dataSize) != ERROR_SUCCESS){
|
||||||
crash("Unable to set GameDirectory registry value", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Unable to set GameDirectory registry value");
|
||||||
}
|
}
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
}
|
}
|
||||||
|
|
@ -230,20 +229,19 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
/* 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){
|
||||||
SDL_snprintf(msg, sizeof msg, "Error initializing SDL: %s", SDL_GetError());
|
crash(Exception::MEOW, false, "Error initializing SDL: %s", SDL_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STEAM
|
#ifdef STEAM
|
||||||
if (!STEAMSHIM_init()){
|
if (!STEAMSHIM_init()){
|
||||||
crash("Could not initialize Steamworks API", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Could not initialize Steamworks API");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!EventThread::allocUserEvents()){
|
if (!EventThread::allocUserEvents()){
|
||||||
crash("Error allocating SDL user events", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Error allocating SDL user events");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,8 +274,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){
|
||||||
SDL_snprintf(msg, sizeof msg, "Unable to switch into gameFolder %s", conf.gameFolder);
|
crash(Exception::MEOW, false, "Unable to switch into gameFolder %s", conf.gameFolder);
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -290,14 +287,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){
|
||||||
SDL_snprintf(msg, sizeof msg, "Error initializing SDL_ttf: %s", SDL_GetError());
|
crash(Exception::MEOW, false, "Error initializing SDL_ttf: %s", SDL_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Sound_Init() == false){
|
if (Sound_Init() == false){
|
||||||
SDL_snprintf(msg, sizeof msg, "Error initializing SDL_sound: %s", Sound_GetError());
|
crash(Exception::MEOW, false, "Error initializing SDL_sound: %s", Sound_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
TTF_Quit();
|
TTF_Quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
|
|
@ -316,8 +311,7 @@ int main(int argc, char *argv[]){
|
||||||
SDL_SetWindowFullscreen(win, true);
|
SDL_SetWindowFullscreen(win, true);
|
||||||
|
|
||||||
if (!win){
|
if (!win){
|
||||||
SDL_snprintf(msg, sizeof msg, "Error creating window: %s", SDL_GetError());
|
crash(Exception::MEOW, false, "Error creating window: %s", SDL_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,7 +327,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
if (!alcDev){
|
if (!alcDev){
|
||||||
SDL_DestroyWindow(win);
|
SDL_DestroyWindow(win);
|
||||||
crash("Error opening OpenAL device", Exception::MEOW, false);
|
crash(Exception::MEOW, false, "Error opening OpenAL device");
|
||||||
TTF_Quit();
|
TTF_Quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
|
|
@ -390,7 +384,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(rtData.rgssErrorMsg.c_str(), Exception::MEOW, false);
|
crash(Exception::MEOW, false, rtData.rgssErrorMsg.c_str());
|
||||||
|
|
||||||
/* Clean up any remainin events */
|
/* Clean up any remainin events */
|
||||||
eventThread.cleanup();
|
eventThread.cleanup();
|
||||||
|
|
|
||||||
31
src/meow.cpp
31
src/meow.cpp
|
|
@ -17,12 +17,15 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
#include <ruby/version.h>
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
#include <ruby/version.h>
|
||||||
#include <AL/al.h>
|
#include <AL/al.h>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <physfs.h>
|
#include <physfs.h>
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
@ -38,9 +41,23 @@ static inline const char* glGetStringInt(GLenum name){
|
||||||
return (const char*) gl.GetString(name);
|
return (const char*) gl.GetString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void crash(const char* reason, Exception::Type t, bool do_exp){
|
void crash(Exception::Type t, bool do_exp, const char *fmt, ...){
|
||||||
char msg[1024];
|
va_list ap;
|
||||||
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);
|
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);
|
||||||
SDL_MessageBoxData messageboxdata = {
|
SDL_MessageBoxData messageboxdata = {
|
||||||
.flags = SDL_MESSAGEBOX_ERROR,
|
.flags = SDL_MESSAGEBOX_ERROR,
|
||||||
.window = NULL,
|
.window = NULL,
|
||||||
|
|
@ -54,7 +71,7 @@ void crash(const char* reason, Exception::Type t, bool do_exp){
|
||||||
|
|
||||||
int buttonid = 0;
|
int buttonid = 0;
|
||||||
if (SDL_ShowMessageBox(&messageboxdata, &buttonid) == false) {
|
if (SDL_ShowMessageBox(&messageboxdata, &buttonid) == false) {
|
||||||
printf("[CRASHDUMP] %s\n", reason);
|
printf("[CRASHDUMP] %s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buttonid == 1){
|
if(buttonid == 1){
|
||||||
|
|
@ -110,3 +127,7 @@ void crash(const char* reason, Exception::Type t, bool do_exp){
|
||||||
throw Exception(t, msg);
|
throw Exception(t, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowError(const char* m){
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Sunshine Error", m, NULL);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
void crash(const char* reason, Exception::Type t, bool do_exp);
|
void crash(Exception::Type t, bool do_exp, const char *fmt, ...);
|
||||||
|
void ShowError(const char* m);
|
||||||
|
|
|
||||||
|
|
@ -148,14 +148,6 @@ bool SceneElement::operator<(const SceneElement &o) const{
|
||||||
|
|
||||||
if (z <= o.z){
|
if (z <= o.z){
|
||||||
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);
|
return (creationStamp < o.creationStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,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){
|
||||||
snprintf(msg, sizeof msg, "Error creating window: %s", SDL_GetError());
|
crash(Exception::MEOW, false, "Error creating window: %s", SDL_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,8 @@ struct SDLSoundSource : ALDataSource{
|
||||||
sample = Sound_NewSample(&srcOps, extension, 0, maxBufSize);
|
sample = Sound_NewSample(&srcOps, extension, 0, maxBufSize);
|
||||||
|
|
||||||
if (!sample){
|
if (!sample){
|
||||||
SDL_CloseIO(&ops);
|
SDL_CloseIO(&ops);
|
||||||
snprintf(msg, sizeof msg, "SDL_sound: %s", Sound_GetError());
|
crash(Exception::SDLError, true, "SDL_sound: %s", Sound_GetError());
|
||||||
crash(msg, Exception::SDLError, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleSize = formatSampleSize(sample->actual.format);
|
sampleSize = formatSampleSize(sample->actual.format);
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,7 @@ void Shader::init(const unsigned char *vert, int vertSize, const unsigned char *
|
||||||
|
|
||||||
if (!success){
|
if (!success){
|
||||||
printShaderLog(vertShader);
|
printShaderLog(vertShader);
|
||||||
snprintf(msg, sizeof msg, "GLSL: An error occured while compiling vertex shader '%s' in program '%s'", vertName, programName);
|
crash(Exception::MKXPError , true, "GLSL: An error occured while compiling vertex shader '%s' in program '%s'", vertName, programName);
|
||||||
crash(msg, Exception::MKXPError ,true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compile fragment shader */
|
/* Compile fragment shader */
|
||||||
|
|
@ -164,8 +163,7 @@ void Shader::init(const unsigned char *vert, int vertSize, const unsigned char *
|
||||||
|
|
||||||
if (!success){
|
if (!success){
|
||||||
printShaderLog(fragShader);
|
printShaderLog(fragShader);
|
||||||
snprintf(msg, sizeof msg, "GLSL: An error occured while compiling fragment shader '%s' in program '%s'", fragName, programName);
|
crash(Exception::MKXPError, true, "GLSL: An error occured while compiling fragment shader '%s' in program '%s'", fragName, programName);
|
||||||
crash(msg, Exception::MKXPError, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Link shader program */
|
/* Link shader program */
|
||||||
|
|
@ -182,8 +180,7 @@ void Shader::init(const unsigned char *vert, int vertSize, const unsigned char *
|
||||||
|
|
||||||
if (!success){
|
if (!success){
|
||||||
printProgramLog(program);
|
printProgramLog(program);
|
||||||
snprintf(msg, sizeof msg, "GLSL: An error occured while linking program '%s' (vertex '%s', fragment '%s')", programName, vertName, fragName);
|
crash(Exception::MKXPError, true, "GLSL: An error occured while linking program '%s' (vertex '%s', fragment '%s')", programName, vertName, fragName);
|
||||||
crash(msg, Exception::MKXPError, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,7 +375,6 @@ void SimpleTransShader::setProg(float value){
|
||||||
gl.Uniform1f(u_prog, value);
|
gl.Uniform1f(u_prog, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SpriteShaderBase::SpriteShaderInit(){
|
void SpriteShaderBase::SpriteShaderInit(){
|
||||||
ShaderBase::init();
|
ShaderBase::init();
|
||||||
|
|
||||||
|
|
@ -465,7 +461,6 @@ void PlaneShader::setOpacity(float value){
|
||||||
gl.Uniform1f(u_opacity, value);
|
gl.Uniform1f(u_opacity, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GrayShader::GrayShader(){
|
GrayShader::GrayShader(){
|
||||||
INIT_SHADER(simple, gray, GrayShader);
|
INIT_SHADER(simple, gray, GrayShader);
|
||||||
|
|
||||||
|
|
@ -478,7 +473,6 @@ void GrayShader::setGray(float value){
|
||||||
gl.Uniform1f(u_gray, value);
|
gl.Uniform1f(u_gray, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TilemapShader::TilemapShader(){
|
TilemapShader::TilemapShader(){
|
||||||
INIT_SHADER(tilemap, simple, TilemapShader);
|
INIT_SHADER(tilemap, simple, TilemapShader);
|
||||||
|
|
||||||
|
|
@ -491,7 +485,6 @@ void TilemapShader::setAniIndex(int value){
|
||||||
gl.Uniform1f(u_aniIndex, value);
|
gl.Uniform1f(u_aniIndex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TilemapWaterShader::TilemapWaterShader(){
|
TilemapWaterShader::TilemapWaterShader(){
|
||||||
INIT_SHADER(tilemap, tilemapWater, TilemapWaterShader);
|
INIT_SHADER(tilemap, tilemapWater, TilemapWaterShader);
|
||||||
|
|
||||||
|
|
@ -509,8 +502,6 @@ void TilemapWaterShader::setOffset(const Vec2i &value){
|
||||||
gl.Uniform2f(u_offset, value.x, value.y);
|
gl.Uniform2f(u_offset, value.x, value.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FlashMapShader::FlashMapShader(){
|
FlashMapShader::FlashMapShader(){
|
||||||
INIT_SHADER(simpleColor, flashMap, FlashMapShader);
|
INIT_SHADER(simpleColor, flashMap, FlashMapShader);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,6 @@ struct SoundOpenHandler : FileSystem::OpenHandler{
|
||||||
};
|
};
|
||||||
|
|
||||||
SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){
|
SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){
|
||||||
char msg[512];
|
|
||||||
SoundBuffer *buffer = bufferHash.value(filename, 0);
|
SoundBuffer *buffer = bufferHash.value(filename, 0);
|
||||||
|
|
||||||
if (buffer){
|
if (buffer){
|
||||||
|
|
@ -224,8 +223,7 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){
|
||||||
|
|
||||||
if (!buffer){
|
if (!buffer){
|
||||||
char buf[512];
|
char buf[512];
|
||||||
snprintf(buf, sizeof(buf), "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError());
|
crash(Exception::MEOW, false, "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError());
|
||||||
crash(msg, Exception::MEOW, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -360,11 +360,6 @@ void Sprite::setY(int value){
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p->trans.setPosition(Vec2(getX(), value));
|
p->trans.setPosition(Vec2(getX(), value));
|
||||||
|
|
||||||
if (rgssVer >= 2){
|
|
||||||
p->wave.dirty = true;
|
|
||||||
setSpriteY(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setOX(int value){
|
void Sprite::setOX(int value){
|
||||||
|
|
@ -402,9 +397,6 @@ void Sprite::setZoomY(float value){
|
||||||
|
|
||||||
p->trans.setScale(Vec2(getZoomX(), value));
|
p->trans.setScale(Vec2(getZoomX(), value));
|
||||||
p->recomputeBushDepth();
|
p->recomputeBushDepth();
|
||||||
|
|
||||||
if (rgssVer >= 2)
|
|
||||||
p->wave.dirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setAngle(float value){
|
void Sprite::setAngle(float value){
|
||||||
|
|
@ -628,4 +620,4 @@ void Sprite::defaultSpriteShaderInit(SpriteShaderBase &shader){
|
||||||
|
|
||||||
shader.setColor(*blend);
|
shader.setColor(*blend);
|
||||||
shader.setModulate(p->modulate->norm);
|
shader.setModulate(p->modulate->norm);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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("Marshal: Table: bad file format", Exception::RGSSError, true);
|
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("Marshal: Table: bad file format", Exception::RGSSError, true);
|
crash(Exception::RGSSError, true, "Marshal: Table: bad file format");
|
||||||
|
|
||||||
if (len != 20 + x*y*z*2)
|
if (len != 20 + x*y*z*2)
|
||||||
crash("Marshal: Table: bad file format", Exception::RGSSError, true);
|
crash(Exception::RGSSError, true, "Marshal: Table: bad file format");
|
||||||
|
|
||||||
Table *t = new Table(x, y, z);
|
Table *t = new Table(x, y, z);
|
||||||
memcpy(dataPtr(t->data), data, sizeof(int16_t)*size);
|
memcpy(dataPtr(t->data), data, sizeof(int16_t)*size);
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ TexPool::~TexPool(){
|
||||||
TEXFBO TexPool::request(int width, int height){
|
TEXFBO TexPool::request(int width, int height){
|
||||||
CacheNode cnode;
|
CacheNode cnode;
|
||||||
Size size(width, height);
|
Size size(width, height);
|
||||||
char msg[512];
|
|
||||||
/* See if we can statisfy request from cache */
|
/* See if we can statisfy request from cache */
|
||||||
CNodeList &bucket = p->poolHash[size];
|
CNodeList &bucket = p->poolHash[size];
|
||||||
|
|
||||||
|
|
@ -118,8 +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){
|
||||||
snprintf(msg, sizeof msg, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height);
|
crash(Exception::MKXPError, true, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height);
|
||||||
crash(msg, Exception::MKXPError, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nope, create it instead */
|
/* Nope, create it instead */
|
||||||
|
|
|
||||||
|
|
@ -357,8 +357,7 @@ struct TilemapPrivate {
|
||||||
for (size_t i = 0; i < zlayersMax; ++i)
|
for (size_t i = 0; i < zlayersMax; ++i)
|
||||||
elem.zlayers[i] = new ZLayer(this, viewport);
|
elem.zlayers[i] = new ZLayer(this, viewport);
|
||||||
|
|
||||||
prepareCon = shState->prepareDraw.connect
|
prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &TilemapPrivate::prepare));
|
||||||
(sigc::mem_fun(this, &TilemapPrivate::prepare));
|
|
||||||
|
|
||||||
updateFlashMapViewport();
|
updateFlashMapViewport();
|
||||||
}
|
}
|
||||||
|
|
@ -403,7 +402,7 @@ struct TilemapPrivate {
|
||||||
atlas.size = TileAtlas::minSize(atlas.efTilesetH, glState.caps.maxTexSize);
|
atlas.size = TileAtlas::minSize(atlas.efTilesetH, glState.caps.maxTexSize);
|
||||||
|
|
||||||
if (atlas.size.x < 0)
|
if (atlas.size.x < 0)
|
||||||
throw Exception(Exception::MKXPError, "Cannot allocate big enough texture for tileset atlas");
|
crash(Exception::MKXPError, true, "Cannot allocate big enough texture for tileset atlas");
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAutotileInfo(){
|
void updateAutotileInfo(){
|
||||||
|
|
@ -499,13 +498,11 @@ struct TilemapPrivate {
|
||||||
if (blitW <= autotileW && tiles.animated){
|
if (blitW <= autotileW && tiles.animated){
|
||||||
/* Static autotile */
|
/* Static autotile */
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int j = 0; j < 4; ++j)
|
||||||
GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH),
|
GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH), Vec2i(autotileW*j, atInd*autotileH));
|
||||||
Vec2i(autotileW*j, atInd*autotileH));
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* Animated autotile */
|
/* Animated autotile */
|
||||||
GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH),
|
GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH), Vec2i(0, atInd*autotileH));
|
||||||
Vec2i(0, atInd*autotileH));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -535,8 +532,7 @@ struct TilemapPrivate {
|
||||||
Vec2i texSize;
|
Vec2i texSize;
|
||||||
shState->ensureTexSize(tsLaneW, blitOp.h, texSize);
|
shState->ensureTexSize(tsLaneW, blitOp.h, texSize);
|
||||||
shState->bindTex();
|
shState->bindTex();
|
||||||
GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y,
|
GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y, 0, 0, tsLaneW, blitOp.h, tsSurf, GL_RGBA);
|
||||||
0, 0, tsLaneW, blitOp.h, tsSurf, GL_RGBA);
|
|
||||||
|
|
||||||
shader.setTexSize(texSize);
|
shader.setTexSize(texSize);
|
||||||
quad.setTexRect(FloatRect(0, 0, tsLaneW, blitOp.h));
|
quad.setTexRect(FloatRect(0, 0, tsLaneW, blitOp.h));
|
||||||
|
|
@ -556,8 +552,7 @@ struct TilemapPrivate {
|
||||||
for (size_t i = 0; i < blits.size(); ++i){
|
for (size_t i = 0; i < blits.size(); ++i){
|
||||||
const TileAtlas::Blit &blitOp = blits[i];
|
const TileAtlas::Blit &blitOp = blits[i];
|
||||||
|
|
||||||
GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y,
|
GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y, blitOp.dst.x, blitOp.dst.y, tsLaneW, blitOp.h, tsSurf, GL_RGBA);
|
||||||
blitOp.dst.x, blitOp.dst.y, tsLaneW, blitOp.h, tsSurf, GL_RGBA);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLMeta::subRectImageEnd();
|
GLMeta::subRectImageEnd();
|
||||||
|
|
@ -572,8 +567,7 @@ struct TilemapPrivate {
|
||||||
for (size_t i = 0; i < blits.size(); ++i){
|
for (size_t i = 0; i < blits.size(); ++i){
|
||||||
const TileAtlas::Blit &blitOp = blits[i];
|
const TileAtlas::Blit &blitOp = blits[i];
|
||||||
|
|
||||||
GLMeta::blitRectangle(IntRect(blitOp.src.x, blitOp.src.y, tsLaneW, blitOp.h),
|
GLMeta::blitRectangle(IntRect(blitOp.src.x, blitOp.src.y, tsLaneW, blitOp.h), blitOp.dst);
|
||||||
blitOp.dst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLMeta::blitEnd();
|
GLMeta::blitEnd();
|
||||||
|
|
@ -1118,8 +1112,7 @@ void Tilemap::setMapData(Table *value){
|
||||||
|
|
||||||
p->invalidateBuffers();
|
p->invalidateBuffers();
|
||||||
p->mapDataCon.disconnect();
|
p->mapDataCon.disconnect();
|
||||||
p->mapDataCon = value->modified.connect
|
p->mapDataCon = value->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers));
|
||||||
(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tilemap::setFlashData(Table *value){
|
void Tilemap::setFlashData(Table *value){
|
||||||
|
|
@ -1141,8 +1134,7 @@ void Tilemap::setPriorities(Table *value){
|
||||||
|
|
||||||
p->invalidateBuffers();
|
p->invalidateBuffers();
|
||||||
p->prioritiesCon.disconnect();
|
p->prioritiesCon.disconnect();
|
||||||
p->prioritiesCon = value->modified.connect
|
p->prioritiesCon = value->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers));
|
||||||
(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tilemap::setVisible(bool value){
|
void Tilemap::setVisible(bool value){
|
||||||
|
|
|
||||||
|
|
@ -35,23 +35,15 @@
|
||||||
|
|
||||||
namespace TileQuads{
|
namespace TileQuads{
|
||||||
/* Calculate needed quad counts */
|
/* Calculate needed quad counts */
|
||||||
int oneDimCount(int tileDimension,
|
int oneDimCount(int tileDimension, int destDimension);
|
||||||
int destDimension);
|
int twoDimCount(int tileW, int tileH, int destW, int destH);
|
||||||
int twoDimCount(int tileW, int tileH,
|
|
||||||
int destW, int destH);
|
|
||||||
|
|
||||||
/* Build tiling quads */
|
/* Build tiling quads */
|
||||||
int buildH(const IntRect &sourceRect,
|
int buildH(const IntRect &sourceRect, int width, int x, int y, Vertex *verts);
|
||||||
int width, int x, int y,
|
|
||||||
Vertex *verts);
|
|
||||||
|
|
||||||
int buildV(const IntRect &sourceRect,
|
int buildV(const IntRect &sourceRect, int height, int ox, int oy, Vertex *verts);
|
||||||
int height, int ox, int oy,
|
|
||||||
Vertex *verts);
|
|
||||||
|
|
||||||
int build(const IntRect &sourceRect,
|
int build(const IntRect &sourceRect, const IntRect &destRect, Vertex *verts);
|
||||||
const IntRect &destRect,
|
|
||||||
Vertex *verts);
|
|
||||||
|
|
||||||
/* Build a quad "frame" (see Window cursor_rect) */
|
/* Build a quad "frame" (see Window cursor_rect) */
|
||||||
int buildFrame(const IntRect &rect, Vertex vert[36]);
|
int buildFrame(const IntRect &rect, Vertex vert[36]);
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ struct VorbisSource : ALDataSource{
|
||||||
|
|
||||||
if (error){
|
if (error){
|
||||||
SDL_CloseIO(&src);
|
SDL_CloseIO(&src);
|
||||||
crash("Vorbisfile: Cannot read ogg file", Exception::MKXPError, true);
|
crash(Exception::MKXPError, true, "Vorbisfile: Cannot read ogg file");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract bitstream info */
|
/* Extract bitstream info */
|
||||||
|
|
@ -90,7 +90,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("Cannot handle audio with more than 2 channels", Exception::MKXPError, true);
|
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 New Issue