Code cleanup

This commit is contained in:
DepressedTWM 2026-05-18 08:37:31 +04:00
parent 5fd7991db2
commit e1ced21b34
10 changed files with 22 additions and 86 deletions

View File

@ -154,10 +154,8 @@ void audioBindingInit(){
BIND_PLAY_STOP_FADE( bgs ); BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me ); BIND_PLAY_STOP_FADE( me );
if (rgssVer >= 3){
BIND_POS( bgm ); BIND_POS( bgm );
BIND_POS( bgs ); BIND_POS( bgs );
}
BIND_PLAY_STOP( se ) BIND_PLAY_STOP( se )

View File

@ -75,9 +75,6 @@ void fileIntBindingInit();
void journalBindingInit(); void journalBindingInit();
void wallpaperBindingInit(); void wallpaperBindingInit();
#ifdef __linux__
void wallpaperBindingTerminate();
#endif
void nikoBindingInit(); void nikoBindingInit();
void oneshotBindingInit(); void oneshotBindingInit();
void SunshineBindingInit(); void SunshineBindingInit();
@ -104,16 +101,12 @@ static void mriBindingInit(){
spriteBindingInit(); spriteBindingInit();
viewportBindingInit(); viewportBindingInit();
planeBindingInit(); planeBindingInit();
windowBindingInit(); windowBindingInit();
tilemapBindingInit(); tilemapBindingInit();
TimeBindingInit(); TimeBindingInit();
inputBindingInit(); inputBindingInit();
audioBindingInit(); audioBindingInit();
graphicsBindingInit(); graphicsBindingInit();
fileIntBindingInit(); fileIntBindingInit();
journalBindingInit(); journalBindingInit();
wallpaperBindingInit(); wallpaperBindingInit();
@ -126,21 +119,16 @@ static void mriBindingInit(){
printf("[mriBindingInit] Done\n"); printf("[mriBindingInit] Done\n");
printf("[mriBindingInit] RGSS version: %i\n", rgssVer); printf("[mriBindingInit] RGSS version: %i\n", rgssVer);
#endif #endif
if (rgssVer >= 3){
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain); _rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop); _rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint); _rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP); _rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1")); rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1"));
}else{
_rb_define_module_function(rb_mKernel, "print", mriPrint); _rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP); _rb_define_module_function(rb_mKernel, "p", mriP);
rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller"); rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller); _rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
}
rb_eval_string(module_rpg1); rb_eval_string(module_rpg1);
@ -153,7 +141,6 @@ static void mriBindingInit(){
/* Load global constants */ /* Load global constants */
rb_gv_set("MKXP", Qtrue); rb_gv_set("MKXP", Qtrue);
#ifdef DEBUG
VALUE debug = rb_bool_new(shState->config().editor.debug); VALUE debug = rb_bool_new(shState->config().editor.debug);
if (rgssVer == 1) if (rgssVer == 1)
rb_gv_set("DEBUG", debug); rb_gv_set("DEBUG", debug);
@ -161,15 +148,10 @@ static void mriBindingInit(){
rb_gv_set("TEST", debug); rb_gv_set("TEST", debug);
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest)); rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
#endif
} }
static void showMsg(const std::string &msg){ static void showMsg(const std::string &msg){
#ifdef NDEBUG
shState->eThread().showMessageBox(msg.c_str()); shState->eThread().showMessageBox(msg.c_str());
#else
Debug() << "[DEBUG] " + msg.c_str();
#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){
@ -205,7 +187,6 @@ RB_METHOD(mriP){
RB_METHOD(mkxpDataDirectory){ RB_METHOD(mkxpDataDirectory){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const std::string &path = shState->config().customDataPath; const std::string &path = shState->config().customDataPath;
const char *s = path.empty() ? "." : path.c_str(); const char *s = path.empty() ? "." : path.c_str();
@ -214,7 +195,6 @@ RB_METHOD(mkxpDataDirectory){
RB_METHOD(mkxpPuts){ RB_METHOD(mkxpPuts){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *str; const char *str;
rb_get_args(argc, argv, "z", &str RB_ARG_END); rb_get_args(argc, argv, "z", &str RB_ARG_END);
@ -234,7 +214,6 @@ RB_METHOD(mkxpRawKeyStates){
RB_METHOD(mkxpMouseInWindow){ RB_METHOD(mkxpMouseInWindow){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_bool_new(EventThread::mouseState.inWindow); return rb_bool_new(EventThread::mouseState.inWindow);
} }
@ -245,7 +224,6 @@ static VALUE rgssMainCb(VALUE block){
static VALUE rgssMainRescue(VALUE arg, VALUE exc){ static VALUE rgssMainRescue(VALUE arg, VALUE exc){
VALUE *excRet = (VALUE*) arg; VALUE *excRet = (VALUE*) arg;
*excRet = exc; *excRet = exc;
return Qnil; return Qnil;
@ -406,11 +384,7 @@ static void runRMXPScripts(BacktraceData &btData){
} }
/* Set the debug flag */ /* Set the debug flag */
#ifdef DEBUG
rb_gv_set("$debug", conf.debugMode ? Qtrue : Qfalse); rb_gv_set("$debug", conf.debugMode ? Qtrue : Qfalse);
#else
rb_gv_set("$debug", Qfalse);
#endif
rb_gv_set("$RGSS_SCRIPTS", scriptArray); rb_gv_set("$RGSS_SCRIPTS", scriptArray);
@ -460,7 +434,6 @@ static void runRMXPScripts(BacktraceData &btData){
break; break;
} }
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str())); rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
} }
@ -510,7 +483,6 @@ 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') */
@ -589,7 +561,6 @@ static void mriBindingExecute(){
rb_ary_push(lpaths, pathv); rb_ary_push(lpaths, pathv);
} }
} }
RbData rbData; RbData rbData;
shState->setBindingData(&rbData); shState->setBindingData(&rbData);
BacktraceData btData; BacktraceData btData;
@ -625,4 +596,3 @@ static void mriBindingReset(){
#endif #endif
rb_raise(getRbData()->exc[Reset], " "); rb_raise(getRbData()->exc[Reset], " ");
} }

View File

@ -412,13 +412,10 @@ void bitmapBindingInit(){
_rb_define_method(klass, "hue_change", bitmapHueChange); _rb_define_method(klass, "hue_change", bitmapHueChange);
_rb_define_method(klass, "draw_text", bitmapDrawText); _rb_define_method(klass, "draw_text", bitmapDrawText);
_rb_define_method(klass, "text_size", bitmapTextSize); _rb_define_method(klass, "text_size", bitmapTextSize);
if (rgssVer >= 2){
_rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect); _rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect);
_rb_define_method(klass, "clear_rect", bitmapClearRect); _rb_define_method(klass, "clear_rect", bitmapClearRect);
_rb_define_method(klass, "blur", bitmapBlur); _rb_define_method(klass, "blur", bitmapBlur);
_rb_define_method(klass, "radial_blur", bitmapRadialBlur); _rb_define_method(klass, "radial_blur", bitmapRadialBlur);
}
INIT_PROP_BIND(Bitmap, Font, "font"); INIT_PROP_BIND(Bitmap, Font, "font");
} }

View File

@ -93,7 +93,6 @@ static void disposableBindingInit(VALUE klass){
/* Make sure we always have access to the original method, even /* Make sure we always have access to the original method, even
* if it is overridden by user scripts */ * if it is overridden by user scripts */
if (rgssVer == 1)
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose"); rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
} }

View File

@ -97,7 +97,6 @@ RB_NA_METHOD(fileIntClose){
#endif #endif
SDL_CloseIO(ops); SDL_CloseIO(ops);
setPrivateData(self, nullptr); setPrivateData(self, nullptr);
return Qnil; return Qnil;
} }
RB_NA_METHOD(fileIntGetByte){ RB_NA_METHOD(fileIntGetByte){

View File

@ -263,7 +263,6 @@ void fontBindingInit(){
rb_iv_set(klass, "default_name", defNamesObj); rb_iv_set(klass, "default_name", defNamesObj);
if (rgssVer >= 3)
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType); wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name"); INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
@ -271,15 +270,9 @@ void fontBindingInit(){
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold"); INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic"); INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color"); INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
if (rgssVer >= 2){
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow"); INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
}
if (rgssVer >= 3){
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline"); INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color"); INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
}
rb_define_class_method(klass, "exist?", fontDoesExist); rb_define_class_method(klass, "exist?", fontDoesExist);
@ -292,12 +285,8 @@ void fontBindingInit(){
INIT_PROP_BIND(Font, Italic, "italic"); INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color"); INIT_PROP_BIND(Font, Color, "color");
if (rgssVer >= 2){
INIT_PROP_BIND(Font, Shadow, "shadow"); INIT_PROP_BIND(Font, Shadow, "shadow");
}
if (rgssVer >= 3){
INIT_PROP_BIND(Font, Outline, "outline"); INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color"); INIT_PROP_BIND(Font, OutColor, "out_color");
}
} }

View File

@ -219,9 +219,7 @@ void graphicsBindingInit(){
INIT_GRA_PROP_BIND( Brightness, "brightness" ); INIT_GRA_PROP_BIND( Brightness, "brightness" );
if (rgssVer >= 3){
_rb_define_module_function(module, "play_movie", graphicsPlayMovie); _rb_define_module_function(module, "play_movie", graphicsPlayMovie);
}
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" ); INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" ); INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );

View File

@ -56,56 +56,45 @@ static int getButtonArg(int argc, VALUE *argv){
RB_METHOD(inputPress){ RB_METHOD(inputPress){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv); int num = getButtonArg(argc, argv);
return rb_bool_new(shState->input().isPressed(num)); return rb_bool_new(shState->input().isPressed(num));
} }
RB_METHOD(inputTrigger){ RB_METHOD(inputTrigger){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv); int num = getButtonArg(argc, argv);
return rb_bool_new(shState->input().isTriggered(num)); return rb_bool_new(shState->input().isTriggered(num));
} }
RB_METHOD(inputRepeat){ RB_METHOD(inputRepeat){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv); int num = getButtonArg(argc, argv);
return rb_bool_new(shState->input().isRepeated(num)); return rb_bool_new(shState->input().isRepeated(num));
} }
RB_METHOD(inputDir4){ RB_METHOD(inputDir4){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().dir4Value()); return rb_fix_new(shState->input().dir4Value());
} }
RB_METHOD(inputDir8){ RB_METHOD(inputDir8){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().dir8Value()); return rb_fix_new(shState->input().dir8Value());
} }
/* Non-standard extensions */ /* Non-standard extensions */
RB_METHOD(inputMouseX){ RB_METHOD(inputMouseX){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().mouseX()); return rb_fix_new(shState->input().mouseX());
} }
RB_METHOD(inputMouseY){ RB_METHOD(inputMouseY){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().mouseY()); return rb_fix_new(shState->input().mouseY());
} }
RB_METHOD(inputQuit){ RB_METHOD(inputQuit){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_bool_new(shState->input().hasQuit()); return rb_bool_new(shState->input().hasQuit());
} }

View File

@ -27,8 +27,7 @@
#include "exception.h" #include "exception.h"
template<class C> template<class C>
static VALUE static VALUE serializableDump(int, VALUE *, VALUE self){
serializableDump(int, VALUE *, VALUE self){
Serializable *s = getPrivateData<C>(self); Serializable *s = getPrivateData<C>(self);
int dataSize = s->serialSize(); int dataSize = s->serialSize();

View File

@ -120,7 +120,6 @@ void spriteBindingInit(){
INIT_PROP_BIND( Sprite, Tone, "tone" ); INIT_PROP_BIND( Sprite, Tone, "tone" );
INIT_PROP_BIND( Sprite, Obscured, "obscured" ); INIT_PROP_BIND( Sprite, Obscured, "obscured" );
if (rgssVer >= 2){
_rb_define_method(klass, "width", spriteWidth); _rb_define_method(klass, "width", spriteWidth);
_rb_define_method(klass, "height", spriteHeight); _rb_define_method(klass, "height", spriteHeight);
@ -130,5 +129,4 @@ void spriteBindingInit(){
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" ); INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" ); INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" ); INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
}
} }