From 0c6ed553a2b048ae802c982a4e89ff6337495e56 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 26 Jul 2022 18:14:28 -0700 Subject: [PATCH] Shorten code by calling new function Reduced duplicate code by calling the new Audio_PlayFanfare_Rando function from z_player.c --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 6 +-- .../actors/ovl_player_actor/z_player.c | 38 +++++-------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 1aba4fae3a..5597c53ebe 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -118,7 +118,7 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, textId, NULL); if (gSaveContext.n64ddFlag) { - Audio_PlayFanfare_Rando(); + Audio_PlayFanfare_Rando(getItemId); } else { Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } @@ -156,7 +156,7 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { } Message_StartTextbox(globalCtx, textId, NULL); if (gSaveContext.n64ddFlag) { - Audio_PlayFanfare_Rando(); + Audio_PlayFanfare_Rando(getItemId); } else { Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } @@ -166,7 +166,7 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { // Function to play "get-item" fanfares according to the type of item obtained (used in rando) // Longer fanfares for medallions/stones/songs are behind the Cvar -void Audio_PlayFanfare_Rando() { +void Audio_PlayFanfare_Rando(ItemID getItemId) { s32 temp1; if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index cdc63422f4..11cbf02e25 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12684,6 +12684,11 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { Message_StartTextbox(globalCtx, giEntry->textId, &this->actor); Item_Give(globalCtx, giEntry->itemId); + // In rando the fanfares are handled in z_en_si.c, so we can skip down a bit + if (gSaveContext.n64ddFlag) { + goto RandoFanfareSkip; + } + if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_RED)) || ((this->getItemId >= GI_RUPEE_PURPLE) && (this->getItemId <= GI_RUPEE_GOLD)) || ((this->getItemId >= GI_RUPEE_GREEN_LOSE) && (this->getItemId <= GI_RUPEE_PURPLE_LOSE)) || @@ -12699,36 +12704,13 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { else { temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; } - - // Restore appropriate item fanfares in rando when we're obtaining items outside of their normal contexts + + RandoFanfareSkip: if (gSaveContext.n64ddFlag) { - // If we get a skulltula token (in tokensanity) or the "WINNER" heart, play "get small item" - if (this->getItemId == GI_SKULL_TOKEN || this->getItemId == GI_HEART_PIECE_WIN) { - temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; - } - // But if the "WINNER" heart is the 4th heart piece collected, play "get heart container" - if (this->getItemId == GI_HEART_PIECE_WIN && - ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000)) { - temp1 = NA_BGM_HEART_GET | 0x900; - } - // If the setting is toggled on and we get special quest items (longer fanfares): - if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { - // If we get a medallion, play the "get a medallion" fanfare - if ((this->getItemId >= GI_MEDALLION_LIGHT) && (this->getItemId <= GI_MEDALLION_SPIRIT)) { - temp1 = NA_BGM_MEDALLION_GET | 0x900; - } - // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare - if ((this->getItemId >= GI_STONE_KOKIRI) && (this->getItemId <= GI_STONE_ZORA)) { - temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; - } - // If the item we're getting is a song, play the "learned a song" fanfare - if ((this->getItemId >= GI_ZELDAS_LULLABY) && (this->getItemId <= GI_PRELUDE_OF_LIGHT)) { - temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; - } - } + Audio_PlayFanfare_Rando(this->getItemId); + } else { + Audio_PlayFanfare(temp1); } - - Audio_PlayFanfare(temp1); } } else {