From e780b74d1b5bdd540967a53fbdb522ae66a50b53 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:22:20 -0400 Subject: [PATCH] Properly sync BITS ferris wheel platforms --- autogen/lua_definitions/functions.lua | 4 ++++ data/behavior_data.c | 1 + data/dynos_mgr_builtin.cpp | 1 + docs/lua/functions-2.md | 18 ++++++++++++++++++ docs/lua/functions.md | 1 + src/game/behavior_actions.h | 1 + src/game/behaviors/ferris_wheel.inc.c | 11 +++++++++++ src/game/obj_behaviors_2.h | 1 + src/pc/lua/smlua_functions_autogen.c | 17 +++++++++++++++++ 9 files changed, 55 insertions(+) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 3986a6ab..4ef93ef0 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -797,6 +797,10 @@ function bhv_ferris_wheel_axle_init() -- ... end +function bhv_ferris_wheel_platform_init() + -- ... +end + function bhv_ferris_wheel_platform_update() -- ... end diff --git a/data/behavior_data.c b/data/behavior_data.c index 8dd2d314..53ec740c 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -5663,6 +5663,7 @@ const BehaviorScript bhvFerrisWheelPlatform[] = { BEGIN(OBJ_LIST_SURFACE), ID(id_bhvFerrisWheelPlatform), OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), + CALL_NATIVE(bhv_ferris_wheel_platform_init), BEGIN_LOOP(), CALL_NATIVE(bhv_ferris_wheel_platform_update), CALL_NATIVE(load_object_collision_model), diff --git a/data/dynos_mgr_builtin.cpp b/data/dynos_mgr_builtin.cpp index 96e0b20d..e4a836e3 100644 --- a/data/dynos_mgr_builtin.cpp +++ b/data/dynos_mgr_builtin.cpp @@ -1974,6 +1974,7 @@ static const void* sDynosBuiltinFuncs[] = { define_builtin(bhv_blue_coin_switch_init), define_builtin(bhv_star_number_loop), define_builtin(spawn_star_number), + define_builtin(bhv_ferris_wheel_platform_init), }; const void* DynOS_Builtin_Func_GetFromName(const char* aDataName) { diff --git a/docs/lua/functions-2.md b/docs/lua/functions-2.md index 12016f61..ea78b8e4 100644 --- a/docs/lua/functions-2.md +++ b/docs/lua/functions-2.md @@ -3526,6 +3526,24 @@
+## [bhv_ferris_wheel_platform_init](#bhv_ferris_wheel_platform_init) + +### Lua Example +`bhv_ferris_wheel_platform_init()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void bhv_ferris_wheel_platform_init(void);` + +[:arrow_up_small:](#) + +
+ ## [bhv_ferris_wheel_platform_update](#bhv_ferris_wheel_platform_update) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index a37907fa..c05e5e00 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -229,6 +229,7 @@ - [bhv_falling_pillar_init](functions-2.md#bhv_falling_pillar_init) - [bhv_falling_pillar_loop](functions-2.md#bhv_falling_pillar_loop) - [bhv_ferris_wheel_axle_init](functions-2.md#bhv_ferris_wheel_axle_init) + - [bhv_ferris_wheel_platform_init](functions-2.md#bhv_ferris_wheel_platform_init) - [bhv_ferris_wheel_platform_update](functions-2.md#bhv_ferris_wheel_platform_update) - [bhv_fire_piranha_plant_init](functions-2.md#bhv_fire_piranha_plant_init) - [bhv_fire_piranha_plant_update](functions-2.md#bhv_fire_piranha_plant_update) diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h index 305e929b..05adef9e 100644 --- a/src/game/behavior_actions.h +++ b/src/game/behavior_actions.h @@ -486,6 +486,7 @@ void bhv_track_ball_update(void); void bhv_seesaw_platform_init(void); void bhv_seesaw_platform_update(void); void bhv_ferris_wheel_axle_init(void); +void bhv_ferris_wheel_platform_init(void); void bhv_ferris_wheel_platform_update(void); void bhv_water_bomb_spawner_update(void); void bhv_water_bomb_update(void); diff --git a/src/game/behaviors/ferris_wheel.inc.c b/src/game/behaviors/ferris_wheel.inc.c index 375a9a73..30928da0 100644 --- a/src/game/behaviors/ferris_wheel.inc.c +++ b/src/game/behaviors/ferris_wheel.inc.c @@ -56,6 +56,17 @@ void bhv_ferris_wheel_axle_init(void) { } } +void bhv_ferris_wheel_platform_init(void) { + struct SyncObject* so = sync_object_init(o, 2000.0f); + if (so) { + so->hasStandardFields = FALSE; + so->maxUpdateRate = 5.0f; + sync_object_init_field(o, &o->oPosX); + sync_object_init_field(o, &o->oPosY); + sync_object_init_field(o, &o->oPosZ); + } +} + /** * Update function for bhvFerrisWheelPlatform. * Position self relative to parent using the parent's roll. diff --git a/src/game/obj_behaviors_2.h b/src/game/obj_behaviors_2.h index 1b7ebffa..35f4101e 100644 --- a/src/game/obj_behaviors_2.h +++ b/src/game/obj_behaviors_2.h @@ -53,6 +53,7 @@ void bhv_track_ball_update(void); void bhv_seesaw_platform_init(void); void bhv_seesaw_platform_update(void); void bhv_ferris_wheel_axle_init(void); +void bhv_ferris_wheel_platform_init(void); void bhv_ferris_wheel_platform_update(void); void bhv_water_bomb_spawner_update(void); void bhv_water_bomb_update(void); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 2d63e897..f6ebb08d 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -3230,6 +3230,22 @@ int smlua_func_bhv_ferris_wheel_axle_init(UNUSED lua_State* L) { return 1; } +int smlua_func_bhv_ferris_wheel_platform_init(UNUSED lua_State* L) { + if (!gCurrentObject) { return 0; } + 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", "bhv_ferris_wheel_platform_init", 0, top); + return 0; + } + + + bhv_ferris_wheel_platform_init(); + + return 1; +} + int smlua_func_bhv_ferris_wheel_platform_update(UNUSED lua_State* L) { if (!gCurrentObject) { return 0; } if (L == NULL) { return 0; } @@ -32826,6 +32842,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "bhv_falling_pillar_init", smlua_func_bhv_falling_pillar_init); smlua_bind_function(L, "bhv_falling_pillar_loop", smlua_func_bhv_falling_pillar_loop); smlua_bind_function(L, "bhv_ferris_wheel_axle_init", smlua_func_bhv_ferris_wheel_axle_init); + smlua_bind_function(L, "bhv_ferris_wheel_platform_init", smlua_func_bhv_ferris_wheel_platform_init); smlua_bind_function(L, "bhv_ferris_wheel_platform_update", smlua_func_bhv_ferris_wheel_platform_update); smlua_bind_function(L, "bhv_fire_piranha_plant_init", smlua_func_bhv_fire_piranha_plant_init); smlua_bind_function(L, "bhv_fire_piranha_plant_update", smlua_func_bhv_fire_piranha_plant_update);