Make first param of network_disconnect optional

This commit is contained in:
EmeraldLockdown 2026-03-10 19:17:11 -05:00
parent f82637b8ec
commit fbf3280f09
5 changed files with 11 additions and 8 deletions

View file

@ -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)

View file

@ -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:](#)

View file

@ -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);

View file

@ -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) {

View file

@ -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);