From fe316a9a08920eb9487aede9545005f16927bdfa Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:53:54 -0500 Subject: [PATCH] Document some more files (69.61%) --- autogen/lua_definitions/functions.lua | 116 +++++++++++++---------- docs/lua/functions-4.md | 130 +++++++++++++++++++------- src/game/mario_misc.c | 48 +++++----- src/game/mario_misc.h | 6 +- src/game/mario_step.c | 2 +- src/game/mario_step.h | 29 ++++-- src/pc/lua/smlua_functions_autogen.c | 46 ++++----- src/pc/network/network_utils.c | 2 +- src/pc/network/network_utils.h | 7 ++ 9 files changed, 248 insertions(+), 138 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 0a1975034..097624b4b 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -5768,23 +5768,28 @@ function set_swimming_at_surface_particles(m, particleFlag) -- ... end +--- Behavior init function for NPC Toad function bhv_toad_message_init() -- ... end +--- Behavior loop function for NPC Toad function bhv_toad_message_loop() -- ... end +--- Behavior init function for Star Door unlock object function bhv_unlock_door_star_init() -- ... end +--- Behavior loop function for Star Door unlock object function bhv_unlock_door_star_loop() -- ... end --- @return number +--- Always returns zero. May have been originally used for beta trampolines function get_additive_y_vel_for_jumps() -- ... end @@ -5800,65 +5805,75 @@ function init_bully_collision_data(data, posX, posZ, forwardVel, yaw, conversion -- ... end ---- @param arg0 MarioState ---- @param arg1 integer -function mario_bonk_reflection(arg0, arg1) - -- ... -end - ---- @param arg0 MarioState ---- @param arg1 integer ---- @param arg2 integer ---- @return integer -function mario_push_off_steep_floor(arg0, arg1, arg2) - -- ... -end - ---- @param arg0 MarioState ---- @return integer -function mario_update_moving_sand(arg0) - -- ... -end - ---- @param arg0 MarioState ---- @param arg1 number ---- @return integer -function mario_update_quicksand(arg0, arg1) - -- ... -end - ---- @param arg0 MarioState ---- @return integer -function mario_update_windy_ground(arg0) - -- ... -end - ---- @param arg0 MarioState ---- @param arg1 integer ---- @return integer -function perform_air_step(arg0, arg1) - -- ... -end - ---- @param arg0 MarioState ---- @return integer -function perform_ground_step(arg0) +--- @param m MarioState +--- @param negateSpeed integer +--- Reflects Mario off a wall if he is colliding with one and flips forward velocity if `negateSpeed` is TRUE +function mario_bonk_reflection(m, negateSpeed) -- ... end --- @param m MarioState +--- @param action integer +--- @param actionArg integer +--- @return integer +--- Pushes Mario off a steep floor and sets his action to `action` with `actionArg` +function mario_push_off_steep_floor(m, action, actionArg) + -- ... +end + +--- @param m MarioState +--- @return integer +--- Pushes Mario in the direction of the quicksand based on the floor surface +function mario_update_moving_sand(m) + -- ... +end + +--- @param m MarioState +--- @param sinkingSpeed number +--- @return integer +--- Updates Mario's state in quicksand, sinks him at `sinkingSpeed` if he's in non instant quicksand +function mario_update_quicksand(m, sinkingSpeed) + -- ... +end + +--- @param m MarioState +--- @return integer +--- Pushes Mario in the direction of the wind based on the floor surface +function mario_update_windy_ground(m) + -- ... +end + +--- @param m MarioState +--- @param stepArg integer +--- @return integer +--- Performs a full Mario air physics step (4 substeps) and returns an `AIR_STEP_*` result +function perform_air_step(m, stepArg) + -- ... +end + +--- @param m MarioState +--- @return integer +--- Performs a full Mario ground physics step (4 substeps) and returns an `GROUND_STEP_*` result +function perform_ground_step(m) + -- ... +end + +--- @param m MarioState +--- Sets Mario's velocity to his forward velocity multiplied by the cosine and sine of his pitch and yaw function set_vel_from_pitch_and_yaw(m) -- ... end ---- @param arg0 MarioState +--- @param m MarioState --- @return integer -function stationary_ground_step(arg0) +--- Performs a full Mario stationary physics step (4 substeps) and returns an `GROUND_STEP_*` result +function stationary_ground_step(m) -- ... end ---- @param arg0 MarioState -function stop_and_set_height_to_floor(arg0) +--- @param m MarioState +--- Sets all of Mario's velocity variables to 0 and sets his Y position to the floor height +function stop_and_set_height_to_floor(m) -- ... end @@ -6420,40 +6435,47 @@ function network_player_set_override_palette_color(np, part, color) end --- @return boolean +--- Checks if the game can currently be paused in singleplayer function network_check_singleplayer_pause() -- ... end --- @param localIndex integer --- @return string +--- Gets a Discord ID corresponding to the network player with `localIndex` function network_discord_id_from_local_index(localIndex) -- ... end --- @param localIndex integer --- @return string +--- Gets the DJUI hex color code string for the player corresponding to `localIndex`'s cap color function network_get_player_text_color_string(localIndex) -- ... end --- @param localIndex integer --- @return integer +--- Gets a player's global index from their local index function network_global_index_from_local(localIndex) -- ... end --- @return boolean +--- Checks if you are a moderator in the current lobby function network_is_moderator() -- ... end --- @return boolean +--- Checks if you are hosting the current lobby, this value doesn't change function network_is_server() -- ... end --- @param globalIndex integer --- @return integer +--- Gets a player's local index from their global index function network_local_index_from_global(globalIndex) -- ... end diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 752b567f2..70666691a 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -2113,6 +2113,9 @@ ## [bhv_toad_message_init](#bhv_toad_message_init) +### Description +Behavior init function for NPC Toad + ### Lua Example `bhv_toad_message_init()` @@ -2131,6 +2134,9 @@ ## [bhv_toad_message_loop](#bhv_toad_message_loop) +### Description +Behavior loop function for NPC Toad + ### Lua Example `bhv_toad_message_loop()` @@ -2149,6 +2155,9 @@ ## [bhv_unlock_door_star_init](#bhv_unlock_door_star_init) +### Description +Behavior init function for Star Door unlock object + ### Lua Example `bhv_unlock_door_star_init()` @@ -2167,6 +2176,9 @@ ## [bhv_unlock_door_star_loop](#bhv_unlock_door_star_loop) +### Description +Behavior loop function for Star Door unlock object + ### Lua Example `bhv_unlock_door_star_loop()` @@ -2191,6 +2203,9 @@ ## [get_additive_y_vel_for_jumps](#get_additive_y_vel_for_jumps) +### Description +Always returns zero. May have been originally used for beta trampolines + ### Lua Example `local numberValue = get_additive_y_vel_for_jumps()` @@ -2235,20 +2250,23 @@ ## [mario_bonk_reflection](#mario_bonk_reflection) +### Description +Reflects Mario off a wall if he is colliding with one and flips forward velocity if `negateSpeed` is TRUE + ### Lua Example -`mario_bonk_reflection(arg0, arg1)` +`mario_bonk_reflection(m, negateSpeed)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | -| arg1 | `integer` | +| m | [MarioState](structs.md#MarioState) | +| negateSpeed | `integer` | ### Returns - None ### C Prototype -`void mario_bonk_reflection(struct MarioState *, u32);` +`void mario_bonk_reflection(struct MarioState *m, u8 negateSpeed);` [:arrow_up_small:](#) @@ -2256,21 +2274,24 @@ ## [mario_push_off_steep_floor](#mario_push_off_steep_floor) +### Description +Pushes Mario off a steep floor and sets his action to `action` with `actionArg` + ### Lua Example -`local integerValue = mario_push_off_steep_floor(arg0, arg1, arg2)` +`local integerValue = mario_push_off_steep_floor(m, action, actionArg)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | -| arg1 | `integer` | -| arg2 | `integer` | +| m | [MarioState](structs.md#MarioState) | +| action | `integer` | +| actionArg | `integer` | ### Returns - `integer` ### C Prototype -`u32 mario_push_off_steep_floor(struct MarioState *, u32, u32);` +`u32 mario_push_off_steep_floor(struct MarioState *m, u32 action, u32 actionArg);` [:arrow_up_small:](#) @@ -2278,19 +2299,22 @@ ## [mario_update_moving_sand](#mario_update_moving_sand) +### Description +Pushes Mario in the direction of the quicksand based on the floor surface + ### Lua Example -`local integerValue = mario_update_moving_sand(arg0)` +`local integerValue = mario_update_moving_sand(m)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | +| m | [MarioState](structs.md#MarioState) | ### Returns - `integer` ### C Prototype -`u32 mario_update_moving_sand(struct MarioState *);` +`u32 mario_update_moving_sand(struct MarioState *m);` [:arrow_up_small:](#) @@ -2298,20 +2322,23 @@ ## [mario_update_quicksand](#mario_update_quicksand) +### Description +Updates Mario's state in quicksand, sinks him at `sinkingSpeed` if he's in non instant quicksand + ### Lua Example -`local integerValue = mario_update_quicksand(arg0, arg1)` +`local integerValue = mario_update_quicksand(m, sinkingSpeed)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | -| arg1 | `number` | +| m | [MarioState](structs.md#MarioState) | +| sinkingSpeed | `number` | ### Returns - `integer` ### C Prototype -`u32 mario_update_quicksand(struct MarioState *, f32);` +`u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed);` [:arrow_up_small:](#) @@ -2319,19 +2346,22 @@ ## [mario_update_windy_ground](#mario_update_windy_ground) +### Description +Pushes Mario in the direction of the wind based on the floor surface + ### Lua Example -`local integerValue = mario_update_windy_ground(arg0)` +`local integerValue = mario_update_windy_ground(m)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | +| m | [MarioState](structs.md#MarioState) | ### Returns - `integer` ### C Prototype -`u32 mario_update_windy_ground(struct MarioState *);` +`u32 mario_update_windy_ground(struct MarioState *m);` [:arrow_up_small:](#) @@ -2339,20 +2369,23 @@ ## [perform_air_step](#perform_air_step) +### Description +Performs a full Mario air physics step (4 substeps) and returns an `AIR_STEP_*` result + ### Lua Example -`local integerValue = perform_air_step(arg0, arg1)` +`local integerValue = perform_air_step(m, stepArg)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | -| arg1 | `integer` | +| m | [MarioState](structs.md#MarioState) | +| stepArg | `integer` | ### Returns - `integer` ### C Prototype -`s32 perform_air_step(struct MarioState *, u32);` +`s32 perform_air_step(struct MarioState *m, u32 stepArg);` [:arrow_up_small:](#) @@ -2360,19 +2393,22 @@ ## [perform_ground_step](#perform_ground_step) +### Description +Performs a full Mario ground physics step (4 substeps) and returns an `GROUND_STEP_*` result + ### Lua Example -`local integerValue = perform_ground_step(arg0)` +`local integerValue = perform_ground_step(m)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | +| m | [MarioState](structs.md#MarioState) | ### Returns - `integer` ### C Prototype -`s32 perform_ground_step(struct MarioState *);` +`s32 perform_ground_step(struct MarioState *m);` [:arrow_up_small:](#) @@ -2380,6 +2416,9 @@ ## [set_vel_from_pitch_and_yaw](#set_vel_from_pitch_and_yaw) +### Description +Sets Mario's velocity to his forward velocity multiplied by the cosine and sine of his pitch and yaw + ### Lua Example `set_vel_from_pitch_and_yaw(m)` @@ -2400,19 +2439,22 @@ ## [stationary_ground_step](#stationary_ground_step) +### Description +Performs a full Mario stationary physics step (4 substeps) and returns an `GROUND_STEP_*` result + ### Lua Example -`local integerValue = stationary_ground_step(arg0)` +`local integerValue = stationary_ground_step(m)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | +| m | [MarioState](structs.md#MarioState) | ### Returns - `integer` ### C Prototype -`s32 stationary_ground_step(struct MarioState *);` +`s32 stationary_ground_step(struct MarioState *m);` [:arrow_up_small:](#) @@ -2420,19 +2462,22 @@ ## [stop_and_set_height_to_floor](#stop_and_set_height_to_floor) +### Description +Sets all of Mario's velocity variables to 0 and sets his Y position to the floor height + ### Lua Example -`stop_and_set_height_to_floor(arg0)` +`stop_and_set_height_to_floor(m)` ### Parameters | Field | Type | | ----- | ---- | -| arg0 | [MarioState](structs.md#MarioState) | +| m | [MarioState](structs.md#MarioState) | ### Returns - None ### C Prototype -`void stop_and_set_height_to_floor(struct MarioState *);` +`void stop_and_set_height_to_floor(struct MarioState *m);` [:arrow_up_small:](#) @@ -4117,6 +4162,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_check_singleplayer_pause](#network_check_singleplayer_pause) +### Description +Checks if the game can currently be paused in singleplayer + ### Lua Example `local booleanValue = network_check_singleplayer_pause()` @@ -4135,6 +4183,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_discord_id_from_local_index](#network_discord_id_from_local_index) +### Description +Gets a Discord ID corresponding to the network player with `localIndex` + ### Lua Example `local stringValue = network_discord_id_from_local_index(localIndex)` @@ -4155,6 +4206,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_get_player_text_color_string](#network_get_player_text_color_string) +### Description +Gets the DJUI hex color code string for the player corresponding to `localIndex`'s cap color + ### Lua Example `local stringValue = network_get_player_text_color_string(localIndex)` @@ -4175,6 +4229,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_global_index_from_local](#network_global_index_from_local) +### Description +Gets a player's global index from their local index + ### Lua Example `local integerValue = network_global_index_from_local(localIndex)` @@ -4195,6 +4252,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_is_moderator](#network_is_moderator) +### Description +Checks if you are a moderator in the current lobby + ### Lua Example `local booleanValue = network_is_moderator()` @@ -4213,6 +4273,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_is_server](#network_is_server) +### Description +Checks if you are hosting the current lobby, this value doesn't change + ### Lua Example `local booleanValue = network_is_server()` @@ -4231,6 +4294,9 @@ Saves a `key` corresponding to a float `value` to mod storage ## [network_local_index_from_global](#network_local_index_from_global) +### Description +Gets a player's local index from their global index + ### Lua Example `local integerValue = network_local_index_from_global(globalIndex)` diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index bbd022e37..c6452d245 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -166,30 +166,6 @@ static void toad_message_fading(void) { } } -void bhv_toad_message_loop(void) { - if (!gCurrentObject) { return; } - if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) { - gCurrentObject->oInteractionSubtype = 0; - switch (gCurrentObject->oToadMessageState) { - case TOAD_MESSAGE_FADED: - toad_message_faded(); - break; - case TOAD_MESSAGE_OPAQUE: - toad_message_opaque(); - break; - case TOAD_MESSAGE_OPACIFYING: - toad_message_opacifying(); - break; - case TOAD_MESSAGE_FADING: - toad_message_fading(); - break; - case TOAD_MESSAGE_TALKING: - toad_message_talking(); - break; - } - } -} - void bhv_toad_message_init(void) { if (!gCurrentObject) { return; } s32 saveFlags = save_file_get_flags(); @@ -224,6 +200,30 @@ void bhv_toad_message_init(void) { } } +void bhv_toad_message_loop(void) { + if (!gCurrentObject) { return; } + if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) { + gCurrentObject->oInteractionSubtype = 0; + switch (gCurrentObject->oToadMessageState) { + case TOAD_MESSAGE_FADED: + toad_message_faded(); + break; + case TOAD_MESSAGE_OPAQUE: + toad_message_opaque(); + break; + case TOAD_MESSAGE_OPACIFYING: + toad_message_opacifying(); + break; + case TOAD_MESSAGE_FADING: + toad_message_fading(); + break; + case TOAD_MESSAGE_TALKING: + toad_message_talking(); + break; + } + } +} + static void star_door_unlock_spawn_particles(s16 angleOffset) { if (!gCurrentObject) { return; } struct Object *sparkleParticle = spawn_object(gCurrentObject, 0, bhvSparkleSpawn); diff --git a/src/game/mario_misc.h b/src/game/mario_misc.h index 63d673edb..e5e85ad21 100644 --- a/src/game/mario_misc.h +++ b/src/game/mario_misc.h @@ -10,9 +10,13 @@ extern struct GraphNodeObject gMirrorMario[MAX_PLAYERS]; extern struct MarioBodyState gBodyStates[MAX_PLAYERS]; Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c); -void bhv_toad_message_loop(void); +/* |description|Behavior init function for NPC Toad|descriptionEnd| */ void bhv_toad_message_init(void); +/* |description|Behavior loop function for NPC Toad|descriptionEnd| */ +void bhv_toad_message_loop(void); +/* |description|Behavior init function for Star Door unlock object|descriptionEnd| */ void bhv_unlock_door_star_init(void); +/* |description|Behavior loop function for Star Door unlock object|descriptionEnd| */ void bhv_unlock_door_star_loop(void); Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); Gfx *geo_switch_mario_stand_run(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx); diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 362c03774..6ac8d33bb 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -91,7 +91,7 @@ BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 p data->velZ = forwardVel * coss(yaw); } -void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed) { +void mario_bonk_reflection(struct MarioState *m, u8 negateSpeed) { if (!m) { return; } if (m->wall != NULL) { s16 wallAngle = atan2s(m->wallNormal[2], m->wallNormal[0]); diff --git a/src/game/mario_step.h b/src/game/mario_step.h index 9be6f8e74..37127e6ff 100644 --- a/src/game/mario_step.h +++ b/src/game/mario_step.h @@ -16,23 +16,34 @@ struct BullyCollisionData { extern struct Surface gWaterSurfacePseudoFloor; +/* |description|Always returns zero. May have been originally used for beta trampolines|descriptionEnd| */ f32 get_additive_y_vel_for_jumps(void); void stub_mario_step_1(struct MarioState *); void stub_mario_step_2(void); -void mario_bonk_reflection(struct MarioState *, u32); +/* |description|Reflects Mario off a wall if he is colliding with one and flips forward velocity if `negateSpeed` is TRUE |descriptionEnd| */ +void mario_bonk_reflection(struct MarioState *m, u8 negateSpeed); void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2); BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ, f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius); -u32 mario_update_quicksand(struct MarioState *, f32); -u32 mario_push_off_steep_floor(struct MarioState *, u32, u32); -u32 mario_update_moving_sand(struct MarioState *); -u32 mario_update_windy_ground(struct MarioState *); -void stop_and_set_height_to_floor(struct MarioState *); -s32 stationary_ground_step(struct MarioState *); -s32 perform_ground_step(struct MarioState *); -s32 perform_air_step(struct MarioState *, u32); +/* |description|Updates Mario's state in quicksand, sinks him at `sinkingSpeed` if he's in non instant quicksand|descriptionEnd| */ +u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed); +/* |description|Pushes Mario off a steep floor and sets his action to `action` with `actionArg`|descriptionEnd| */ +u32 mario_push_off_steep_floor(struct MarioState *m, u32 action, u32 actionArg); +/* |description|Pushes Mario in the direction of the quicksand based on the floor surface|descriptionEnd| */ +u32 mario_update_moving_sand(struct MarioState *m); +/* |description|Pushes Mario in the direction of the wind based on the floor surface|descriptionEnd| */ +u32 mario_update_windy_ground(struct MarioState *m); +/* |description|Sets all of Mario's velocity variables to 0 and sets his Y position to the floor height|descriptionEnd| */ +void stop_and_set_height_to_floor(struct MarioState *m); +/* |description|Performs a full Mario stationary physics step (4 substeps) and returns an `GROUND_STEP_*` result|descriptionEnd| */ +s32 stationary_ground_step(struct MarioState *m); +/* |description|Performs a full Mario ground physics step (4 substeps) and returns an `GROUND_STEP_*` result|descriptionEnd| */ +s32 perform_ground_step(struct MarioState *m); +/* |description|Performs a full Mario air physics step (4 substeps) and returns an `AIR_STEP_*` result|descriptionEnd| */ +s32 perform_air_step(struct MarioState *m, u32 stepArg); +/* |description|Sets Mario's velocity to his forward velocity multiplied by the cosine and sine of his pitch and yaw|descriptionEnd| */ void set_vel_from_pitch_and_yaw(struct MarioState* m); #endif // MARIO_STEP_H diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index c3f3f02ae..27108dabf 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -18294,12 +18294,12 @@ int smlua_func_mario_bonk_reflection(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "mario_bonk_reflection"); return 0; } - u32 arg1 = smlua_to_integer(L, 2); + u8 negateSpeed = smlua_to_integer(L, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "mario_bonk_reflection"); return 0; } - mario_bonk_reflection(arg0, arg1); + mario_bonk_reflection(m, negateSpeed); return 1; } @@ -18313,14 +18313,14 @@ int smlua_func_mario_push_off_steep_floor(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "mario_push_off_steep_floor"); return 0; } - u32 arg1 = smlua_to_integer(L, 2); + u32 action = smlua_to_integer(L, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "mario_push_off_steep_floor"); return 0; } - u32 arg2 = smlua_to_integer(L, 3); + u32 actionArg = smlua_to_integer(L, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "mario_push_off_steep_floor"); return 0; } - lua_pushinteger(L, mario_push_off_steep_floor(arg0, arg1, arg2)); + lua_pushinteger(L, mario_push_off_steep_floor(m, action, actionArg)); return 1; } @@ -18334,10 +18334,10 @@ int smlua_func_mario_update_moving_sand(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "mario_update_moving_sand"); return 0; } - lua_pushinteger(L, mario_update_moving_sand(arg0)); + lua_pushinteger(L, mario_update_moving_sand(m)); return 1; } @@ -18351,12 +18351,12 @@ int smlua_func_mario_update_quicksand(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "mario_update_quicksand"); return 0; } - f32 arg1 = smlua_to_number(L, 2); + f32 sinkingSpeed = smlua_to_number(L, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "mario_update_quicksand"); return 0; } - lua_pushinteger(L, mario_update_quicksand(arg0, arg1)); + lua_pushinteger(L, mario_update_quicksand(m, sinkingSpeed)); return 1; } @@ -18370,10 +18370,10 @@ int smlua_func_mario_update_windy_ground(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "mario_update_windy_ground"); return 0; } - lua_pushinteger(L, mario_update_windy_ground(arg0)); + lua_pushinteger(L, mario_update_windy_ground(m)); return 1; } @@ -18387,12 +18387,12 @@ int smlua_func_perform_air_step(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "perform_air_step"); return 0; } - u32 arg1 = smlua_to_integer(L, 2); + u32 stepArg = smlua_to_integer(L, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "perform_air_step"); return 0; } - lua_pushinteger(L, perform_air_step(arg0, arg1)); + lua_pushinteger(L, perform_air_step(m, stepArg)); return 1; } @@ -18406,10 +18406,10 @@ int smlua_func_perform_ground_step(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "perform_ground_step"); return 0; } - lua_pushinteger(L, perform_ground_step(arg0)); + lua_pushinteger(L, perform_ground_step(m)); return 1; } @@ -18440,10 +18440,10 @@ int smlua_func_stationary_ground_step(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stationary_ground_step"); return 0; } - lua_pushinteger(L, stationary_ground_step(arg0)); + lua_pushinteger(L, stationary_ground_step(m)); return 1; } @@ -18457,10 +18457,10 @@ int smlua_func_stop_and_set_height_to_floor(lua_State* L) { return 0; } - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stop_and_set_height_to_floor"); return 0; } - stop_and_set_height_to_floor(arg0); + stop_and_set_height_to_floor(m); return 1; } diff --git a/src/pc/network/network_utils.c b/src/pc/network/network_utils.c index aff07b6aa..5ff1102b2 100644 --- a/src/pc/network/network_utils.c +++ b/src/pc/network/network_utils.c @@ -54,7 +54,7 @@ const char* network_get_player_text_color_string(u8 localIndex) { extern s16 gMenuMode; bool network_check_singleplayer_pause(void) { - return gMenuMode != -1 && !gServerSettings.pauseAnywhere && network_player_connected_count() == 1 && mods_get_all_pausable() && !gDjuiInPlayerMenu; + return gMenuMode != -1 && network_player_connected_count() == 1 && mods_get_all_pausable() && !gDjuiInPlayerMenu; } const char* network_discord_id_from_local_index(u8 localIndex) { diff --git a/src/pc/network/network_utils.h b/src/pc/network/network_utils.h index 486d7a580..a44b58674 100644 --- a/src/pc/network/network_utils.h +++ b/src/pc/network/network_utils.h @@ -4,17 +4,24 @@ #include #include "network.h" +/* |description|Gets a player's global index from their local index|descriptionEnd| */ u8 network_global_index_from_local(u8 localIndex); +/* |description|Gets a player's local index from their global index|descriptionEnd| */ u8 network_local_index_from_global(u8 globalIndex); +/* |description|Checks if you are hosting the current lobby, this value doesn't change|descriptionEnd| */ bool network_is_server(void); +/* |description|Checks if you are a moderator in the current lobby|descriptionEnd| */ bool network_is_moderator(void); u8* network_get_player_text_color(u8 localIndex); +/* |description|Gets the DJUI hex color code string for the player corresponding to `localIndex`'s cap color|descriptionEnd| */ const char* network_get_player_text_color_string(u8 localIndex); +/* |description|Checks if the game can currently be paused in singleplayer|descriptionEnd| */ bool network_check_singleplayer_pause(void); +/* |description|Gets a Discord ID corresponding to the network player with `localIndex`|descriptionEnd| */ const char* network_discord_id_from_local_index(u8 localIndex); #endif \ No newline at end of file