From 7d2170c82b682c04331c32239421a28963e91b7d Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sat, 20 Aug 2022 17:24:12 -0400 Subject: [PATCH 1/5] Stops syncing GS Flags with GS Token Count with Skullsanity on. --- .../Enhancements/debugger/debugSaveEditor.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index e1d2b8060..174aa63d0 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -911,15 +911,19 @@ void DrawFlagsTab() { setMask <<= 1; } - static bool keepGsCountUpdated = true; - ImGui::Checkbox("Keep GS Count Updated", &keepGsCountUpdated); - InsertHelpHoverText("Automatically adjust the number of gold skulltula tokens acquired based on set flags"); - int32_t gsCount = 0; - if (keepGsCountUpdated) { - for (int32_t gsFlagIndex = 0; gsFlagIndex < 6; gsFlagIndex++) { - gsCount += std::popcount(static_cast(gSaveContext.gsFlags[gsFlagIndex])); + // If playing a Randomizer Save with Shuffle Skull Tokens on anything other than "Off" we don't want to keep + // GS Token Count updated, since Gold Skulltulas killed will not correlate to GS Tokens Collected. + if (!(gSaveContext.n64ddFlag && OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SHUFFLE_TOKENS))) { + static bool keepGsCountUpdated = true; + ImGui::Checkbox("Keep GS Count Updated", &keepGsCountUpdated); + InsertHelpHoverText("Automatically adjust the number of gold skulltula tokens acquired based on set flags."); + int32_t gsCount = 0; + if (keepGsCountUpdated) { + for (int32_t gsFlagIndex = 0; gsFlagIndex < 6; gsFlagIndex++) { + gsCount += std::popcount(static_cast(gSaveContext.gsFlags[gsFlagIndex])); + } + gSaveContext.inventory.gsTokens = gsCount; } - gSaveContext.inventory.gsTokens = gsCount; } }); From 01dbfc71adbab509e756cf2082d47563e4b4c020 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 22 Aug 2022 19:32:42 -0400 Subject: [PATCH 2/5] Documents our new GiveItemEntry fuctions. --- soh/include/functions.h | 1 + soh/src/code/z_actor.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/soh/include/functions.h b/soh/include/functions.h index 66d278eb6..a336cb1ef 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -454,6 +454,7 @@ u32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx); s8 func_8002F368(GlobalContext* globalCtx); void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y); u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); +// TODO: Rename the follwing 3 functions using whatever scheme we use when we rename func_8002F434 and func_8002F554. s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry); s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange); void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry); diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 7e92a6941..950dd2525 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -1955,6 +1955,15 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { } } +/** + * Uses the given `GetItemEntry` to prepare the player to receive an item via the animation + * where Link holds an item over his head. This function does not require an actor for giving + * the player an item, instead setting the player as their own interactRangeActor and getItemDirection. + * + * \param globalCtx the Global Context + * \param getItemEntry the GetItemEntry for the item you want the player to receive. + * \return true if the player can receive an item, false if not. + */ s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry) { Player* player = GET_PLAYER(globalCtx); @@ -1975,6 +1984,22 @@ s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntr return false; } +/** + * Uses the given `GetItemEntry` to prepare the player to receive an item via the animation + * where Link holds an item over his head. This uses data from the actor link is receiving + * the item from to set the player's interactRangeActor and getItemDirection. It also checks + * a range from which Link must be from said actor in order to receive the item. + * + * \param actor the actor link is receiving an item from. Will usually be a chest but can also + * be an npc. + * \param globalCtx the Global Context + * \param getItemEntry the GetItemEntry for the item you want the player to receive. + * \param xzRange the distance on the x and z axes that the player can be from the target + * actor to receive the item. + * \param yRange the distance on the y axis that the player can be from the target actor + * to receive the item. + * \return true if the player can receive an item, false if not. + */ s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(globalCtx); @@ -2001,6 +2026,15 @@ s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry return false; } +/** + * Uses the given `GetItemEntry` to prepare the player to receive an item via the animation + * where Link holds an item over his head. This is a wrapper function around `GiveItemEntryFromActor` + * that supplies a fixed xzRange of 50.0f and a fixed yRange of 10.0f. + * + * \param actor the target actor that link is receiving an item from. + * \param globalCtx the Global Context + * \param getItemEntry the GetItemEntry for the item you want the player to receive. + */ void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry) { GiveItemEntryFromActor(actor, globalCtx, getItemEntry, 50.0f, 10.0f); } From 10c05892bfa9b8ad5c11884bbda8391b0f17ac98 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 22 Aug 2022 19:38:30 -0400 Subject: [PATCH 3/5] Uses more descriptive type name for ItemIDs for creating custom messages. --- soh/soh/Enhancements/custom-message/CustomMessageManager.cpp | 4 ++-- soh/soh/Enhancements/custom-message/CustomMessageManager.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp index 7c36fe209..00c7153ea 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp +++ b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp @@ -47,7 +47,7 @@ void CustomMessageManager::ReplaceColors(std::string& string) { } } -void CustomMessageManager::FormatCustomMessage(std::string& message, uint16_t iid) { +void CustomMessageManager::FormatCustomMessage(std::string& message, ItemID iid) { message.insert(0, ITEM_OBTAINED(iid)); size_t start_pos = 0; std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); @@ -81,7 +81,7 @@ bool CustomMessageManager::InsertCustomMessage(std::string tableID, uint16_t tex return messageInsertResult.second; } -bool CustomMessageManager::CreateGetItemMessage(std::string tableID, uint16_t giid, uint16_t iid, +bool CustomMessageManager::CreateGetItemMessage(std::string tableID, uint16_t giid, ItemID iid, CustomMessageEntry messageEntry) { FormatCustomMessage(messageEntry.english, iid); FormatCustomMessage(messageEntry.german, iid); diff --git a/soh/soh/Enhancements/custom-message/CustomMessageManager.h b/soh/soh/Enhancements/custom-message/CustomMessageManager.h index 76a613105..389457d00 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom-message/CustomMessageManager.h @@ -89,7 +89,7 @@ class CustomMessageManager { with the provided giid (getItemID) as its key. This function also inserts the icon corresponding to the provided iid (itemID) at the beginning of each page of the textbox. */ - bool CreateGetItemMessage(std::string tableID, uint16_t giid, uint16_t iid, CustomMessageEntry messages); + bool CreateGetItemMessage(std::string tableID, uint16_t giid, ItemID iid, CustomMessageEntry messages); /* Formats the provided Custom Message Entry and inserts it into the table with the provided tableID, @@ -122,7 +122,7 @@ class CustomMessageManager { & for newline, ^ for wait-for-input, and @ for the player name, as well as % for colors (i.e. %r for red and %w for white). */ - void FormatCustomMessage(std::string& message, uint16_t iid); + void FormatCustomMessage(std::string& message, ItemID iid); /* Replaces special characters and certain symbols with control codes From 3a67e2a806e2eb2a81cd0fb81c61db6579925249 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 22 Aug 2022 19:40:58 -0400 Subject: [PATCH 4/5] Fixes potential issue with if statement. --- soh/src/code/z_en_item00.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index be40d80f4..a50c74e87 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -510,8 +510,10 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { } if (!Actor_HasParent(&this->actor, globalCtx)) { - if (!gSaveContext.n64ddFlag && getItemId != GI_NONE) { - func_8002F554(&this->actor, globalCtx, getItemId); + if (!gSaveContext.n64ddFlag) { + if (getItemId != GI_NONE) { + func_8002F554(&this->actor, globalCtx, getItemId); + } } else { getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum); GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem); From 28edabdbe4bb78ad32685e374f107b9c5b34b74e Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 23 Aug 2022 00:08:22 -0400 Subject: [PATCH 5/5] Fixes missed type change. --- soh/soh/Enhancements/custom-message/CustomMessageTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/custom-message/CustomMessageTypes.h b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h index bc56964fe..39dceea1d 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageTypes.h +++ b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h @@ -18,7 +18,7 @@ typedef enum { typedef struct { u16 giid; - u16 iid; + ItemID iid; std::string english; std::string german; std::string french;