From 1a71619f47513e73e1a0829bf2733d510ac01bf1 Mon Sep 17 00:00:00 2001 From: arthurtilly <32559225+arthurtilly@users.noreply.github.com> Date: Wed, 26 Oct 2022 19:12:29 +1300 Subject: [PATCH] Imminent fixes for bugs found on master branch (#512) * The vanilla level checks define for Yoshi is inverted, causing him to require 120 stars when it is off and appear at 0 stars when it's on * The downwarp fix results in Mario levitating in midair when grabbing Bowser midair. While downwarps should still be fixed, the change should be reverted immediately until a better fix is made. * Some checks of Mario's floor class were using the wrong defines, which can lead to unexpected behavior in the event anyone wants to reorder surface types. By default the SURFACE_CLASS_SLIPPERY and SURFACE_SLIPPERY defines have the same value, which is why this mistake is hard to notice. * The firsty frames define was implemented poorly, not allowing for vanilla firsty behavior no matter what the values were set to. This has been reverted, while avoiding the UB in the original vanilla code. * Removed the ledge grab changes that fix QSLGs and change the false ledgegrab define since Arceveti wanted to in his PR --- README.md | 3 +-- include/config/config_movement.h | 7 ++----- include/surface_terrains.h | 2 +- src/engine/surface_collision.c | 2 +- src/game/behaviors/yoshi.inc.c | 2 +- src/game/mario.c | 24 ++++++++++++------------ src/game/mario_actions_airborne.c | 7 ++----- src/game/mario_actions_automatic.c | 2 -- src/game/mario_step.c | 11 ++++++----- 9 files changed, 26 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index c399e9016..0cb169fad 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin - **ArcticJaguar725**: Most audio configuration and layout changes, colored ia4 text, floombas, various bugfixes, and more - **CowQuack**: Adjustable skybox sizes, area-specific skybox function - **thecozies**: Water surface types, general maintenance, and time -- **MrComit**: General use object defines, JUMP_KICK_FIX, LEDGE_GRABS_CHECK_SLOPE_ANGLE +- **MrComit**: General use object defines, JUMP_KICK_FIX - **aglab2**: Bugfixes (particularly puppycam), refactor stuff - **someone2639**: math.s and crash screen disam, stack trace, map packing, shiftable segments 2, S2DEX engine - **Arthurtilly**: Platform Displacement 2 @@ -61,7 +61,6 @@ Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff - Toggle to disable fall damage and the fall damage sound * - Nonstop stars * - Removed course-specific camera processing * -- You can increase the number of frames that you have to perform a firsty * - Ability to set Mario's movement speed when hanging from a ceiling * - Tighter hanging controls (Mario will face the direction of the analog stick directly while hanging from a ceiling) * - reonucam3: custom camera by Reonu. This is included as a .patch file in the enhancements folder, you need to apply it if you want this camera. diff --git a/include/config/config_movement.h b/include/config/config_movement.h index 6fa9ff7ff..95d567135 100644 --- a/include/config/config_movement.h +++ b/include/config/config_movement.h @@ -68,14 +68,11 @@ // Allows Mario to grab hangable ceilings from any state. #define HANGING_FIX -// The last frame after hitting a wall that will be considered a firsty when wallkicking. -#define FIRSTY_LAST_FRAME 1 - // The maximum angle the player can wall kick, in degrees. 0..90. To allow 45 degree wall kicks, you must supply `46` to allow 45 and under. #define WALL_KICK_DEGREES 45 -// This is vanilla behavior, disable it to allow ledge grabbing regardless of floor pitch. -// #define LEDGE_GRABS_CHECK_SLOPE_ANGLE +// Makes Mario unable to ledge grab steep slopes to prevent false ledge grabs. +#define DONT_LEDGE_GRAB_STEEP_SLOPES // Disables BLJs and crushes SimpleFlips's dreams. // #define DISABLE_BLJ diff --git a/include/surface_terrains.h b/include/surface_terrains.h index 95b20aa37..e39be5cfb 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -244,7 +244,7 @@ enum SurfaceTypes { enum SurfaceClass { SURFACE_CLASS_DEFAULT, - SURFACE_CLASS_VERY_SLIPPERY = 0x0013, + SURFACE_CLASS_VERY_SLIPPERY, SURFACE_CLASS_SLIPPERY, SURFACE_CLASS_NOT_SLIPPERY }; diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 73bb70342..2e5f67d70 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -704,7 +704,7 @@ s32 find_water_level(s32 x, s32 z) { // TODO: Allow y pos // If the location is within a water box and it is a water box. // Water is less than 50 val only, while above is gas and such. - if (loX < x && x < hiX && loZ < z && z < hiZ && val < 50) { + if (loX <= x && x <= hiX && loZ <= z && z <= hiZ && val < 50) { // Set the water height. Since this breaks, only return the first height. waterLevel = *p; break; diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c index a6eb0a443..26a76fadc 100644 --- a/src/game/behaviors/yoshi.inc.c +++ b/src/game/behaviors/yoshi.inc.c @@ -11,7 +11,7 @@ void bhv_yoshi_init(void) { o->oBuoyancy = 1.3f; o->oInteractionSubtype = INT_SUBTYPE_NPC; -#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) +#if !defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) if (sYoshiDead == TRUE) { #else if ((save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_MIN), COURSE_NUM_TO_INDEX(COURSE_MAX)) < 120) diff --git a/src/game/mario.c b/src/game/mario.c index 90f4da1d9..acce2d695 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -536,10 +536,10 @@ u32 mario_floor_is_slippery(struct MarioState *m) { } switch (mario_get_floor_class(m)) { - case SURFACE_VERY_SLIPPERY: normY = COS10; break; - case SURFACE_SLIPPERY: normY = COS20; break; - default: normY = COS38; break; - case SURFACE_NOT_SLIPPERY: normY = 0.0f; break; + case SURFACE_CLASS_VERY_SLIPPERY: normY = COS10; break; + case SURFACE_CLASS_SLIPPERY: normY = COS20; break; + default: normY = COS38; break; + case SURFACE_CLASS_NOT_SLIPPERY: normY = 0.0f; break; } return m->floor->normal.y <= normY; @@ -557,10 +557,10 @@ s32 mario_floor_is_slope(struct MarioState *m) { } switch (mario_get_floor_class(m)) { - case SURFACE_VERY_SLIPPERY: normY = COS5; break; - case SURFACE_SLIPPERY: normY = COS10; break; - default: normY = COS15; break; - case SURFACE_NOT_SLIPPERY: normY = COS20; break; + case SURFACE_CLASS_VERY_SLIPPERY: normY = COS5; break; + case SURFACE_CLASS_SLIPPERY: normY = COS10; break; + default: normY = COS15; break; + case SURFACE_CLASS_NOT_SLIPPERY: normY = COS20; break; } return m->floor->normal.y <= normY; @@ -584,10 +584,10 @@ s32 mario_floor_is_steep(struct MarioState *m) { // This does not matter in vanilla game practice. if (!mario_facing_downhill(m, FALSE)) { switch (mario_get_floor_class(m)) { - case SURFACE_VERY_SLIPPERY: normY = COS15; break; - case SURFACE_SLIPPERY: normY = COS20; break; - default: normY = COS30; break; - case SURFACE_NOT_SLIPPERY: normY = COS30; break; + case SURFACE_CLASS_VERY_SLIPPERY: normY = COS15; break; + case SURFACE_CLASS_SLIPPERY: normY = COS20; break; + default: normY = COS30; break; + case SURFACE_CLASS_NOT_SLIPPERY: normY = COS30; break; } return m->floor->normal.y <= normY; diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 7103228fd..26051395f 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1273,7 +1273,7 @@ s32 act_air_hit_wall(struct MarioState *m) { mario_drop_held_object(m); } - if (++(m->actionTimer) <= FIRSTY_LAST_FRAME) { + if (++(m->actionTimer) <= 2) { if (m->input & INPUT_A_PRESSED) { m->vel[1] = 52.0f; m->faceAngle[1] += 0x8000; @@ -1299,12 +1299,9 @@ s32 act_air_hit_wall(struct MarioState *m) { return set_mario_action(m, ACT_SOFT_BONK, 0); } -#if FIRSTY_LAST_FRAME > 1 set_mario_animation(m, MARIO_ANIM_START_WALLKICK); - m->marioObj->header.gfx.angle[1] = m->wallYaw; -#endif - return FALSE; + return TRUE; } s32 act_forward_rollout(struct MarioState *m) { diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 117e1cb47..6fd5ea36b 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -565,11 +565,9 @@ s32 act_ledge_grab(struct MarioState *m) { if (m->actionTimer < 10) { m->actionTimer++; } -#ifdef LEDGE_GRABS_CHECK_SLOPE_ANGLE if (m->floor->normal.y < COS25) { return let_go_of_ledge(m); } -#endif if (m->input & (INPUT_Z_PRESSED | INPUT_OFF_FLOOR)) { return let_go_of_ledge(m); } diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 2b1ceb08b..eb9923fdc 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -259,10 +259,9 @@ s32 stationary_ground_step(struct MarioState *m) { if (takeStep) { stepResult = perform_ground_step(m); } else { - // Hackersm64: this condition fixes potential downwarps - if (m->pos[1] <= m->floorHeight + 160.0f) { - m->pos[1] = m->floorHeight; - } + //! TODO - This is responsible for many stationary downwarps but is + // important for stuff like catching Bowser in midair, figure out a good way to fix + m->pos[1] = m->floorHeight; vec3f_copy(marioObj->header.gfx.pos, m->pos); vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0); @@ -404,8 +403,10 @@ struct Surface *check_ledge_grab(struct MarioState *m, struct Surface *prevWall, if (ledgeFloor == NULL || (*ledgeFloor) == NULL || ledgePos[1] < nextPos[1] + 100.0f +#ifdef DONT_LEDGE_GRAB_STEEP_SLOPES || (*ledgeFloor)->normal.y < COS25 // H64 TODO: check if floor is actually slippery - || SURFACE_IS_UNSAFE((*ledgeFloor)->type)) { +#endif + ) { return NULL; }