summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEblo <7004497+Eblo@users.noreply.github.com>2026-01-04 08:52:18 -0500
committerGitHub <noreply@github.com>2026-01-04 08:52:18 -0500
commit722306e606bb5eee0c0a4db17cfb387d6ed0c02d (patch)
treec9b3efbcedf00c48a85f0db3c8b8f488d678b04e
parentdd5c0f152a788780ef4dac22dd9c902c2d15f0be (diff)
Exclude Triforce from plentiful items, add error handling (#1433)
* Exclude Triforce from plentiful, add error handling * Add max check because unsigned
-rw-r--r--mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp b/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp
index 6edec7fb1..3114798e9 100644
--- a/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp
+++ b/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp
@@ -280,6 +280,11 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) {
std::vector<RandoItemId> plentifulItems;
std::vector<RandoItemId> potentialPlentifulItems;
for (size_t i = 0; i < itemPool.size(); i++) {
+ // The user can specify exactly how many pieces they want to shuffle, so skip those
+ if (Rando::StaticData::Items[itemPool[i]].randoItemId == RI_TRIFORCE_PIECE) {
+ continue;
+ }
+
switch (Rando::StaticData::Items[itemPool[i]].randoItemType) {
case RITYPE_BOSS_KEY:
case RITYPE_SMALL_KEY:
@@ -409,6 +414,17 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) {
RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_MAX] = piecesShuffled;
RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_REQUIRED] = (piecesShuffled * currentRatio) + 1;
}
+
+ if (RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_MAX] < 1 ||
+ RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_MAX] > 1000 ||
+ RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_REQUIRED] < 1 ||
+ RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_REQUIRED] > 1000) {
+ SPDLOG_ERROR("Error with adjusting Triforce Piece placement. Resulting shuffle requires {} "
+ "pieces and out of a total of {}",
+ RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_REQUIRED],
+ RANDO_SAVE_OPTIONS[RO_TRIFORCE_PIECES_MAX]);
+ throw std::runtime_error("Invalid Triforce Piece count");
+ }
}
// Grant the starting items