Debuging ruby error + added One shot mode

This commit is contained in:
ZakatTeamI2P 2026-04-12 12:49:07 +04:00
parent cbac6c0c6f
commit 799370de98
21 changed files with 236 additions and 360 deletions

View file

@ -11,8 +11,9 @@ option(DEBUG "Debug mode" OFF)
## Misc setup ##
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(DEBUG_C_FLAGS "-g -O0 -fno-omit-frame-pointer")
set(DEBUG_CXX_FLAGS "-g -O0 -fno-omit-frame-pointer -std=c++17")
#i want die
set(DEBUG_C_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb")
set(DEBUG_CXX_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_C_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_CXX_FLAGS}")

View file

@ -1,6 +1,6 @@
# mkxp-sunshine
This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: sunshine.
This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: sunshine mod
# xScripts.rxdata
./rpgscript.rb scripts/ [GameDir]

View file

@ -3,6 +3,7 @@ Type=Application
Name=OneShot
Exec=oneshot %F
Comment=A surreal puzzle adventure game with unique mechanics / capabilities.
Comment[ru]=Сюрреалистическая головоломка-приключение с уникальными механиками / возможностями.
Icon=oneshot
Categories=Game;
Terminal=false

View file

@ -32,7 +32,10 @@
int volume = 100; \
int pitch = 100; \
double pos = 0.0; \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos 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; \
} \
@ -112,8 +115,7 @@ DEF_PLAY_STOP( se )
DEF_AUD_PROP_I(BGM_Volume)
DEF_AUD_PROP_I(SFX_Volume)
RB_METHOD(audioReset)
{
RB_METHOD(audioReset){
RB_UNUSED_PARAM;
shState->audio().reset();
@ -143,18 +145,16 @@ RB_METHOD(audioReset)
}
void
audioBindingInit()
{
audioBindingInit(){
VALUE module = rb_define_module("Audio");
BIND_PLAY_STOP_FADE( bgm );
BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me );
if (rgssVer >= 3)
{
BIND_POS( bgm );
BIND_POS( bgs );
if (rgssVer >= 3){
BIND_POS( bgm );
BIND_POS( bgs );
}
BIND_PLAY_STOP( se )

View file

@ -34,7 +34,6 @@
#include <ruby.h>
#include <ruby/encoding.h>
#undef inline
#include <assert.h>
#include <string>
#include <zlib.h>
@ -47,8 +46,7 @@ static void mriBindingExecute();
static void mriBindingTerminate();
static void mriBindingReset();
ScriptBinding scriptBindingImpl =
{
ScriptBinding scriptBindingImpl = {
mriBindingExecute,
mriBindingTerminate,
mriBindingReset
@ -95,8 +93,7 @@ RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
RB_METHOD(_kernelCaller);
static void mriBindingInit()
{
static void mriBindingInit(){
tableBindingInit();
etcBindingInit();
fontBindingInit();
@ -120,8 +117,7 @@ static void mriBindingInit()
steamBindingInit();
chromaBindingInit();
if (rgssVer >= 3)
{
if (rgssVer >= 3){
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
@ -129,9 +125,7 @@ static void mriBindingInit()
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1"));
}
else
{
}else{
_rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP);
@ -159,9 +153,7 @@ static void mriBindingInit()
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
}
static void
showMsg(const std::string &msg)
{
static void showMsg(const std::string &msg){
#ifdef NDEBUG
shState->eThread().showMessageBox(msg.c_str());
#else
@ -169,14 +161,11 @@ showMsg(const std::string &msg)
#endif
}
static void printP(int argc, VALUE *argv,
const char *convMethod, const char *sep)
{
static void printP(int argc, VALUE *argv, const char *convMethod, const char *sep){
VALUE dispString = rb_str_buf_new(128);
ID conv = rb_intern(convMethod);
for (int i = 0; i < argc; ++i)
{
for (int i = 0; i < argc; ++i){
VALUE str = rb_funcall2(argv[i], conv, 0, NULL);
rb_str_buf_append(dispString, str);
@ -187,8 +176,7 @@ static void printP(int argc, VALUE *argv,
showMsg(RSTRING_PTR(dispString));
}
RB_METHOD(mriPrint)
{
RB_METHOD(mriPrint){
RB_UNUSED_PARAM;
printP(argc, argv, "to_s", "");
@ -196,8 +184,7 @@ RB_METHOD(mriPrint)
return Qnil;
}
RB_METHOD(mriP)
{
RB_METHOD(mriP){
RB_UNUSED_PARAM;
printP(argc, argv, "inspect", "\n");
@ -205,8 +192,7 @@ RB_METHOD(mriP)
return Qnil;
}
RB_METHOD(mkxpDataDirectory)
{
RB_METHOD(mkxpDataDirectory){
RB_UNUSED_PARAM;
const std::string &path = shState->config().customDataPath;
@ -215,8 +201,7 @@ RB_METHOD(mkxpDataDirectory)
return rb_str_new_cstr(s);
}
RB_METHOD(mkxpPuts)
{
RB_METHOD(mkxpPuts){
RB_UNUSED_PARAM;
const char *str;
@ -227,8 +212,7 @@ RB_METHOD(mkxpPuts)
return Qnil;
}
RB_METHOD(mkxpRawKeyStates)
{
RB_METHOD(mkxpRawKeyStates){
RB_UNUSED_PARAM;
VALUE str = rb_str_new(0, sizeof(EventThread::keyStates));
@ -237,21 +221,18 @@ RB_METHOD(mkxpRawKeyStates)
return str;
}
RB_METHOD(mkxpMouseInWindow)
{
RB_METHOD(mkxpMouseInWindow){
RB_UNUSED_PARAM;
return rb_bool_new(EventThread::mouseState.inWindow);
}
static VALUE rgssMainCb(VALUE block)
{
static VALUE rgssMainCb(VALUE block){
rb_funcall2(block, rb_intern("call"), 0, 0);
return Qnil;
}
static VALUE rgssMainRescue(VALUE arg, VALUE exc)
{
static VALUE rgssMainRescue(VALUE arg, VALUE exc){
VALUE *excRet = (VALUE*) arg;
*excRet = exc;
@ -259,8 +240,7 @@ static VALUE rgssMainRescue(VALUE arg, VALUE exc)
return Qnil;
}
static void processReset()
{
static void processReset(){
shState->graphics().reset();
shState->audio().reset();
@ -269,12 +249,10 @@ static void processReset()
false);
}
RB_METHOD(mriRgssMain)
{
RB_METHOD(mriRgssMain){
RB_UNUSED_PARAM;
while (true)
{
while (true){
VALUE exc = Qnil;
rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(),
@ -293,8 +271,7 @@ RB_METHOD(mriRgssMain)
return Qnil;
}
RB_METHOD(mriRgssStop)
{
RB_METHOD(mriRgssStop){
RB_UNUSED_PARAM;
while (true)
@ -303,8 +280,7 @@ RB_METHOD(mriRgssStop)
return Qnil;
}
RB_METHOD(_kernelCaller)
{
RB_METHOD(_kernelCaller){
RB_UNUSED_PARAM;
VALUE trace = rb_funcall2(rb_mKernel, rb_intern("_mkxp_kernel_caller_alias"), 0, 0);
@ -335,35 +311,29 @@ RB_METHOD(_kernelCaller)
return trace;
}
static VALUE newStringUTF8(const char *string, long length)
{
static VALUE newStringUTF8(const char *string, long length){
return rb_enc_str_new(string, length, rb_utf8_encoding());
}
struct evalArg
{
struct evalArg{
VALUE string;
VALUE filename;
};
static VALUE evalHelper(evalArg *arg)
{
static VALUE evalHelper(evalArg *arg){
VALUE argv[] = { arg->string, Qnil, arg->filename };
return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv);
}
static VALUE evalString(VALUE string, VALUE filename, int *state)
{
static VALUE evalString(VALUE string, VALUE filename, int *state){
evalArg arg = { string, filename };
return rb_protect((VALUE (*)(VALUE))evalHelper, (VALUE)&arg, state);
}
static void runCustomScript(const std::string &filename)
{
static void runCustomScript(const std::string &filename){
std::string scriptData;
if (!readFileSDL(filename.c_str(), scriptData))
{
if (!readFileSDL(filename.c_str(), scriptData)){
showMsg(std::string("Unable to open '") + filename + "'");
return;
}
@ -374,27 +344,23 @@ static void runCustomScript(const std::string &filename)
VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
struct BacktraceData
{
struct BacktraceData{
/* Maps: Ruby visible filename, To: Actual script name */
BoostHash<std::string, std::string> scriptNames;
};
#define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld")
static void runRMXPScripts(BacktraceData &btData)
{
static void runRMXPScripts(BacktraceData &btData){
const Config &conf = shState->rtData().config;
const std::string &scriptPack = conf.game.scripts;
if (scriptPack.empty())
{
if (scriptPack.empty()){
showMsg("No game scripts specified (missing Game.ini?)");
return;
}
if (!shState->fileSystem().exists(scriptPack.c_str()))
{
if (!shState->fileSystem().exists(scriptPack.c_str())){
showMsg("Unable to open '" + scriptPack + "'");
return;
}
@ -403,18 +369,14 @@ static void runRMXPScripts(BacktraceData &btData)
/* We checked if Scripts.rxdata exists, but something might
* still go wrong */
try
{
try{
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
}
catch (const Exception &e)
{
}catch (const Exception &e){
showMsg(std::string("Failed to read script data: ") + e.msg);
return;
}
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY))
{
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
showMsg("Failed to read script data");
return;
}
@ -429,8 +391,7 @@ static void runRMXPScripts(BacktraceData &btData)
std::string decodeBuffer;
decodeBuffer.resize(0x1000);
for (long i = 0; i < scriptCount; ++i)
{
for (long i = 0; i < scriptCount; ++i){
VALUE script = rb_ary_entry(scriptArray, i);
if (!RB_TYPE_P(script, RUBY_T_ARRAY))
@ -442,8 +403,7 @@ static void runRMXPScripts(BacktraceData &btData)
int result = Z_OK;
unsigned long bufferLen;
while (true)
{
while (true){
unsigned char *bufferPtr =
reinterpret_cast<unsigned char*>(const_cast<char*>(decodeBuffer.c_str()));
const unsigned char *sourcePtr =
@ -462,8 +422,7 @@ static void runRMXPScripts(BacktraceData &btData)
decodeBuffer.resize(decodeBuffer.size()*2);
}
if (result != Z_OK)
{
if (result != Z_OK){
static char buffer[256];
snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'",
i, RSTRING_PTR(scriptName));
@ -485,10 +444,8 @@ static void runRMXPScripts(BacktraceData &btData)
if (exc != Qnil)
return;
while (true)
{
for (long i = 0; i < scriptCount; ++i)
{
while (true){
for (long i = 0; i < scriptCount; ++i){
VALUE script = rb_ary_entry(scriptArray, i);
VALUE scriptDecoded = rb_ary_entry(script, 3);
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
@ -518,8 +475,7 @@ static void runRMXPScripts(BacktraceData &btData)
}
}
static void showExc(VALUE exc, const BacktraceData &btData)
{
static void showExc(VALUE exc, const BacktraceData &btData){
VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
VALUE bt0 = rb_ary_entry(bt, 0);
@ -577,29 +533,27 @@ static void showExc(VALUE exc, const BacktraceData &btData)
showMsg(ms);
}
static void mriBindingExecute()
{
static void mriBindingExecute(){
/* Normally only a ruby executable would do a sysinit,
* but not doing it will lead to crashes due to closed
* stdio streams on some platforms (eg. Windows) */
//JIT for performance
int argc = 0;
char **argv = 0;
ruby_sysinit(&argc, &argv);
ruby_setup();
char options_argv1[] = "oneshot", options_argv2[] = "-e", options_argv3[] = "";
char options_argv1[] = "oneshot", options_argv2[] = "-evd", options_argv3[] = "--jit";
char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL};
ruby_setup();
ruby_sysinit(&argc, &argv);
//ruby_init();
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
Config &conf = shState->rtData().config;
if (!conf.rubyLoadpaths.empty())
{
if (!conf.rubyLoadpaths.empty()){
/* Setup custom load paths */
VALUE lpaths = rb_gv_get(":");
for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i)
{
for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i){
std::string &path = conf.rubyLoadpaths[i];
VALUE pathv = rb_str_new(path.c_str(), path.size());
@ -624,15 +578,13 @@ static void mriBindingExecute()
shState->rtData().rqTermAck.set();
}
static void mriBindingTerminate()
{
static void mriBindingTerminate(){
rb_raise(rb_eSystemExit, " ");
#ifdef __linux__
wallpaperBindingTerminate();
#endif
}
static void mriBindingReset()
{
static void mriBindingReset(){
rb_raise(getRbData()->exc[Reset], " ");
}

View file

@ -29,13 +29,11 @@
#include <string.h>
#include <assert.h>
RbData *getRbData()
{
RbData *getRbData(){
return static_cast<RbData*>(shState->bindingData());
}
struct
{
struct{
RbException id;
const char *name;
} static customExc[] =
@ -45,8 +43,7 @@ struct
{ SDL, "SDLError" }
};
RbData::RbData()
{
RbData::RbData(){
for (size_t i = 0; i < ARRAY_SIZE(customExc); ++i)
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
@ -59,14 +56,12 @@ RbData::RbData()
exc[ArgumentError] = rb_eArgError;
}
RbData::~RbData()
{
RbData::~RbData(){
}
/* Indexed with Exception::Type */
static const RbException excToRbExc[] =
{
static const RbException excToRbExc[] = {
RGSS, /* RGSSError */
ErrnoENOENT, /* NoFileError */
IOError,
@ -85,9 +80,7 @@ void raiseRbExc(const Exception &exc){
rb_raise(excClass, "%s", exc.msg.c_str());
}
void
raiseDisposedAccess(VALUE self)
{
void raiseDisposedAccess(VALUE self){
const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name;
char buf[32];
@ -97,9 +90,7 @@ raiseDisposedAccess(VALUE self)
rb_raise(getRbData()->exc[RGSS], "disposed %s", buf);
}
int
rb_get_args(int argc, VALUE *argv, const char *format, ...)
{
int rb_get_args(int argc, VALUE *argv, const char *format, ...){
char c;
VALUE *arg = argv;
va_list ap;
@ -108,8 +99,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
va_start(ap, format);
while ((c = *format++))
{
while ((c = *format++)){
switch (c)
{
case '|' :
@ -117,7 +107,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
default:
// FIXME print num of needed args vs provided
if (argc <= argI && !opt)
rb_raise(rb_eArgError, "wrong number of arguments");
rb_raise(rb_eArgError, "wrong number of arguments ");
break;
}

View file

@ -28,13 +28,10 @@
/* 'Children' are disposables that are disposed together
* with their parent. Currently this is only used by Viewport
* in RGSS1. */
inline void
disposableAddChild(VALUE disp, VALUE child)
{
inline void disposableAddChild(VALUE disp, VALUE child){
VALUE children = rb_iv_get(disp, "children");
if (NIL_P(children))
{
if (NIL_P(children)){
children = rb_ary_new();
rb_iv_set(disp, "children", children);
}
@ -43,9 +40,7 @@ disposableAddChild(VALUE disp, VALUE child)
rb_ary_push(children, child);
}
inline void
disposableDisposeChildren(VALUE disp)
{
inline void disposableDisposeChildren(VALUE disp){
VALUE children = rb_iv_get(disp, "children");
if (NIL_P(children))
@ -58,8 +53,7 @@ disposableDisposeChildren(VALUE disp)
}
template<class C>
RB_METHOD(disposableDispose)
{
RB_METHOD(disposableDispose){
RB_UNUSED_PARAM;
C *d = getPrivateData<C>(self);
@ -80,8 +74,7 @@ RB_METHOD(disposableDispose)
}
template<class C>
RB_METHOD(disposableIsDisposed)
{
RB_METHOD(disposableIsDisposed){
RB_UNUSED_PARAM;
C *d = getPrivateData<C>(self);
@ -93,8 +86,7 @@ RB_METHOD(disposableIsDisposed)
}
template<class C>
static void disposableBindingInit(VALUE klass)
{
static void disposableBindingInit(VALUE klass){
_rb_define_method(klass, "dispose", disposableDispose<C>);
_rb_define_method(klass, "disposed?", disposableIsDisposed<C>);
@ -105,9 +97,7 @@ static void disposableBindingInit(VALUE klass)
}
template<class C>
inline void
checkDisposed(VALUE self)
{
inline void checkDisposed(VALUE self){
if (disposableIsDisposed<C>(0, 0, self) == Qtrue)
raiseDisposedAccess(self);
}

View file

@ -125,16 +125,14 @@ SET_FUN(Color, double, "fff|f", 255)
SET_FUN(Tone, double, "fff|f", 0)
SET_FUN(Rect, int, "iiii", 0)
RB_METHOD(rectEmpty)
{
RB_METHOD(rectEmpty){
RB_UNUSED_PARAM;
Rect *r = getPrivateData<Rect>(self);
r->empty();
return self;
}
RB_METHOD(ColorStringify)
{
RB_METHOD(ColorStringify){
RB_UNUSED_PARAM;
Color *c = getPrivateData<Color>(self);
@ -143,8 +141,7 @@ RB_METHOD(ColorStringify)
c->red, c->green, c->blue, c->alpha);
}
RB_METHOD(ToneStringify)
{
RB_METHOD(ToneStringify){
RB_UNUSED_PARAM;
Tone *t = getPrivateData<Tone>(self);
@ -153,8 +150,7 @@ RB_METHOD(ToneStringify)
t->red, t->green, t->blue, t->gray);
}
RB_METHOD(RectStringify)
{
RB_METHOD(RectStringify){
RB_UNUSED_PARAM;
Rect *r = getPrivateData<Rect>(self);
@ -196,9 +192,7 @@ INITCOPY_FUN(Rect)
#define RB_ATTR_RW(Klass, Attr, attr) \
{ RB_ATTR_R(Klass, Attr, attr); RB_ATTR_W(Klass, Attr, attr); }
void
etcBindingInit()
{
void etcBindingInit(){
VALUE klass;
INIT_BIND(Color);

View file

@ -30,23 +30,17 @@
static void fileIntFreeInstance(void *inst){
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
SDL_CloseIO(ops);
}
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
static VALUE
fileIntForPath(const char *path, bool rubyExc)
{
static VALUE fileIntForPath(const char *path, bool rubyExc){
SDL_IOStream* ops;
try
{
try{
shState->fileSystem().openReadRaw(ops, path);
}
catch (const Exception &e)
{
catch (const Exception &e){
SDL_CloseIO(ops);
if (rubyExc)
@ -64,16 +58,14 @@ fileIntForPath(const char *path, bool rubyExc)
return obj;
}
RB_METHOD(fileIntRead)
{
RB_METHOD(fileIntRead){
int length = -1;
rb_get_args(argc, argv, "i", &length RB_ARG_END);
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
if (length == -1)
{
if (length == -1){
Sint64 cur = SDL_TellIO(ops);
Sint64 end = SDL_SeekIO(ops, 0, SDL_IO_SEEK_END);
length = end - cur;
@ -90,8 +82,7 @@ RB_METHOD(fileIntRead)
return data;
}
RB_METHOD(fileIntClose)
{
RB_METHOD(fileIntClose){
RB_UNUSED_PARAM;
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
@ -100,28 +91,21 @@ RB_METHOD(fileIntClose)
return Qnil;
}
RB_METHOD(fileIntGetByte)
{
RB_METHOD(fileIntGetByte){
RB_UNUSED_PARAM;
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
unsigned char byte;
size_t result = SDL_ReadIO(ops, &byte, 1);
return (result == 1) ? rb_fix_new(byte) : Qnil;
}
RB_METHOD(fileIntBinmode)
{
RB_METHOD(fileIntBinmode){
RB_UNUSED_PARAM;
return Qnil;
}
VALUE
kernelLoadDataInt(const char *filename, bool rubyExc)
{
VALUE kernelLoadDataInt(const char *filename, bool rubyExc){
rb_gc_start();
VALUE port = fileIntForPath(filename, rubyExc);
@ -136,8 +120,7 @@ kernelLoadDataInt(const char *filename, bool rubyExc)
return result;
}
RB_METHOD(kernelLoadData)
{
RB_METHOD(kernelLoadData){
RB_UNUSED_PARAM;
const char *filename;
@ -146,8 +129,7 @@ RB_METHOD(kernelLoadData)
return kernelLoadDataInt(filename, true);
}
RB_METHOD(kernelSaveData)
{
RB_METHOD(kernelSaveData){
RB_UNUSED_PARAM;
VALUE obj;
@ -167,48 +149,36 @@ RB_METHOD(kernelSaveData)
return Qnil;
}
static VALUE stringForceUTF8(VALUE arg)
{
static VALUE stringForceUTF8(VALUE arg){
if (RB_TYPE_P(arg, RUBY_T_STRING) && ENCODING_IS_ASCII8BIT(arg))
rb_enc_associate_index(arg, rb_utf8_encindex());
return arg;
}
static VALUE customProc(VALUE arg, VALUE proc)
{
static VALUE customProc(VALUE arg, VALUE proc){
VALUE obj = stringForceUTF8(arg);
obj = rb_funcall2(proc, rb_intern("call"), 1, &obj);
return obj;
}
RB_METHOD(_marshalLoad){
printf("test\n");
RB_UNUSED_PARAM;
printf("test2\n");
VALUE port, proc = Qnil;
printf("test3\n");
rb_scan_args(argc, argv, "01", &port, &proc);
//rb_get_args(argc, argv, "o|o", &port, &proc RB_ARG_END);
printf("test4\n");
VALUE utf8Proc;
if (NIL_P(proc))
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil);
else
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(customProc), proc);
printf("test5\n");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
//if (!rb_obj_is_kind_of(marsh, rb_cModule)) rb_raise(rb_eRuntimeError, "Marshal not found");
printf("test6\n");
VALUE v[] = { port, utf8Proc };
printf("test7\n");
return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v);
}
void
fileIntBindingInit()
{
void fileIntBindingInit(){
VALUE klass = rb_define_class("FileInt", rb_cIO);
rb_define_alloc_func(klass, classAllocate<&FileIntType>);
@ -223,11 +193,11 @@ fileIntBindingInit()
/* We overload the built-in 'Marshal::load()' function to silently
* insert our utf8proc that ensures all read strings will be
* UTF-8 encoded */
printf("test8\n");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
printf("test9\n");
if(marsh = Qnil){
printf("BrUh: cant get Marshal\n");
exit(1);
}
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
printf("test10\n");
_rb_define_module_function(marsh, "load", _marshalLoad);
printf("test11\n");
}

View file

@ -57,8 +57,7 @@
#endif
#ifdef __linux__
void desktopEnvironmentInit()
{
void desktopEnvironmentInit(){
if (desktop != "uninitialized") {
return;
}

View file

@ -26,8 +26,7 @@
DEF_TYPE(Window);
RB_METHOD(windowInitialize)
{
RB_METHOD(windowInitialize){
Window *w = viewportElementInitialize<Window>(argc, argv, self);
setPrivateData(self, w);
@ -39,8 +38,7 @@ RB_METHOD(windowInitialize)
return self;
}
RB_METHOD(windowUpdate)
{
RB_METHOD(windowUpdate){
RB_UNUSED_PARAM;
Window *w = getPrivateData<Window>(self);
@ -70,8 +68,7 @@ DEF_PROP_I(Window, ContentsOpacity)
void
windowBindingInit()
{
windowBindingInit(){
VALUE klass = rb_define_class("Window", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&WindowType>);

View file

@ -24,24 +24,15 @@
#include "eventthread.h"
#include "debugwriter.h"
static void nullBindingExecute()
{
static void nullBindingExecute(){
Debug() << "The null binding doesn't do anything, so we're done!";
shState->rtData().rqTermAck.set();
}
static void nullBindingTerminate()
{
static void nullBindingTerminate() {}
static void nullBindingReset() {}
}
static void nullBindingReset()
{
}
ScriptBinding scriptBindingImpl =
{
ScriptBinding scriptBindingImpl ={
nullBindingExecute,
nullBindingTerminate,
nullBindingReset

View file

@ -10,8 +10,7 @@
#include <guiddef.h>
#endif
namespace ChromaSDK
{
namespace ChromaSDK{
// Keyboards
//! Razer Blackwidow Chroma device.
// {2EA1BB63-CA28-428D-9F06-196B88330BBB}
@ -166,7 +165,6 @@ namespace ChromaSDK
static const GUID CORE_CHROMA =
{ 0x201203b, 0x62f3, 0x4c50, { 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } };
}
#endif

View file

@ -15,14 +15,12 @@ typedef void* PRZPARAM; //!< Context sensitive pointer.
typedef DWORD RZID; //!< Generic data type for Identifier.
typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable)
namespace ChromaSDK
{
namespace ChromaSDK{
//! Event notification Window message
const UINT WM_CHROMA_EVENT = WM_APP+0x2000;
//! Chroma generic effects. Note: Not all devices supported the listed effects.
typedef enum EFFECT_TYPE
{
typedef enum EFFECT_TYPE{
CHROMA_NONE = 0, //!< No effect.
CHROMA_WAVE, //!< Wave effect (This effect type has deprecated and should not be used).
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect type has deprecated and should not be used).
@ -36,11 +34,9 @@ namespace ChromaSDK
} EFFECT_TYPE;
//! Device info.
typedef struct DEVICE_INFO_TYPE
{
typedef struct DEVICE_INFO_TYPE{
//! Device types.
enum DeviceType
{
enum DeviceType{
DEVICE_KEYBOARD = 1, //!< Keyboard device.
DEVICE_MOUSE = 2, //!< Mouse device.
DEVICE_HEADSET = 3, //!< Headset device.
@ -57,8 +53,7 @@ namespace ChromaSDK
const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects.
//! Blinking effect (This effect type has deprecated and should not be used).
typedef struct BLINKING_EFFECT_TYPE
{
typedef struct BLINKING_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
@ -66,14 +61,12 @@ namespace ChromaSDK
} BLINKING_EFFECT_TYPE;
//! Breathing effect (This effect type has deprecated and should not be used).
typedef struct BREATHING_EFFECT_TYPE
{
typedef struct BREATHING_EFFECT_TYPE{
RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Breathing effect types.
enum _Type
{
enum _Type{
ONE_COLOR = 1, //!< 1 color (Only fill Color1).
TWO_COLORS, //!< 2 colors.
RANDOM_COLORS //!< Random colors
@ -84,8 +77,7 @@ namespace ChromaSDK
} BREATHING_EFFECT_TYPE;
//! Custom effect (This effect type has deprecated and should not be used).
typedef struct CUSTOM_EFFECT_TYPE
{
typedef struct CUSTOM_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
@ -93,21 +85,18 @@ namespace ChromaSDK
} CUSTOM_EFFECT_TYPE;
//! No effect.
typedef struct NO_EFFECT_TYPE
{
typedef struct NO_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
} NO_EFFECT_TYPE;
//! Reactive effect (This effect type has deprecated and should not be used).
typedef struct REACTIVE_EFFECT_TYPE
{
typedef struct REACTIVE_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Duration of the effect.
enum _Duration
{
enum _Duration{
DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration.
@ -117,21 +106,18 @@ namespace ChromaSDK
} REACTIVE_EFFECT_TYPE;
//! Spectrum cycling effect (This effect type has deprecated and should not be used).
typedef struct SPECTRUMCYCLING_EFFECT_TYPE
{
typedef struct SPECTRUMCYCLING_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
} SPECTRUMCYCLING_EFFECT_TYPE;
//! Starlight effect (This effect type has deprecated and should not be used).
typedef struct STARLIGHT_EFFECT_TYPE
{
typedef struct STARLIGHT_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Starlight effect types.
enum _Type
{
enum _Type{
TWO_COLORS = 1, //!< 2 colors.
RANDOM_COLORS //!< Random colors
} Type;
@ -140,8 +126,7 @@ namespace ChromaSDK
COLORREF Color2; //!< Second color.
//! Duration of the effect.
enum _Duration
{
enum _Duration{
DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration.
@ -150,8 +135,7 @@ namespace ChromaSDK
} STARLIGHT_EFFECT_TYPE;
//! Static effect (This effect type has deprecated and should not be used).
typedef struct STATIC_EFFECT_TYPE
{
typedef struct STATIC_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
@ -159,8 +143,7 @@ namespace ChromaSDK
} STATIC_EFFECT_TYPE;
//! Wave effect (This effect type has deprecated and should not be used).
typedef struct WAVE_EFFECT_TYPE
{
typedef struct WAVE_EFFECT_TYPE{
RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
@ -175,8 +158,7 @@ namespace ChromaSDK
} WAVE_EFFECT_TYPE;
//! Keyboards
namespace Keyboard
{
namespace Keyboard{
//! Definitions of keys.
typedef enum RZKEY
{

View file

@ -123,7 +123,12 @@ class Scene_Map
EdText.info(tr("You cannot perform this action during cutscenes."))
return
else
$game_temp.common_event_id = 35
if Window_Settings.OneShotMode = true
File.new("badend.lock", "w")
$game_temp.common_event_id = 35
else
$game_temp.common_event_id = 35
end
end
end
# Loop

View file

@ -34,12 +34,12 @@ class Scene_Title
$game_system = Game_System.new
# Skip title screen if debug mode (or demo, but not GDC)
if $debug || ($demo && !$GDC) || save_exists
$game_map.update
$game_map.autoplay
$scene = Scene_Map.new
return
end
#if $debug || ($demo && !$GDC) || save_exists
# $game_map.update
# $game_map.autoplay
# $scene = Scene_Map.new
# return
#end
load_perma_flags
Window_Settings.load_settings
Oneshot.allow_exit true
@ -53,7 +53,11 @@ class Scene_Title
if File.exists?("Graphics/Titles/#{translation_name}.png")
@sprite.bitmap = RPG::Cache.title(translation_name)
else
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
if File.exist?("badend.lock")
@sprite.bitmap = RPG::Cache.title("badend")
else
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
end
end
# check for debug file to add debug items
@ -72,9 +76,7 @@ class Scene_Title
@menu.bitmap = Bitmap.new(640, 480)
@menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start"))
@menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings"))
if !$GDC
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
end
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
if $game_switches[160] && $game_switches[152]
@menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("..."))
end
@ -90,7 +92,12 @@ class Scene_Title
# Initialize cursor position
@cursor_pos = 0
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
if File.exist?("badend.lock")
#TODO: fix
Audio.bgm_play("Audio/BGM/MyBurdenIsDead.ogg", 100, 100)
else
$game_system.bgm_play($data_system.title_bgm)
end
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
@ -130,11 +137,9 @@ class Scene_Title
#--------------------------------------------------------------------------
def update
@menu.bitmap.clear
@menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start"))
@menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start"))
@menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings"))
if !$GDC
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
end
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
if $game_switches[160] && $game_switches[152]
@menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("..."))
end
@ -178,17 +183,28 @@ class Scene_Title
if !@window_settings_title.visible
# Handle confirmation
if Input.trigger?(Input::ACTION)
case @cursor_pos
when 0 # Continue
$game_switches[157] = false
command_continue
when 1 # Settings
command_settings
when 2 # Shutdown
command_shutdown
when 3 # memory
$game_switches[157] = true
command_continue
if File.exist?("badend.lock")
case @cursor_pos
when 0 # Continue
EdText.info(tr("Savior not found"))
when 1 # Settings
command_settings
when 2 # Shutdown
command_shutdown
end
else
case @cursor_pos
when 0 # Continue
$game_switches[157] = false
command_continue
when 1 # Settings
command_settings
when 2 # Shutdown
command_shutdown
when 3 # memory
$game_switches[157] = true
command_continue
end
end
end
end

View file

@ -8,8 +8,11 @@ class Window_Settings
SETTINGS_FILE_NAME = Oneshot::SAVE_PATH + '/settings.conf'
class << self
attr_accessor :DebugIsEnabled
attr_accessor :OneShotMode
end
@DebugIsEnabled = false
#You have only ONE shot!
@OneShotMode = false
def save_settings
$persistent.save
File.open(SETTINGS_FILE_NAME, 'w') do |file|
@ -22,6 +25,7 @@ class Window_Settings
file.puts('frameskip=' + Graphics.frameskip.to_s)
file.puts('in_game_timer=' + $game_temp.igt_timer_visible.to_s)
file.puts('debug=' + Window_Settings.DebugIsEnabled.to_s)
file.puts('oneshotmode=' + Window_Settings.OneShotMode.to_s)
end
end
@ -84,10 +88,16 @@ class Window_Settings
Window_Settings.DebugIsEnabled = true
elsif vals[1] == "false"
Window_Settings.DebugIsEnabled = false
end
when "oneshotmode"
if vals[1] == "true"
Window_Settings.OneShotMode = true
elsif vals[1] == "false"
Window_Settings.OneShotMode = false
end
end
end
end
end
def initialize
@viewport = Viewport.new(0, 0, 640, 480)
@bg = Sprite.new(@viewport)
@ -145,7 +155,7 @@ class Window_Settings
tr('In-Game Timer'),
tr('Language'),
tr('Debug mode(DEVS ONLY!)'),
tr('Configure Controls (Press F1)'),
tr('One Shot Mode(!)'),
]
@index = 0
@ -231,6 +241,13 @@ class Window_Settings
else
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF"))
end
when 10
if(Window_Settings.OneShotMode == true)
#EdText.info(tr("WARNING: In this mode, if you close the game NOT through the bed, you will get a bad ending(Like in the Freeware Oneshot version)!"))
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("ON"))
else
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF"))
end
end
end
@ -476,6 +493,11 @@ class Window_Settings
Window_Settings.DebugIsEnabled = !Window_Settings.DebugIsEnabled
redraw_setting_index(9)
end
when 10
if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
Window_Settings.OneShotMode = !Window_Settings.OneShotMode
redraw_setting_index(10)
end
end
if Input.trigger?(Input::CANCEL)

View file

@ -48,48 +48,40 @@ struct ID \
} \
};
namespace Buffer
{
namespace Buffer{
DEF_AL_ID
inline Buffer::ID gen()
{
inline Buffer::ID gen(){
Buffer::ID id;
alGenBuffers(1, &id.al);
return id;
}
inline void del(Buffer::ID id)
{
inline void del(Buffer::ID id){
alDeleteBuffers(1, &id.al);
}
inline void uploadData(Buffer::ID id, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq)
{
inline void uploadData(Buffer::ID id, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq){
alBufferData(id.al, format, data, size, freq);
}
inline ALint getInteger(Buffer::ID id, ALenum prop)
{
inline ALint getInteger(Buffer::ID id, ALenum prop){
ALint value;
alGetBufferi(id.al, prop, &value);
return value;
}
inline ALint getSize(Buffer::ID id)
{
inline ALint getSize(Buffer::ID id){
return getInteger(id, AL_SIZE);
}
inline ALint getBits(Buffer::ID id)
{
inline ALint getBits(Buffer::ID id){
return getInteger(id, AL_BITS);
}
inline ALint getChannels(Buffer::ID id)
{
inline ALint getChannels(Buffer::ID id){
return getInteger(id, AL_CHANNELS);
}
}
@ -98,103 +90,86 @@ namespace Source
{
DEF_AL_ID
inline Source::ID gen()
{
inline Source::ID gen(){
Source::ID id;
alGenSources(1, &id.al);
return id;
}
inline void del(Source::ID id)
{
inline void del(Source::ID id){
alDeleteSources(1, &id.al);
}
inline void attachBuffer(Source::ID id, Buffer::ID buffer)
{
inline void attachBuffer(Source::ID id, Buffer::ID buffer){
alSourcei(id.al, AL_BUFFER, buffer.al);
}
inline void detachBuffer(Source::ID id)
{
inline void detachBuffer(Source::ID id){
attachBuffer(id, Buffer::ID(0));
}
inline void queueBuffer(Source::ID id, Buffer::ID buffer)
{
inline void queueBuffer(Source::ID id, Buffer::ID buffer){
alSourceQueueBuffers(id.al, 1, &buffer.al);
}
inline Buffer::ID unqueueBuffer(Source::ID id)
{
inline Buffer::ID unqueueBuffer(Source::ID id){
Buffer::ID buffer;
alSourceUnqueueBuffers(id.al, 1, &buffer.al);
return buffer;
}
inline void clearQueue(Source::ID id)
{
inline void clearQueue(Source::ID id){
attachBuffer(id, Buffer::ID(0));
}
inline ALint getInteger(Source::ID id, ALenum prop)
{
inline ALint getInteger(Source::ID id, ALenum prop){
ALint value;
alGetSourcei(id.al, prop, &value);
return value;
}
inline ALint getProcBufferCount(Source::ID id)
{
inline ALint getProcBufferCount(Source::ID id){
return getInteger(id, AL_BUFFERS_PROCESSED);
}
inline ALenum getState(Source::ID id)
{
inline ALenum getState(Source::ID id){
return getInteger(id, AL_SOURCE_STATE);
}
inline ALfloat getSecOffset(Source::ID id)
{
inline ALfloat getSecOffset(Source::ID id){
ALfloat value;
alGetSourcef(id.al, AL_SEC_OFFSET, &value);
return value;
}
inline void setVolume(Source::ID id, float value)
{
inline void setVolume(Source::ID id, float value){
alSourcef(id.al, AL_GAIN, value);
}
inline void setPitch(Source::ID id, float value)
{
inline void setPitch(Source::ID id, float value){
alSourcef(id.al, AL_PITCH, value);
}
inline void play(Source::ID id)
{
inline void play(Source::ID id){
alSourcePlay(id.al);
}
inline void stop(Source::ID id)
{
inline void stop(Source::ID id){
alSourceStop(id.al);
}
inline void pause(Source::ID id)
{
inline void pause(Source::ID id){
alSourcePause(id.al);
}
}
}
inline uint8_t formatSampleSize(int sdlFormat)
{
inline uint8_t formatSampleSize(int sdlFormat){
switch (sdlFormat)
{
case SDL_AUDIO_U8 :
@ -215,20 +190,16 @@ inline uint8_t formatSampleSize(int sdlFormat)
return 0;
}
inline ALenum chooseALFormat(int sampleSize, int channelCount)
{
switch (sampleSize)
{
inline ALenum chooseALFormat(int sampleSize, int channelCount){
switch (sampleSize){
case 1 :
switch (channelCount)
{
switch (channelCount){
case 1 : return AL_FORMAT_MONO8;
case 2 : return AL_FORMAT_STEREO8;
}
/* falls through */
case 2 :
switch (channelCount)
{
switch (channelCount){
case 1 : return AL_FORMAT_MONO16;
case 2 : return AL_FORMAT_STEREO16;
}

View file

@ -28,8 +28,7 @@
#include <cstring>
#endif
struct ALDataSource
{
struct ALDataSource{
enum Status
{
NoError,

View file

@ -55,15 +55,13 @@
#include "gamecontrollerdb.txt.xxd"
#endif
static void
rgssThreadError(RGSSThreadData *rtData, const std::string &msg){
static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg){
rtData->rgssErrorMsg = msg;
rtData->ethread->requestTerminate();
rtData->rqTermAck.set();
}
static inline const char*
glGetStringInt(GLenum name){
static inline const char* glGetStringInt(GLenum name){
return (const char*) gl.GetString(name);
}