diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index dc50843d5..374382265 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -77,7 +77,8 @@ in_files = [ "src/game/first_person_cam.h", "src/engine/behavior_script.h", "src/audio/seqplayer.h", - "src/engine/lighting_engine.h" + "src/engine/lighting_engine.h", + "src/pc/network/sync_object.h" ] override_allowed_functions = { @@ -95,7 +96,8 @@ override_allowed_functions = { "src/game/area.h": [ "get_mario_spawn_type", "area_get_warp_node", "area_get_any_warp_node", "play_transition" ], "src/engine/level_script.h": [ "area_create_warp_node" ], "src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ], - "src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ] + "src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ], + "src/pc/network/sync_object.h": [ "sync_object_is_initialized", "sync_object_is_owned_locally" ] } override_disallowed_functions = { diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index ac894bdb8..6503fc5e8 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -11671,6 +11671,20 @@ function surface_has_force(surfaceType) -- ... end +--- @param syncId integer +--- @return boolean +--- Checks if a sync object is initialized using a `syncId` +function sync_object_is_initialized(syncId) + -- ... +end + +--- @param syncId integer +--- @return boolean +--- Checks if a sync object is owned locally using a `syncId` +function sync_object_is_owned_locally(syncId) + -- ... +end + --- @alias Pointer_integer integer --- @alias Pointer_BehaviorScript BehaviorScript --- @alias Pointer_number number diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index f702e4fc3..75016525c 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -7115,6 +7115,58 @@ Checks if a surface has force
+--- +# functions from sync_object.h + +
+ + +## [sync_object_is_initialized](#sync_object_is_initialized) + +### Description +Checks if a sync object is initialized using a `syncId` + +### Lua Example +`local booleanValue = sync_object_is_initialized(syncId)` + +### Parameters +| Field | Type | +| ----- | ---- | +| syncId | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool sync_object_is_initialized(u32 syncId);` + +[:arrow_up_small:](#) + +
+ +## [sync_object_is_owned_locally](#sync_object_is_owned_locally) + +### Description +Checks if a sync object is owned locally using a `syncId` + +### Lua Example +`local booleanValue = sync_object_is_owned_locally(syncId)` + +### Parameters +| Field | Type | +| ----- | ---- | +| syncId | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool sync_object_is_owned_locally(u32 syncId);` + +[:arrow_up_small:](#) + +
+ --- [< prev](functions-5.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [5](functions-5.md) | 6] diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 205c36738..1f4f1fbd7 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -2108,6 +2108,12 @@
+- sync_object.h + - [sync_object_is_initialized](functions-6.md#sync_object_is_initialized) + - [sync_object_is_owned_locally](functions-6.md#sync_object_is_owned_locally) + +
+ --- # manually written functions diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 9be290f84..8728d4f3d 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -52,6 +52,7 @@ #include "src/engine/behavior_script.h" #include "src/audio/seqplayer.h" #include "src/engine/lighting_engine.h" +#include "src/pc/network/sync_object.h" /////////////// @@ -34925,6 +34926,44 @@ int smlua_func_surface_has_force(lua_State* L) { return 1; } + /////////////////// + // sync_object.h // +/////////////////// + +int smlua_func_sync_object_is_initialized(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "sync_object_is_initialized", 1, top); + return 0; + } + + u32 syncId = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sync_object_is_initialized"); return 0; } + + lua_pushboolean(L, sync_object_is_initialized(syncId)); + + return 1; +} + +int smlua_func_sync_object_is_owned_locally(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "sync_object_is_owned_locally", 1, top); + return 0; + } + + u32 syncId = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sync_object_is_owned_locally"); return 0; } + + lua_pushboolean(L, sync_object_is_owned_locally(syncId)); + + return 1; +} + void smlua_bind_functions_autogen(void) { @@ -36921,4 +36960,8 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "obj_get_surface_from_index", smlua_func_obj_get_surface_from_index); smlua_bind_function(L, "surface_has_force", smlua_func_surface_has_force); + // sync_object.h + smlua_bind_function(L, "sync_object_is_initialized", smlua_func_sync_object_is_initialized); + smlua_bind_function(L, "sync_object_is_owned_locally", smlua_func_sync_object_is_owned_locally); + } diff --git a/src/pc/network/sync_object.h b/src/pc/network/sync_object.h index 1997d3a12..ad46afe26 100644 --- a/src/pc/network/sync_object.h +++ b/src/pc/network/sync_object.h @@ -60,7 +60,9 @@ struct SyncObject* sync_object_get(u32 syncId); struct SyncObject* sync_object_get_first(void); struct SyncObject* sync_object_get_next(void); struct Object* sync_object_get_object(u32 syncId); +/* |description|Checks if a sync object is initialized using a `syncId`|descriptionEnd| */ bool sync_object_is_initialized(u32 syncId); +/* |description|Checks if a sync object is owned locally using a `syncId`|descriptionEnd| */ bool sync_object_is_owned_locally(u32 syncId); struct Packet* sync_object_get_last_reliable_packet(u32 syncId);