From 9325e6d0a51243c35a4757adf75611c8fb0a1084 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:05:15 -0500 Subject: [PATCH] fix: don't show duplicate gregs on item tracker (#2498) Co-authored-by: briaguya --- .../randomizer/randomizer_item_tracker.cpp | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index e074b298e..0c81e8139 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -9,6 +9,7 @@ #include #include #include +#include extern "C" { #include @@ -855,14 +856,14 @@ void UpdateVectors() { if (CVarGetInteger("gItemTrackerDungeonItemsDisplayType", 0) == 1) { mainWindowItems.insert(mainWindowItems.end(), dungeonItems.begin(), dungeonItems.end()); } - if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 1) { - // insert empty items until we're on a new row for greg - while (mainWindowItems.size() % 6) { - mainWindowItems.push_back(ITEM_TRACKER_ITEM(ITEM_NONE, 0, DrawItem)); - } - mainWindowItems.insert(mainWindowItems.end(), gregItems.begin(), gregItems.end()); - } - if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 2) { + + // if we're adding greg to the misc window, + // and misc isn't on the main window, + // and it doesn't already have greg, add him + if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 2 && + CVarGetInteger("gItemTrackerMiscItemsDisplayType", 1) != 1 && + std::none_of(miscItems.begin(), miscItems.end(), [](ItemTrackerItem item){return item.id == ITEM_RUPEE_GREEN;})) { + miscItems.insert(miscItems.end(), gregItems.begin(), gregItems.end()); } else { for (auto it = miscItems.begin(); it != miscItems.end();) { @@ -874,6 +875,17 @@ void UpdateVectors() { } } + // if we're adding greg to the main window + if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 1) { + // insert empty items until we're on a new row for greg + while (mainWindowItems.size() % 6) { + mainWindowItems.push_back(ITEM_TRACKER_ITEM(ITEM_NONE, 0, DrawItem)); + } + + // add greg + mainWindowItems.insert(mainWindowItems.end(), gregItems.begin(), gregItems.end()); + } + shouldUpdateVectors = false; }