summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-02-27 23:32:26 +0100
committerLéo Lam <leo@leolam.fr>2022-02-27 23:32:51 +0100
commit63bf3d2fa491c08c128ede28c04a899d24d3a242 (patch)
tree176886c597de0129417fa36b5c1222e3bc1ba04c /src
parenta1fd80bd1ced02639a8336c3ed2c19706b478e05 (diff)
Match PauseMenuDataMgr::removeGrabbedItem
Diffstat (limited to 'src')
-rw-r--r--src/Game/UI/uiPauseMenuDataMgr.cpp60
1 files changed, 29 insertions, 31 deletions
diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp
index 87855c27..b6252223 100644
--- a/src/Game/UI/uiPauseMenuDataMgr.cpp
+++ b/src/Game/UI/uiPauseMenuDataMgr.cpp
@@ -1338,44 +1338,42 @@ void PauseMenuDataMgr::removeGrabbedItems() {
saveToGameData(items);
}
-// NON_MATCHING: mostly branching (which leads to other differences), but visibly equivalent
bool PauseMenuDataMgr::removeGrabbedItem(ksys::act::BaseProcLink* link) {
- if (!link || !link->hasProc())
- return false;
-
- ksys::act::ActorConstDataAccess accessor;
- ksys::act::acquireActor(link, &accessor);
- const auto name = accessor.getName();
- auto& cs = mCritSection;
- const auto& items = getItems();
bool found = false;
+ if (link && link->hasProc()) {
+ ksys::act::ActorConstDataAccess accessor;
+ ksys::act::acquireActor(link, &accessor);
+ const auto name = accessor.getName();
+ auto& cs = mCritSection;
+ const auto& items = getItems();
- for (s32 i = 0; i < NumGrabbableItems; ++i) {
- auto& entry = mGrabbedItems[i];
- if (found) {
- mGrabbedItems[i - 1].item = entry.item;
- mGrabbedItems[i - 1]._8 = entry._8;
- mGrabbedItems[i - 1]._9 = entry._9;
- continue;
- }
+ for (s32 i = 0; i < NumGrabbableItems; ++i) {
+ auto& entry = mGrabbedItems[i];
+ if (found) {
+ mGrabbedItems[i - 1].item = entry.item;
+ mGrabbedItems[i - 1]._8 = entry._8;
+ mGrabbedItems[i - 1]._9 = entry._9;
+ continue;
+ }
- if (!entry.item || name != entry.item->getName())
- continue;
+ if (!entry.item || name != entry.item->getName())
+ continue;
- if (entry.item->getValue() == 0 && !entry._9) {
- const auto lock = sead::makeScopedLock(cs);
- auto* item = entry.item;
- destroyAndRecycleItem(mItemLists, item);
- updateInventoryInfo(items);
- updateListHeads();
- saveToGameData(items);
- mLastAddedItem = nullptr;
- }
+ if (entry.item->getValue() == 0 && !entry._9) {
+ const auto lock = sead::makeScopedLock(cs);
+ auto* item = entry.item;
+ destroyAndRecycleItem(mItemLists, item);
+ updateInventoryInfo(items);
+ updateListHeads();
+ saveToGameData(items);
+ mLastAddedItem = nullptr;
+ }
- found = true;
- entry = {};
+ found = true;
+ entry = {};
+ }
+ mGrabbedItems[4] = {};
}
- mGrabbedItems[4] = {};
return found;
}