afd
This commit is contained in:
parent
c0c0e4d8ba
commit
e8f9220197
|
|
@ -117,9 +117,6 @@ DEF_AUD_PROP_I(SFX_Volume)
|
||||||
|
|
||||||
RB_METHOD(audioReset){
|
RB_METHOD(audioReset){
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[audioReset] Reseting audio\n");
|
|
||||||
#endif
|
|
||||||
shState->audio().reset();
|
shState->audio().reset();
|
||||||
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
|
||||||
|
|
@ -225,9 +225,6 @@ static VALUE rgssMainRescue(VALUE arg, VALUE exc){
|
||||||
}
|
}
|
||||||
|
|
||||||
static void processReset(){
|
static void processReset(){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[processReset] reset!\n");
|
|
||||||
#endif
|
|
||||||
shState->graphics().reset();
|
shState->graphics().reset();
|
||||||
shState->audio().reset();
|
shState->audio().reset();
|
||||||
|
|
||||||
|
|
@ -252,9 +249,6 @@ RB_METHOD(mriRgssMain){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (rb_obj_class(exc) == getRbData()->exc[Reset]){
|
if (rb_obj_class(exc) == getRbData()->exc[Reset]){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[mriRgssMain] Reset\n");
|
|
||||||
#endif
|
|
||||||
processReset();
|
processReset();
|
||||||
}else{
|
}else{
|
||||||
rb_exc_raise(exc);
|
rb_exc_raise(exc);
|
||||||
|
|
@ -266,9 +260,6 @@ RB_METHOD(mriRgssMain){
|
||||||
|
|
||||||
RB_METHOD(mriRgssStop){
|
RB_METHOD(mriRgssStop){
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[mriRgssStop] Stop\n");
|
|
||||||
#endif
|
|
||||||
while (true)
|
while (true)
|
||||||
shState->graphics().update();
|
shState->graphics().update();
|
||||||
|
|
||||||
|
|
@ -398,10 +389,6 @@ static void runRMXPScripts(BacktraceData &btData){
|
||||||
VALUE scriptName = rb_ary_entry(script, 1);
|
VALUE scriptName = rb_ary_entry(script, 1);
|
||||||
VALUE scriptString = rb_ary_entry(script, 2);
|
VALUE scriptString = rb_ary_entry(script, 2);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[runRMXPScripts] Script Name: %s\n", RSTRING_PTR(scriptName));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int result = Z_OK;
|
int result = Z_OK;
|
||||||
unsigned long bufferLen;
|
unsigned long bufferLen;
|
||||||
|
|
||||||
|
|
@ -477,8 +464,7 @@ static void showExc(VALUE exc, const BacktraceData &btData){
|
||||||
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
|
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
|
||||||
VALUE bt0 = rb_ary_entry(bt, 0);
|
VALUE bt0 = rb_ary_entry(bt, 0);
|
||||||
VALUE name = rb_class_path(rb_obj_class(exc));
|
VALUE name = rb_class_path(rb_obj_class(exc));
|
||||||
VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")",
|
VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")", bt0, exc, name);
|
||||||
bt0, exc, name);
|
|
||||||
/* omit "useless" last entry (from ruby:1:in `eval') */
|
/* omit "useless" last entry (from ruby:1:in `eval') */
|
||||||
for (long i = 1, btlen = RARRAY_LEN(bt) - 1; i < btlen; ++i)
|
for (long i = 1, btlen = RARRAY_LEN(bt) - 1; i < btlen; ++i)
|
||||||
rb_str_catf(ds, "\n\tfrom %" PRIsVALUE, rb_ary_entry(bt, i));
|
rb_str_catf(ds, "\n\tfrom %" PRIsVALUE, rb_ary_entry(bt, i));
|
||||||
|
|
@ -561,18 +547,11 @@ static void mriBindingExecute(){
|
||||||
BacktraceData btData;
|
BacktraceData btData;
|
||||||
|
|
||||||
mriBindingInit();
|
mriBindingInit();
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[mriBindingExecute] run RMXP Scripts\n");
|
|
||||||
#endif
|
|
||||||
runRMXPScripts(btData);
|
runRMXPScripts(btData);
|
||||||
|
|
||||||
VALUE exc = rb_errinfo();
|
VALUE exc = rb_errinfo();
|
||||||
if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
|
if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
|
||||||
showExc(exc, btData);
|
showExc(exc, btData);
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[mirBindingExecure] Ruby cleanup\n");
|
|
||||||
#endif
|
|
||||||
//ruby_cleanup(0);
|
|
||||||
|
|
||||||
shState->rtData().rqTermAck.set();
|
shState->rtData().rqTermAck.set();
|
||||||
}
|
}
|
||||||
|
|
@ -586,8 +565,5 @@ static void mriBindingTerminate(){
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mriBindingReset(){
|
static void mriBindingReset(){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[mriBindingReset] Binding reset...\n");
|
|
||||||
#endif
|
|
||||||
rb_raise(getRbData()->exc[Reset], " ");
|
rb_raise(getRbData()->exc[Reset], " ");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,23 +31,14 @@
|
||||||
|
|
||||||
void fileIntFreeInstance(void *inst){
|
void fileIntFreeInstance(void *inst){
|
||||||
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
|
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[fileIntFreeInstance] Closing ops\n");
|
|
||||||
#endif
|
|
||||||
SDL_CloseIO(ops);
|
SDL_CloseIO(ops);
|
||||||
}
|
}
|
||||||
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
||||||
|
|
||||||
VALUE fileIntForPath(const char *path, bool rubyExc){
|
VALUE fileIntForPath(const char *path, bool rubyExc){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[fileIntForPath] %s!\n", path);
|
|
||||||
#endif
|
|
||||||
SDL_IOStream* ops = nullptr;
|
SDL_IOStream* ops = nullptr;
|
||||||
ops = SDL_IOFromFile(path, "r");
|
ops = SDL_IOFromFile(path, "r");
|
||||||
if (!ops){
|
if (!ops){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[fileIntForPath] Failed to open file: %s\n", path);
|
|
||||||
#endif
|
|
||||||
if (rubyExc) {
|
if (rubyExc) {
|
||||||
rb_raise(rb_eIOError, "Cannot open file: %s", path);
|
rb_raise(rb_eIOError, "Cannot open file: %s", path);
|
||||||
}
|
}
|
||||||
|
|
@ -71,9 +62,6 @@ RB_METHOD(fileIntRead){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length == 0){
|
if (length == 0){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[fileIntRead] zero length\n");
|
|
||||||
#endif
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,14 +75,9 @@ RB_METHOD(fileIntRead){
|
||||||
RB_NA_METHOD(fileIntClose){
|
RB_NA_METHOD(fileIntClose){
|
||||||
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
|
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
|
||||||
if (!ops){
|
if (!ops){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[fileIntClose] Already closed or null\n");
|
|
||||||
#endif
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[fileIntClose] Closing ops\n");
|
|
||||||
#endif
|
|
||||||
SDL_CloseIO(ops);
|
SDL_CloseIO(ops);
|
||||||
setPrivateData(self, nullptr);
|
setPrivateData(self, nullptr);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
@ -118,18 +101,12 @@ VALUE load_protect(VALUE marsh_and_port) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE kernelLoadDataInt(const char *filename, bool rubyExc){
|
VALUE kernelLoadDataInt(const char *filename, bool rubyExc){
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[kernelLoadDataInt] Filename: %s\n", filename);
|
|
||||||
#endif
|
|
||||||
VALUE port = fileIntForPath(filename, rubyExc);
|
VALUE port = fileIntForPath(filename, rubyExc);
|
||||||
if (NIL_P(port)) return Qnil;
|
if (NIL_P(port)) return Qnil;
|
||||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||||
VALUE args[2] = { marsh, port };
|
VALUE args[2] = { marsh, port };
|
||||||
int state = 0;
|
int state = 0;
|
||||||
VALUE result = rb_protect(load_protect, (VALUE)args, &state);
|
VALUE result = rb_protect(load_protect, (VALUE)args, &state);
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[kernelLoadDataInt] State %d\n", state);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rb_funcallv(port, rb_intern("close"), 0, NULL);
|
rb_funcallv(port, rb_intern("close"), 0, NULL);
|
||||||
|
|
||||||
|
|
@ -152,9 +129,6 @@ RB_METHOD(kernelLoadData){
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
rb_get_args(argc, argv, "z", &filename);
|
rb_get_args(argc, argv, "z", &filename);
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[kernelLoadData] filename: %s\n", filename);
|
|
||||||
#endif
|
|
||||||
return kernelLoadDataInt(filename, true);
|
return kernelLoadDataInt(filename, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,11 +148,8 @@ RB_METHOD(kernelSaveData){
|
||||||
|
|
||||||
VALUE v[] = { obj, file };
|
VALUE v[] = { obj, file };
|
||||||
rb_funcall2(marsh, rb_intern("dump"), ARRAY_SIZE(v), v);
|
rb_funcall2(marsh, rb_intern("dump"), ARRAY_SIZE(v), v);
|
||||||
#ifdef DEBUG
|
|
||||||
printf("[kernelSaveData] Closing file %s\n", rb_str_to_str(filename));
|
|
||||||
#endif
|
|
||||||
rb_io_close(file);
|
|
||||||
|
|
||||||
|
rb_io_close(file);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue