From de2300f837bbb4d71a043a2f39a483fd648f9531 Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 19 May 2022 19:42:07 -0700 Subject: [PATCH] Fix clang/mac compile --- Makefile | 2 +- actors/number/geo.inc.c | 1 + autogen/lua_definitions/functions.lua | 19 +++++++++++-- docs/lua/functions-3.md | 40 +++++++++++++++++++++++++++ docs/lua/functions-4.md | 18 ++++++------ docs/lua/functions.md | 2 ++ src/pc/djui/djui_panel_host_message.c | 1 + src/pc/gfx/gfx_pc.c | 4 ++- src/pc/lua/smlua_functions.c | 2 ++ src/pc/lua/smlua_functions_autogen.c | 32 +++++++++++++++++++-- src/pc/lua/utils/smlua_misc_utils.c | 6 ++-- src/pc/lua/utils/smlua_misc_utils.h | 6 ++-- src/pc/utils/misc.c | 31 --------------------- 13 files changed, 110 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index 4ca1ae3c..c24ecf32 100644 --- a/Makefile +++ b/Makefile @@ -678,7 +678,7 @@ else ifeq ($(COMPILER),clang) CC := clang CXX := clang++ CPP := clang++ - EXTRA_CFLAGS += -Wno-unused-function -Wno-unused-variable -Wno-unknown-warning-option -Wno-self-assign -Wno-unknown-pragmas + EXTRA_CFLAGS += -Wno-unused-function -Wno-unused-variable -Wno-unknown-warning-option -Wno-self-assign -Wno-unknown-pragmas -Wno-unused-result else ifeq ($(TARGET_WEB),1) # As in, web PC port CC := emcc CXX := emcc diff --git a/actors/number/geo.inc.c b/actors/number/geo.inc.c index 44b4135d..3c881384 100644 --- a/actors/number/geo.inc.c +++ b/actors/number/geo.inc.c @@ -47,6 +47,7 @@ Gfx *geo_num3_switch(s32 callContext, struct GraphNode *node, UNUSED void *conte switchCase->selectedCase = 10; } } + return NULL; } extern const Gfx dl_billboard_num3_0[]; diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 8c283bb6..afb08b4a 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3693,6 +3693,11 @@ function get_current_background_music() -- ... end +--- @return integer +function get_current_background_music_default_volume() + -- ... +end + --- @return integer function get_current_background_music_max_target_volume() -- ... @@ -4232,6 +4237,14 @@ function set_mario_animation(m, targetAnimID) -- ... end +--- @param m MarioState +--- @param flags integer +--- @param clear integer +--- @return nil +function set_mario_particle_flags(m, flags, clear) + -- ... +end + --- @param m MarioState --- @param initialVelY number --- @param multiplier number @@ -7434,19 +7447,19 @@ function set_environment_region(index, value) end --- @param far number ---- @return number +--- @return nil function set_override_far(far) -- ... end --- @param fov number ---- @return number +--- @return nil function set_override_fov(fov) -- ... end --- @param near number ---- @return number +--- @return nil function set_override_near(near) -- ... end diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index b1dc3709..f2742567 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -2396,6 +2396,24 @@
+## [get_current_background_music_default_volume](#get_current_background_music_default_volume) + +### Lua Example +`local integerValue = get_current_background_music_default_volume()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 get_current_background_music_default_volume(void);` + +[:arrow_up_small:](#) + +
+ ## [get_current_background_music_max_target_volume](#get_current_background_music_max_target_volume) ### Lua Example @@ -4064,6 +4082,28 @@
+## [set_mario_particle_flags](#set_mario_particle_flags) + +### Lua Example +`set_mario_particle_flags(m, flags, clear)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| flags | `integer` | +| clear | `integer` | + +### Returns +- None + +### C Prototype +`void set_mario_particle_flags(struct MarioState* m, u32 flags, u8 clear);` + +[:arrow_up_small:](#) + +
+ ## [set_mario_y_vel_based_on_fspeed](#set_mario_y_vel_based_on_fspeed) ### Lua Example diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index b83d7d86..09c8a99f 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -5498,7 +5498,7 @@ ## [set_override_far](#set_override_far) ### Lua Example -`local numberValue = set_override_far(far)` +`set_override_far(far)` ### Parameters | Field | Type | @@ -5506,10 +5506,10 @@ | far | `number` | ### Returns -- `number` +- None ### C Prototype -`f32 set_override_far(f32 far);` +`void set_override_far(f32 far);` [:arrow_up_small:](#) @@ -5518,7 +5518,7 @@ ## [set_override_fov](#set_override_fov) ### Lua Example -`local numberValue = set_override_fov(fov)` +`set_override_fov(fov)` ### Parameters | Field | Type | @@ -5526,10 +5526,10 @@ | fov | `number` | ### Returns -- `number` +- None ### C Prototype -`f32 set_override_fov(f32 fov);` +`void set_override_fov(f32 fov);` [:arrow_up_small:](#) @@ -5538,7 +5538,7 @@ ## [set_override_near](#set_override_near) ### Lua Example -`local numberValue = set_override_near(near)` +`set_override_near(near)` ### Parameters | Field | Type | @@ -5546,10 +5546,10 @@ | near | `number` | ### Returns -- `number` +- None ### C Prototype -`f32 set_override_near(f32 near);` +`void set_override_near(f32 near);` [:arrow_up_small:](#) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 40dd7770..3866c0ef 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -729,6 +729,7 @@ - [fade_volume_scale](functions-3.md#fade_volume_scale) - [fadeout_background_music](functions-3.md#fadeout_background_music) - [get_current_background_music](functions-3.md#get_current_background_music) + - [get_current_background_music_default_volume](functions-3.md#get_current_background_music_default_volume) - [get_current_background_music_max_target_volume](functions-3.md#get_current_background_music_max_target_volume) - [get_current_background_music_target_volume](functions-3.md#get_current_background_music_target_volume) - [is_current_background_music_volume_lowered](functions-3.md#is_current_background_music_volume_lowered) @@ -821,6 +822,7 @@ - [set_mario_action](functions-3.md#set_mario_action) - [set_mario_anim_with_accel](functions-3.md#set_mario_anim_with_accel) - [set_mario_animation](functions-3.md#set_mario_animation) + - [set_mario_particle_flags](functions-3.md#set_mario_particle_flags) - [set_mario_y_vel_based_on_fspeed](functions-3.md#set_mario_y_vel_based_on_fspeed) - [set_steep_jump_action](functions-3.md#set_steep_jump_action) - [set_water_plunge_action](functions-3.md#set_water_plunge_action) diff --git a/src/pc/djui/djui_panel_host_message.c b/src/pc/djui/djui_panel_host_message.c index 547d0f35..edbfc5ad 100644 --- a/src/pc/djui/djui_panel_host_message.c +++ b/src/pc/djui/djui_panel_host_message.c @@ -7,6 +7,7 @@ #include "pc/utils/misc.h" #include "src/game/level_update.h" #include "src/game/hardcoded.h" +#include "src/engine/math_util.h" #include "audio/external.h" #include "sounds.h" diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 32bb7f7e..7abc8227 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -624,14 +624,16 @@ static void import_texture(int tile) { // make sure the texture id is a printable ascii string bool texidIsPrintable = true; char* c = (char*)texid; + u16 length = 0; while (c != NULL && *c != '\0') { if (*c < 33 || *c > 126) { texidIsPrintable = false; break; } + length++; c++; } - if (texidIsPrintable) { + if (texidIsPrintable && length > 0) { char texname[SYS_MAX_PATH]; snprintf(texname, sizeof(texname), FS_TEXTUREDIR "/%s.png", texid); load_texture(texname); diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index c9a3f9da..f18192d8 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -178,11 +178,13 @@ int smlua_func_network_send_object(lua_State* L) { int smlua_func_network_send(lua_State* L) { if (!smlua_functions_valid_param_count(L, 2)) { return 0; } network_send_lua_custom(true); + return 1; } int smlua_func_network_send_to(lua_State* L) { if (!smlua_functions_valid_param_count(L, 3)) { return 0; } network_send_lua_custom(false); + return 1; } ////////////// diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 34881729..1d936009 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -7447,6 +7447,15 @@ int smlua_func_get_current_background_music(UNUSED lua_State* L) { return 1; } +int smlua_func_get_current_background_music_default_volume(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + lua_pushinteger(L, get_current_background_music_default_volume()); + + return 1; +} + int smlua_func_get_current_background_music_max_target_volume(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -8489,6 +8498,21 @@ int smlua_func_set_mario_animation(lua_State* L) { return 1; } +int smlua_func_set_mario_particle_flags(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; } + u32 flags = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; } + u8 clear = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; } + + set_mario_particle_flags(m, flags, clear); + + return 1; +} + int smlua_func_set_mario_y_vel_based_on_fspeed(lua_State* L) { if(!smlua_functions_valid_param_count(L, 3)) { return 0; } @@ -15282,7 +15306,7 @@ int smlua_func_set_override_far(lua_State* L) { f32 far = smlua_to_number(L, 1); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; } - lua_pushnumber(L, set_override_far(far)); + set_override_far(far); return 1; } @@ -15293,7 +15317,7 @@ int smlua_func_set_override_fov(lua_State* L) { f32 fov = smlua_to_number(L, 1); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; } - lua_pushnumber(L, set_override_fov(fov)); + set_override_fov(fov); return 1; } @@ -15304,7 +15328,7 @@ int smlua_func_set_override_near(lua_State* L) { f32 near = smlua_to_number(L, 1); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; } - lua_pushnumber(L, set_override_near(near)); + set_override_near(near); return 1; } @@ -16951,6 +16975,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "fade_volume_scale", smlua_func_fade_volume_scale); smlua_bind_function(L, "fadeout_background_music", smlua_func_fadeout_background_music); smlua_bind_function(L, "get_current_background_music", smlua_func_get_current_background_music); + smlua_bind_function(L, "get_current_background_music_default_volume", smlua_func_get_current_background_music_default_volume); smlua_bind_function(L, "get_current_background_music_max_target_volume", smlua_func_get_current_background_music_max_target_volume); smlua_bind_function(L, "get_current_background_music_target_volume", smlua_func_get_current_background_music_target_volume); smlua_bind_function(L, "is_current_background_music_volume_lowered", smlua_func_is_current_background_music_volume_lowered); @@ -17037,6 +17062,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_mario_action", smlua_func_set_mario_action); smlua_bind_function(L, "set_mario_anim_with_accel", smlua_func_set_mario_anim_with_accel); smlua_bind_function(L, "set_mario_animation", smlua_func_set_mario_animation); + smlua_bind_function(L, "set_mario_particle_flags", smlua_func_set_mario_particle_flags); smlua_bind_function(L, "set_mario_y_vel_based_on_fspeed", smlua_func_set_mario_y_vel_based_on_fspeed); smlua_bind_function(L, "set_steep_jump_action", smlua_func_set_steep_jump_action); smlua_bind_function(L, "set_water_plunge_action", smlua_func_set_water_plunge_action); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 79073093..2a21ef0c 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -192,14 +192,14 @@ void set_environment_region(u8 index, s32 value) { } } -f32 set_override_fov(f32 fov) { +void set_override_fov(f32 fov) { gOverrideFOV = fov; } -f32 set_override_near(f32 near) { +void set_override_near(f32 near) { gOverrideNear = near; } -f32 set_override_far(f32 far) { +void set_override_far(f32 far) { gOverrideFar = far; } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 326541ab..6a55e74d 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -59,9 +59,9 @@ void movtexqc_register(const char* name, s16 level, s16 area, s16 type); f32 get_environment_region(u8 index); void set_environment_region(u8 index, s32 value); -f32 set_override_fov(f32 fov); -f32 set_override_near(f32 near); -f32 set_override_far(f32 far); +void set_override_fov(f32 fov); +void set_override_near(f32 near); +void set_override_far(f32 far); void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index d09aecc1..a62874ce 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -129,37 +129,6 @@ static f32 asins(f32 val) { return radians_to_sm64(asin(sm64_to_radians(val))); } -void mtx_to_euler1(Mtx* mat, Vec3s rot) { - if (mat->m[1][1] == 1.0f) { - rot[0] = 0; - rot[1] = atan2(mat->m[1][3], mat->m[3][4]); - rot[2] = 0; - } else if (mat->m[1][1] == -1.0f) { - rot[0] = 0; - rot[1] = atan2(mat->m[1][3], mat->m[3][4]); - rot[2] = 0; - } else { - rot[0] = asin(mat->m[2][1]); - rot[1] = atan2(-mat->m[3][1], mat->m[1][1]); - rot[2] = atan2(-mat->m[2][3], mat->m[2][2]); - } -} -void mtx_to_euler2(Mtx* mat, Vec3s rot) { - if (mat->m[1][1] == 1.0f) { - rot[0] = 0; - rot[1] = atan2(mat->m[3][1], mat->m[4][3]); - rot[2] = 0; - } else if (mat->m[1][1] == -1.0f) { - rot[0] = 0; - rot[1] = atan2(mat->m[3][1], mat->m[4][3]); - rot[2] = 0; - } else { - rot[0] = asin(mat->m[1][2]); - rot[1] = atan2(-mat->m[1][3], mat->m[1][1]); - rot[2] = atan2(-mat->m[3][2], mat->m[2][2]); - } -} - f32 delta_interpolate_f32(f32 start, f32 end, f32 delta) { return start * (1.0f - delta) + end * delta; }