From 0345a873b757ddf29c33928d7144f1c5cdf36255 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Mon, 1 Jan 2024 12:27:23 -0500 Subject: [PATCH] Add get_coop_compatibility_enabled and undefine SM64COOPDX_VERSION if it's on --- autogen/convert_constants.py | 2 +- autogen/lua_definitions/functions.lua | 5 +++++ docs/lua/functions-5.md | 18 ++++++++++++++++++ docs/lua/functions.md | 1 + src/pc/lua/smlua_constants_autogen.c | 2 +- src/pc/lua/smlua_functions_autogen.c | 16 ++++++++++++++++ src/pc/lua/utils/smlua_misc_utils.c | 6 ++++++ src/pc/lua/utils/smlua_misc_utils.h | 2 ++ 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 9a85e45a..32e28b4d 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -259,7 +259,7 @@ def build_to_c(built_files): txt = 'char gSmluaConstants[] = ""\n' for line in lines: txt += '"%s\\n"\n' % line - txt += ';' + txt += '"if get_coop_compatibility_enabled() then SM64COOPDX_VERSION = nil end";' return txt ############################################################################ diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 45e48c1a..0c8650c0 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -8686,6 +8686,11 @@ function djui_set_popup_disabled_override(value) -- ... end +--- @return boolean +function get_coop_compatibility_enabled() + -- ... +end + --- @return integer function get_current_save_file_num() -- ... diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 51895995..83358a37 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -703,6 +703,24 @@
+## [get_coop_compatibility_enabled](#get_coop_compatibility_enabled) + +### Lua Example +`local booleanValue = get_coop_compatibility_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool get_coop_compatibility_enabled(void);` + +[:arrow_up_small:](#) + +
+ ## [get_current_save_file_num](#get_current_save_file_num) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index c12f90d7..254be5de 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1631,6 +1631,7 @@ - [djui_popup_create_global](functions-5.md#djui_popup_create_global) - [djui_reset_popup_disabled_override](functions-5.md#djui_reset_popup_disabled_override) - [djui_set_popup_disabled_override](functions-5.md#djui_set_popup_disabled_override) + - [get_coop_compatibility_enabled](functions-5.md#get_coop_compatibility_enabled) - [get_current_save_file_num](functions-5.md#get_current_save_file_num) - [get_date_and_time](functions-5.md#get_date_and_time) - [get_dialog_box_state](functions-5.md#get_dialog_box_state) diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 6c3eef35..b12bde78 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -4393,4 +4393,4 @@ char gSmluaConstants[] = "" "VERSION_REGION = 'US'\n" "MAX_VERSION_LENGTH = 32\n" "MAX_LOCAL_VERSION_LENGTH = 36\n" -; \ No newline at end of file +"if get_coop_compatibility_enabled() then SM64COOPDX_VERSION = nil end"; \ No newline at end of file diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 12d1adb0..a71ebaea 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -28719,6 +28719,21 @@ int smlua_func_djui_set_popup_disabled_override(lua_State* L) { return 1; } +int smlua_func_get_coop_compatibility_enabled(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_coop_compatibility_enabled", 0, top); + return 0; + } + + + lua_pushboolean(L, get_coop_compatibility_enabled()); + + return 1; +} + int smlua_func_get_current_save_file_num(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -32853,6 +32868,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_popup_create_global", smlua_func_djui_popup_create_global); smlua_bind_function(L, "djui_reset_popup_disabled_override", smlua_func_djui_reset_popup_disabled_override); smlua_bind_function(L, "djui_set_popup_disabled_override", smlua_func_djui_set_popup_disabled_override); + smlua_bind_function(L, "get_coop_compatibility_enabled", smlua_func_get_coop_compatibility_enabled); smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num); smlua_bind_function(L, "get_date_and_time", smlua_func_get_date_and_time); smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index fe589685..3cbeb50b 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -622,6 +622,12 @@ void set_override_envfx(s32 envfx) { /// +bool get_coop_compatibility_enabled(void) { + return configCoopCompatibility; +} + +/// + const char* get_os_name(void) { #if defined(_WIN32) || defined(_WIN64) return "Windows"; diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 923142b3..b2224fa5 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -153,6 +153,8 @@ struct DateTime* get_date_and_time(void); u16 get_envfx(void); void set_override_envfx(s32 envfx); +bool get_coop_compatibility_enabled(void); + const char* get_os_name(void); #endif