diff options
| author | Michael Zhao <44533763+Pistonight@users.noreply.github.com> | 2025-05-02 20:29:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-02 20:29:16 -0700 |
| commit | 5bb38fb36b86fa878d8b26cfa08f6d6172e280f5 (patch) | |
| tree | cc1d63880480358f4adefce7a3d9a29f391abf5a /src/Game/UI/uiPauseMenuDataMgr.cpp | |
| parent | 7facffb1d6a71402c6cd143bcd8034a0f4002dca (diff) | |
| parent | 56ef34dc6b829febefcd2e9e4db92b4ece44c33b (diff) | |
Merge pull request #138 from Pistonight/pmdm_autoequip
match PMDM autoEquip and unequipAll
Diffstat (limited to 'src/Game/UI/uiPauseMenuDataMgr.cpp')
| -rw-r--r-- | src/Game/UI/uiPauseMenuDataMgr.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp index 87cc7f0e..11e6dc93 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.cpp +++ b/src/Game/UI/uiPauseMenuDataMgr.cpp @@ -1054,7 +1054,6 @@ void PauseMenuDataMgr::autoEquipLastAddedItem() { } } -// NON_MATCHING: branching const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item, const sead::OffsetList<PouchItem>& list) { const auto type = item->getType(); @@ -1064,20 +1063,30 @@ const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item, if (type >= PouchItemType::Material) return sead::SafeString::cEmptyString; - if (isPouchItemArmor(type)) { + switch (type) { + case PouchItemType::Sword: + case PouchItemType::Bow: + case PouchItemType::Shield: + case PouchItemType::Arrow: for (auto& other : list) { - if (other.getType() > PouchItemType::ArmorLower) + if (other.getType() > PouchItemType::Shield) break; if (other.getType() == type) other.mEquipped = false; } - } else if (isPouchItemWeapon(type)) { + break; + case PouchItemType::ArmorHead: + case PouchItemType::ArmorUpper: + case PouchItemType::ArmorLower: for (auto& other : list) { - if (other.getType() > PouchItemType::Shield) + if (other.getType() > PouchItemType::ArmorLower) break; if (other.getType() == type) other.mEquipped = false; } + break; + default: + break; } item->mEquipped = true; @@ -1086,7 +1095,6 @@ const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item, return sead::SafeString::cEmptyString; } -// NON_MATCHING: harmless reordering void PauseMenuDataMgr::unequipAll(PouchItemType type) { const auto lock = sead::makeScopedLock(mCritSection); @@ -1094,19 +1102,18 @@ void PauseMenuDataMgr::unequipAll(PouchItemType type) { return; for (auto& item : getItems()) { - if (type == PouchItemType::Invalid) { - if (item.getType() > PouchItemType::ArmorLower) - break; - if (item.isEquipped() && item.getType() != PouchItemType::Arrow) - item.mEquipped = false; + if (item.getType() > PouchItemType::ArmorLower) + break; + if (!item.isEquipped()) + continue; - } else { - if (item.getType() > PouchItemType::ArmorLower) - break; - if (item.isEquipped() && item.getType() == type) { + if (type == PouchItemType::Invalid) { + if (item.getType() != PouchItemType::Arrow) { item.mEquipped = false; - break; } + } else if (item.getType() == type) { + item.mEquipped = false; + break; } } } @@ -2207,6 +2214,7 @@ const sead::SafeString* PauseMenuDataMgr::getEquippedItemName(PouchItemType type if (item->isEquipped() && item->getType() == type) return &item->getName(); } + return nullptr; } |
