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( me );
if (rgssVer >= 3){
BIND_POS( bgm );
BIND_POS( bgs );
}
BIND_POS( bgm );
BIND_POS( bgs );
BIND_PLAY_STOP( se )

View file

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

View file

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

View file

@ -93,8 +93,7 @@ static void disposableBindingInit(VALUE klass){
/* Make sure we always have access to the original method, even
* 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");
}
template<class C>

View file

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

View file

@ -263,23 +263,16 @@ void fontBindingInit(){
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, DefaultSize, "default_size");
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
if (rgssVer >= 2){
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
}
if (rgssVer >= 3){
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
}
rb_define_class_method(klass, "exist?", fontDoesExist);
@ -292,12 +285,8 @@ void fontBindingInit(){
INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color");
if (rgssVer >= 2){
INIT_PROP_BIND(Font, Shadow, "shadow");
}
if (rgssVer >= 3){
INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color");
}
}

View file

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

View file

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

View file

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

View file

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