summaryrefslogtreecommitdiff
path: root/mm/src/code
diff options
context:
space:
mode:
authorGarrett Cox <garrettjcox@gmail.com>2024-11-03 14:26:39 -0600
committerGarrett Cox <garrettjcox@gmail.com>2024-11-03 14:26:39 -0600
commit7fa63244e4d2f1dbfab9babeb9ddd670f57fbc60 (patch)
tree7bb4b4be25b8c8a12e7b74a9e68487fcec87a16c /mm/src/code
parent0e4a2e9fc8ca15a046c81a460b9716028f6dece6 (diff)
PoC glitchless playthrough implementation
Diffstat (limited to 'mm/src/code')
-rw-r--r--mm/src/code/z_actor.c8
-rw-r--r--mm/src/code/z_parameter.c7
2 files changed, 13 insertions, 2 deletions
diff --git a/mm/src/code/z_actor.c b/mm/src/code/z_actor.c
index 7e1bfb38e..7e7281822 100644
--- a/mm/src/code/z_actor.c
+++ b/mm/src/code/z_actor.c
@@ -927,6 +927,14 @@ void Flags_SetRandoInf(s32 flag) {
GameInteractor_ExecuteOnFlagSet(FLAG_RANDO_INF, flag);
}
}
+
+void Flags_ClearRandoInf(s32 flag) {
+ u8 previouslyOn = Flags_GetRandoInf(flag);
+ gSaveContext.save.shipSaveInfo.rando.randoInf[(flag) >> 4] &= (u8) ~(1 << ((flag)&0xF));
+ if (previouslyOn) {
+ GameInteractor_ExecuteOnFlagUnset(FLAG_RANDO_INF, flag);
+ }
+}
// #endregion
/* End of Flags section */
diff --git a/mm/src/code/z_parameter.c b/mm/src/code/z_parameter.c
index 13c5e2901..dc6a46866 100644
--- a/mm/src/code/z_parameter.c
+++ b/mm/src/code/z_parameter.c
@@ -3551,7 +3551,6 @@ s16 sRupeeRefillCounts[] = { 1, 5, 10, 20, 50, 100, 200 };
// 2S2H [Enhancements] This was originally Item_Give, we wrapped it for hooking purposes
u8 Item_GiveImpl(PlayState* play, u8 item) {
- Player* player = GET_PLAYER(play);
u8 i;
u8 temp;
u8 slot;
@@ -3605,7 +3604,11 @@ u8 Item_GiveImpl(PlayState* play, u8 item) {
} else if ((item >= ITEM_SHIELD_HERO) && (item <= ITEM_SHIELD_MIRROR)) {
if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != (u16)(item - ITEM_SHIELD_HERO + EQUIP_VALUE_SHIELD_HERO)) {
SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, item - ITEM_SHIELD_HERO + EQUIP_VALUE_SHIELD_HERO);
- Player_SetEquipmentData(play, player);
+ // 2S2H [Randomizer] Added a nullptr check so that we can call this function outside of gameplay for logic
+ if (gPlayState != NULL) {
+ Player* player = GET_PLAYER(play);
+ Player_SetEquipmentData(play, player);
+ }
return ITEM_NONE;
}
return item;