From dbfc4f5b14e1e56f8bd2cfcfc47d027803e13f66 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 27 Mar 2022 17:25:39 -0700 Subject: [PATCH] Fix errors pointed out by clang --- data/dynos_opt_render.cpp | 4 ++++ src/audio/data.c | 4 ++-- src/game/camera.c | 8 +++++--- src/game/mario_actions_airborne.c | 6 +++--- src/game/object_collision.c | 4 ++-- src/game/paintings.c | 3 +++ src/game/screen_transition.c | 1 + src/game/shadow.c | 3 +-- src/goddard/renderer.c | 2 +- src/pc/gfx/gfx_opengl.c | 1 + src/pc/lua/utils/smlua_obj_utils.c | 4 ++-- src/pc/mods/mods_utils.c | 2 +- 12 files changed, 26 insertions(+), 16 deletions(-) diff --git a/data/dynos_opt_render.cpp b/data/dynos_opt_render.cpp index d182e5e3..9fd0daa8 100644 --- a/data/dynos_opt_render.cpp +++ b/data/dynos_opt_render.cpp @@ -62,7 +62,11 @@ static void PrintString(const Label& aLabel, s32 aX, s32 aY, u32 aFrontColorRGBA } static void PrintBox(s32 aX, s32 aY, s32 aWidth, s32 aHeight, u32 aColorRGBA, bool aAlignLeft) { +#ifdef COOP + if ((aColorRGBA & 0xFF) != 0) { +#else if ((aColorRGBA && 0xFF) != 0) { +#endif Mtx *_Matrix = (Mtx *) alloc_display_list(sizeof(Mtx)); if (!_Matrix) return; if (aAlignLeft) { diff --git a/src/audio/data.c b/src/audio/data.c index 57e093f7..7bf9fb8a 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -183,8 +183,8 @@ s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, struct AdsrEnvelope gDefaultEnvelope[] = { { BE_TO_HOST16(4), BE_TO_HOST16(32000) }, // go from 0 to 32000 over the course of 16ms - { BE_TO_HOST16(1000), BE_TO_HOST16(32000) }, // stay there for 4.16 seconds - { BE_TO_HOST16(ADSR_HANG), 0 } // then continue staying there + { (s16)BE_TO_HOST16(1000), BE_TO_HOST16(32000) }, // stay there for 4.16 seconds + { (s16)BE_TO_HOST16(ADSR_HANG), 0 } // then continue staying there }; #endif diff --git a/src/game/camera.c b/src/game/camera.c index c9555c94..abdfd0bc 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -1714,6 +1714,7 @@ struct ParallelTrackingPoint sBBHLibraryParTrackPath[] = { }; s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { + return 0; } static void stub_camera_1(UNUSED s32 unused) { @@ -2039,6 +2040,7 @@ void mode_behind_mario_camera(struct Camera *c) { } s32 nop_update_water_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { + return 0; } /** @@ -5435,7 +5437,7 @@ void determine_pushing_or_pulling_door(s16 *rotation) { if (sMarioCamState->action == ACT_PULLING_DOOR) { *rotation = 0; } else { - *rotation = DEGREES(180); + *rotation = (s16)DEGREES(180); } } @@ -9606,8 +9608,8 @@ s32 intro_peach_move_camera_start_to_pipe(struct Camera *c, struct CutsceneSplin // The two splines used by this function are reflected in the horizontal plane for some reason, // so they are rotated every frame. Why do this, Nintendo? - rotate_in_xz(c->focus, c->focus, DEGREES(180)); - rotate_in_xz(c->pos, c->pos, DEGREES(180)); + rotate_in_xz(c->focus, c->focus, (s16)DEGREES(180)); + rotate_in_xz(c->pos, c->pos, (s16)DEGREES(180)); vec3f_set(offset, -1328.f, 260.f, 4664.f); vec3f_add(c->focus, offset); diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index fa73fd89..0512254a 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -77,11 +77,11 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) { #pragma GCC diagnostic ignored "-Wtype-limits" //! Never true - if (m->actionState == ACT_GROUND_POUND) { + /*if (m->actionState == ACT_GROUND_POUND) { damageHeight = 600.0f; - } else { + } else {*/ damageHeight = 1150.0f; - } + //} #pragma GCC diagnostic pop diff --git a/src/game/object_collision.c b/src/game/object_collision.c index f899ea08..8384995e 100644 --- a/src/game/object_collision.c +++ b/src/game/object_collision.c @@ -108,7 +108,7 @@ s32 detect_object_hitbox_overlap(struct Object *a, struct Object *b) { return 1; } - //! no return value + return 0; } s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) { @@ -140,7 +140,7 @@ s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) { return 1; } - //! no return value + return 0; } void clear_object_collision(struct Object *a) { diff --git a/src/game/paintings.c b/src/game/paintings.c index 5bfcd56d..95c21012 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -280,6 +280,7 @@ f32 painting_ripple_y(struct Painting *painting, s8 ySource) { return painting->size / 2.0; // some concentric ripples don't care about Mario break; } + return painting->size / 2.0; } /** @@ -305,6 +306,7 @@ f32 painting_nearest_4th(struct Painting *painting) { } else if (painting->floorEntered & ENTER_RIGHT) { return thirdQuarter; } + return thirdQuarter; } /** @@ -336,6 +338,7 @@ f32 painting_ripple_x(struct Painting *painting, s8 xSource) { return painting->size / 2.0; break; } + return painting->size / 2.0; } /** diff --git a/src/game/screen_transition.c b/src/game/screen_transition.c index ab36bbc6..45870cd5 100644 --- a/src/game/screen_transition.c +++ b/src/game/screen_transition.c @@ -324,6 +324,7 @@ s32 render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct Wa return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR); break; } + return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR); } Gfx *render_cannon_circle_base(void) { diff --git a/src/game/shadow.c b/src/game/shadow.c index ec94f909..897c54e6 100644 --- a/src/game/shadow.c +++ b/src/game/shadow.c @@ -188,8 +188,7 @@ f32 get_water_level_below_shadow(struct Shadow *s) { gShadowAboveWaterOrLava = TRUE; return waterLevel; } - //! @bug Missing return statement. This compiles to return `waterLevel` - //! incidentally. + return waterLevel; } /** diff --git a/src/goddard/renderer.c b/src/goddard/renderer.c index a82f5c07..933095ef 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -2845,7 +2845,7 @@ void stub_renderer_6(UNUSED struct GdObj *obj) { * @return an identifier of the menu just defined */ long defpup(UNUSED const char *menufmt, ...) { - //! @bug no return; function was stubbed + return 0; } /** diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index eb9446ad..7ae82942 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -172,6 +172,7 @@ static const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_ return "texVal1.a"; } } + return "unknown"; } static void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) { diff --git a/src/pc/lua/utils/smlua_obj_utils.c b/src/pc/lua/utils/smlua_obj_utils.c index a4237c9b..569022d7 100644 --- a/src/pc/lua/utils/smlua_obj_utils.c +++ b/src/pc/lua/utils/smlua_obj_utils.c @@ -76,11 +76,11 @@ static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum Mod } struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) { - spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true); + return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true); } struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) { - spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, false); + return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, false); } s32 obj_has_behavior_id(struct Object *o, enum BehaviorId behaviorId) { diff --git a/src/pc/mods/mods_utils.c b/src/pc/mods/mods_utils.c index ab635f6d..64db187f 100644 --- a/src/pc/mods/mods_utils.c +++ b/src/pc/mods/mods_utils.c @@ -246,7 +246,7 @@ bool directory_sanity_check(struct dirent* dir, char* dirPath, char* outPath) { if (strchr(dir->d_name, '\\') != NULL) { return false; } // skip anything that starts with . - if (dir->d_name == NULL || dir->d_name[0] == '.') { return false; } + if (dir->d_name[0] == '.') { return false; } // build path if (!concat_path(outPath, dirPath, dir->d_name)) {