From fbf3280f09436f4bc9f9c8592cc71c499f04da47 Mon Sep 17 00:00:00 2001 From: EmeraldLockdown <86802223+EmeraldLoc@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:17:11 -0500 Subject: [PATCH] Make first param of `network_disconnect` optional --- autogen/lua_definitions/functions.lua | 2 +- docs/lua/functions-7.md | 2 +- src/pc/lua/smlua_functions_autogen.c | 11 +++++++---- src/pc/lua/utils/smlua_misc_utils.c | 2 +- src/pc/lua/utils/smlua_misc_utils.h | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index a94676ded..9984b61ce 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -11586,7 +11586,7 @@ function get_coopnet_id(localIndex) -- ... end ---- @param dcType DisconnectType +--- @param dcType? DisconnectType --- @param reason? string --- Disconnects the local player with DisconnectType `dcType` (default is DC_LEAVE) because of `reason` (optional). function network_disconnect(dcType, reason) diff --git a/docs/lua/functions-7.md b/docs/lua/functions-7.md index 8514b8376..46446ddf5 100644 --- a/docs/lua/functions-7.md +++ b/docs/lua/functions-7.md @@ -1858,7 +1858,7 @@ Disconnects the local player with DisconnectType `dcType` (default is DC_LEAVE) - None ### C Prototype -`void network_disconnect(enum DisconnectType dcType, OPTIONAL const char* reason);` +`void network_disconnect(OPTIONAL enum DisconnectType dcType, OPTIONAL const char* reason);` [:arrow_up_small:](#) diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index e47a26fab..9e0d645e8 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -34145,13 +34145,16 @@ int smlua_func_network_disconnect(lua_State* L) { if (L == NULL) { return 0; } int top = lua_gettop(L); - if (top < 1 || top > 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "network_disconnect", 1, 2, top); + if (top < 0 || top > 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "network_disconnect", 0, 2, top); return 0; } - int dcType = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_disconnect"); return 0; } + int dcType = (int) 0; + if (top >= 1) { + dcType = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_disconnect"); return 0; } + } const char* reason = (const char*) NULL; if (top >= 2) { reason = smlua_to_string(L, 2); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 3f7e53081..cab62e76d 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -525,7 +525,7 @@ const char* get_coopnet_id(UNUSED s8 localIndex) { /// -void network_disconnect(enum DisconnectType dcType, OPTIONAL const char* reason) { +void network_disconnect(OPTIONAL enum DisconnectType dcType, OPTIONAL const char* reason) { switch (dcType) { case DC_KICK: if (gNetworkType == NT_SERVER) { diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 5fce12641..28cdd528f 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -226,7 +226,7 @@ const char* get_local_discord_id(void); const char* get_coopnet_id(s8 localIndex); /* |description|Disconnects the local player with DisconnectType `dcType` (default is DC_LEAVE) because of `reason` (optional).|descriptionEnd| */ -void network_disconnect(enum DisconnectType dcType, OPTIONAL const char* reason); +void network_disconnect(OPTIONAL enum DisconnectType dcType, OPTIONAL const char* reason); /* |description|Gets the master volume level|descriptionEnd| */ f32 get_volume_master(void);