Skip to content

Commit

Permalink
Check Tracker Re-update (#4322)
Browse files Browse the repository at this point in the history
* Update check status in the check tracker to the new system. Status and Skipped are now stored in ItemLocation, though still saved separately in the trackerData section.

* Fix shop checks not showing prices when identified.

* Patch fix for check status bleed.
Some cleanup of unused code.

* Small tracker optimizations.

* Fix check hiding.

* Bit more cleanup.

* Unhide the filter and make it work again...

* Fix area totals tracking.
Fix skipped status saving.

* Merge conflict cleanup.
  • Loading branch information
Malkierian authored Sep 17, 2024
1 parent 9c11718 commit 4148d59
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 262 deletions.
2 changes: 1 addition & 1 deletion soh/include/z64save.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum { // Pre-existing IDs for save sections in base code
SECTION_ID_STATS,
SECTION_ID_ENTRANCES,
SECTION_ID_SCENES,
SECTION_ID_TRACKER_DATA,
SECTION_ID_MAX
} SaveFuncIDs;

Expand Down Expand Up @@ -279,7 +280,6 @@ typedef struct {
/* */ u8 pendingIceTrapCount;
/* */ SohStats sohStats;
/* */ FaroresWindData backupFW;
/* */ RandomizerCheckTrackerData checkTrackerData[RC_MAX];
// #endregion
// #region SOH [Randomizer]
// Upstream TODO: Move these to their own struct or name to more obviously specific to Randomizer
Expand Down
28 changes: 16 additions & 12 deletions soh/soh/Enhancements/randomizer/hook_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) {
auto loc = Rando::Context::GetInstance()->GetItemLocation(randomizerQueuedCheck);
if (randomizerQueuedItemEntry.modIndex == receivedItemEntry.modIndex && randomizerQueuedItemEntry.itemId == receivedItemEntry.itemId) {
SPDLOG_INFO("Item received mod {} item {} from RC {}", receivedItemEntry.modIndex, receivedItemEntry.itemId, static_cast<uint32_t>(randomizerQueuedCheck));
loc->MarkAsObtained();
loc->SetCheckStatus(RCSHOW_COLLECTED);
CheckTracker::RecalculateAllAreaTotals();
SaveManager::Instance->SaveSection(gSaveContext.fileNum, SECTION_ID_TRACKER_DATA, true);
randomizerQueuedCheck = RC_UNKNOWN_CHECK;
randomizerQueuedItemEntry = GET_ITEM_NONE;
}
Expand Down Expand Up @@ -662,7 +664,8 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void
*should = false;
} else {
*should = true;
Rando::Context::GetInstance()->GetItemLocation(RC_TOT_MASTER_SWORD)->MarkAsObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_TOT_MASTER_SWORD)->SetCheckStatus(RCSHOW_COLLECTED);
CheckTracker::RecalculateAllAreaTotals();
}
break;
case VB_ITEM00_DESPAWN: {
Expand Down Expand Up @@ -1179,25 +1182,26 @@ void RandomizerOnSceneInitHandler(int16_t sceneNum) {
// probably need to do something different when we implement shuffle
if (sceneNum == SCENE_TREASURE_BOX_SHOP) {
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_ITEM_1);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_1)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_1)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_ITEM_2);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_2)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_2)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_ITEM_3);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_3)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_3)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_ITEM_4);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_4)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_4)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_ITEM_5);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_5)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_5)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_KEY_1);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_1)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_1)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_KEY_2);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_2)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_2)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_KEY_3);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_3)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_3)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_KEY_4);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_4)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_4)->SetCheckStatus(RCSHOW_UNCHECKED);
Flags_UnsetRandomizerInf(RAND_INF_MARKET_TREASURE_CHEST_GAME_KEY_5);
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_5)->MarkAsNotObtained();
Rando::Context::GetInstance()->GetItemLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_5)->SetCheckStatus(RCSHOW_UNCHECKED);
CheckTracker::RecalculateAllAreaTotals();
}

// LACs & Prelude checks
Expand Down
21 changes: 15 additions & 6 deletions soh/soh/Enhancements/randomizer/item_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,23 @@ void ItemLocation::SetCustomPrice(const uint16_t price_) {
}

bool ItemLocation::HasObtained() const {
return obtained;
return status == RCSHOW_COLLECTED || status == RCSHOW_SAVED;
}

void ItemLocation::MarkAsObtained() {
obtained = true;
void ItemLocation::SetCheckStatus(RandomizerCheckStatus status_) {
status = status_;
}

void ItemLocation::MarkAsNotObtained() {
obtained = false;
RandomizerCheckStatus ItemLocation::GetCheckStatus() {
return status;
}

void ItemLocation::SetIsSkipped(bool isSkipped_) {
isSkipped = isSkipped_;
}

bool ItemLocation::GetIsSkipped() {
return isSkipped;
}

bool ItemLocation::IsHintable() const {
Expand Down Expand Up @@ -213,6 +221,7 @@ void ItemLocation::ResetVariables() {
wothCandidate = false;
barrenCandidate = false;
area = RA_NONE;
obtained = false;
status = RCSHOW_UNCHECKED;
isSkipped = false;
}
}
9 changes: 6 additions & 3 deletions soh/soh/Enhancements/randomizer/item_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class ItemLocation {
bool HasCustomPrice() const;
void SetCustomPrice(uint16_t price_);
bool HasObtained() const;
void MarkAsObtained();
void MarkAsNotObtained();
void SetCheckStatus(RandomizerCheckStatus status_);
RandomizerCheckStatus GetCheckStatus();
void SetIsSkipped(bool isSkipped_);
bool GetIsSkipped();
bool IsHintable() const;
void SetAsHintable();
bool IsAHintAccessible() const;
Expand Down Expand Up @@ -70,6 +72,7 @@ class ItemLocation {
bool visibleInImGui = false;
bool wothCandidate = false;
bool barrenCandidate = false;
bool obtained = false;
RandomizerCheckStatus status = RCSHOW_UNCHECKED;
bool isSkipped = false;
};
} // namespace Rando
2 changes: 0 additions & 2 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ std::set<RandomizerCheck> spoilerExcludedLocations;
std::set<RandomizerTrick> enabledTricks;
std::set<RandomizerTrick> enabledGlitches;

std::set<std::map<RandomizerCheck, RandomizerCheckTrackerData>> checkTrackerStates;

u8 generated;
char* seedString;

Expand Down
27 changes: 10 additions & 17 deletions soh/soh/Enhancements/randomizer/randomizerTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ typedef struct {
uint8_t id;
} Sprite;

// Check tracker check visibility categories
typedef enum {
RCSHOW_UNCHECKED,
RCSHOW_SEEN,
RCSHOW_IDENTIFIED,
RCSHOW_SCUMMED,
RCSHOW_COLLECTED,
RCSHOW_SAVED,
} RandomizerCheckStatus;

typedef enum {
HINT_TYPE_HINT_KEY,
HINT_TYPE_AREA,
Expand Down Expand Up @@ -315,6 +305,16 @@ typedef enum {
RCAREA_INVALID
} RandomizerCheckArea;

// Check tracker check visibility categories
typedef enum {
RCSHOW_UNCHECKED,
RCSHOW_SEEN,
RCSHOW_IDENTIFIED,
RCSHOW_SCUMMED,
RCSHOW_COLLECTED,
RCSHOW_SAVED,
} RandomizerCheckStatus;

typedef enum {
RR_NONE,
RR_ROOT,
Expand Down Expand Up @@ -3886,13 +3886,6 @@ typedef enum {
RSK_MAX
} RandomizerSettingKey;

typedef struct {
RandomizerCheckStatus status;
uint16_t skipped;
int16_t price;
uint16_t hintItem;
} RandomizerCheckTrackerData;

//Generic Settings (any binary option can use this)
// off/on
typedef enum {
Expand Down
Loading

0 comments on commit 4148d59

Please sign in to comment.