From 71105833c5a9ec1374e9d3e3bfb39eee8377ce0b Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 23 Apr 2022 00:35:49 -0700 Subject: [PATCH] Made specialTripleJump a field of MarioState instead of a global --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + include/types.h | 1 + src/game/behaviors/yoshi.inc.c | 4 ++-- src/game/interaction.c | 2 +- src/game/level_update.c | 4 ++-- src/game/mario_actions_airborne.c | 2 +- src/game/save_file.c | 1 - src/game/save_file.h | 1 - src/pc/lua/smlua_cobject_autogen.c | 3 ++- 10 files changed, 11 insertions(+), 9 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 19aacaf44..98703c221 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -665,6 +665,7 @@ --- @field public slideVelZ number --- @field public slideYaw integer --- @field public spawnInfo SpawnInfo +--- @field public specialTripleJump integer --- @field public splineKeyframeFraction number --- @field public splineState integer --- @field public squishTimer integer diff --git a/docs/lua/structs.md b/docs/lua/structs.md index a6dca7494..c085ba100 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -956,6 +956,7 @@ | slideVelZ | `number` | | | slideYaw | `integer` | | | spawnInfo | [SpawnInfo](structs.md#SpawnInfo) | | +| specialTripleJump | `integer` | | | splineKeyframeFraction | `number` | | | splineState | `integer` | | | squishTimer | `integer` | | diff --git a/include/types.h b/include/types.h index cbdfb9bfe..ad2229679 100644 --- a/include/types.h +++ b/include/types.h @@ -385,6 +385,7 @@ struct MarioState /*????*/ f32 minimumBoneY; /*????*/ f32 curAnimOffset; /*????*/ u8 knockbackTimer; + /*????*/ u8 specialTripleJump; }; struct TextureInfo diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c index 90b69e5d8..f0d893591 100644 --- a/src/game/behaviors/yoshi.inc.c +++ b/src/game/behaviors/yoshi.inc.c @@ -150,7 +150,7 @@ void yoshi_give_present_loop(void) { if (gHudDisplay.lives == 100) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); - gSpecialTripleJump = TRUE; + gMarioStates[0].specialTripleJump = true; o->oAction = YOSHI_ACT_WALK_JUMP_OFF_ROOF; return; } @@ -226,7 +226,7 @@ void bhv_yoshi_loop(void) { if (sYoshiTalkingState > 2) { if (gHudDisplay.lives >= 100) { - gSpecialTripleJump = 1; + gMarioStates[0].specialTripleJump = true; sYoshiTalkingState = 3; } else if ((gGlobalTimer & 0x03) == 0) { play_sound(SOUND_MENU_YOSHI_GAIN_LIVES, gGlobalSoundSource); diff --git a/src/game/interaction.c b/src/game/interaction.c index 3f842227b..68aff42af 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1282,7 +1282,7 @@ static u8 resolve_player_collision(struct MarioState* m, struct MarioState* m2) velY = fmax(fmin(55.0f, 15.0f + fabs(m->vel[1])), 35.0f); } else if (m->action == ACT_DOUBLE_JUMP) { mario_stop_riding_and_holding(m); - set_mario_action(m, (gSpecialTripleJump && m->playerIndex == 0) ? ACT_SPECIAL_TRIPLE_JUMP : ACT_TRIPLE_JUMP, 0); + set_mario_action(m, (m->specialTripleJump && m->playerIndex == 0) ? ACT_SPECIAL_TRIPLE_JUMP : ACT_TRIPLE_JUMP, 0); velY = fmax(fmin(60.0f, 20.0f + fabs(m->vel[1])), 40.0f); } else { mario_stop_riding_and_holding(m); diff --git a/src/game/level_update.c b/src/game/level_update.c index 62437bf88..824cfbdf9 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1503,7 +1503,7 @@ s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum) { gCurrCourseNum = COURSE_NONE; gSavedCourseNum = COURSE_NONE; gCurrCreditsEntry = NULL; - gSpecialTripleJump = FALSE; + gMarioStates[0].specialTripleJump = FALSE; init_mario_from_save_file(); disable_warp_checkpoint(); @@ -1570,7 +1570,7 @@ void fake_lvl_init_from_save_file(void) { if (gNetworkType == NT_NONE) { gNeverEnteredCastle = true; } gCurrCreditsEntry = NULL; - gSpecialTripleJump = 0; + gMarioStates[0].specialTripleJump = false; init_mario_from_save_file(); disable_warp_checkpoint(); diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 3c64c3ede..685ee2fe6 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -483,7 +483,7 @@ s32 act_double_jump(struct MarioState *m) { } s32 act_triple_jump(struct MarioState *m) { - if (m == &gMarioStates[0] && gSpecialTripleJump) { + if (m == &gMarioStates[0] && m->specialTripleJump) { return set_mario_action(m, ACT_SPECIAL_TRIPLE_JUMP, 0); } diff --git a/src/game/save_file.c b/src/game/save_file.c index d54a113ff..b73060364 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -36,7 +36,6 @@ s8 sUnusedGotGlobalCoinHiScore = 0; u8 gGotFileCoinHiScore = FALSE; u8 gCurrCourseStarFlags = 0; -u8 gSpecialTripleJump = FALSE; u8 gSaveFileUsingBackupSlot = FALSE; #define STUB_LEVEL(_0, _1, courseenum, _3, _4, _5, _6, _7, _8) courseenum, diff --git a/src/game/save_file.h b/src/game/save_file.h index 18d33d218..e1a22ff46 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -79,7 +79,6 @@ extern u8 gLastCompletedStarNum; extern s8 sUnusedGotGlobalCoinHiScore; extern u8 gGotFileCoinHiScore; extern u8 gCurrCourseStarFlags; -extern u8 gSpecialTripleJump; extern s8 gLevelToCourseNumTable[]; // game progress flags diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index d79294934..c08573129 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -713,7 +713,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO { "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE }, }; -#define LUA_MARIO_STATE_FIELD_COUNT 73 +#define LUA_MARIO_STATE_FIELD_COUNT 74 static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { { "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE }, { "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE }, @@ -774,6 +774,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { { "slideVelZ", LVT_F32, offsetof(struct MarioState, slideVelZ), false, LOT_NONE }, { "slideYaw", LVT_S16, offsetof(struct MarioState, slideYaw), false, LOT_NONE }, { "spawnInfo", LVT_COBJECT_P, offsetof(struct MarioState, spawnInfo), false, LOT_SPAWNINFO }, + { "specialTripleJump", LVT_U8, offsetof(struct MarioState, specialTripleJump), false, LOT_NONE }, // { "splineKeyframe", LVT_???, offsetof(struct MarioState, splineKeyframe), false, LOT_??? }, <--- UNIMPLEMENTED { "splineKeyframeFraction", LVT_F32, offsetof(struct MarioState, splineKeyframeFraction), false, LOT_NONE }, { "splineState", LVT_S32, offsetof(struct MarioState, splineState), false, LOT_NONE },