Skip to content

Commit d2d357b

Browse files
committed
match PMDM autoEquip and unequipAll
1 parent bfb94a3 commit d2d357b

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

data/uking_functions.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56389,8 +56389,8 @@ Address,Quality,Size,Name
5638956389
0x0000007100970060,O,000248,_ZN5uking2ui16PauseMenuDataMgr11cookItemGetERKNS_8CookItemE
5639056390
0x0000007100970158,O,000268,_ZN5uking2ui16PauseMenuDataMgr26setCookDataOnLastAddedItemERKNS_8CookItemE
5639156391
0x0000007100970264,O,000116,_ZN5uking2ui16PauseMenuDataMgr22autoEquipLastAddedItemEv
56392-
0x00000071009702d8,m,000268,_ZN5uking2ui16PauseMenuDataMgr9autoEquipEPNS0_9PouchItemERKN4sead10OffsetListIS2_EE
56393-
0x00000071009703e4,m,000216,_ZN5uking2ui16PauseMenuDataMgr10unequipAllENS0_13PouchItemTypeE
56392+
0x00000071009702d8,O,000268,_ZN5uking2ui16PauseMenuDataMgr9autoEquipEPNS0_9PouchItemERKN4sead10OffsetListIS2_EE
56393+
0x00000071009703e4,O,000216,_ZN5uking2ui16PauseMenuDataMgr10unequipAllENS0_13PouchItemTypeE
5639456394
0x00000071009704bc,O,001352,_ZN5uking2ui16PauseMenuDataMgr10removeItemERKN4sead14SafeStringBaseIcEE
5639556395
0x0000007100970a04,O,000896,_ZN5uking2ui16PauseMenuDataMgr22removeWeaponIfEquippedERKN4sead14SafeStringBaseIcEE
5639656396
0x0000007100970d84,O,000512,_ZN5uking2ui16PauseMenuDataMgr11removeArrowERKN4sead14SafeStringBaseIcEEi

src/Game/UI/uiPauseMenuDataMgr.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ void PauseMenuDataMgr::autoEquipLastAddedItem() {
10541054
}
10551055
}
10561056

1057-
// NON_MATCHING: branching
10581057
const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item,
10591058
const sead::OffsetList<PouchItem>& list) {
10601059
const auto type = item->getType();
@@ -1064,20 +1063,30 @@ const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item,
10641063
if (type >= PouchItemType::Material)
10651064
return sead::SafeString::cEmptyString;
10661065

1067-
if (isPouchItemArmor(type)) {
1066+
switch (type) {
1067+
case PouchItemType::Sword:
1068+
case PouchItemType::Bow:
1069+
case PouchItemType::Shield:
1070+
case PouchItemType::Arrow:
10681071
for (auto& other : list) {
1069-
if (other.getType() > PouchItemType::ArmorLower)
1072+
if (other.getType() > PouchItemType::Shield)
10701073
break;
10711074
if (other.getType() == type)
10721075
other.mEquipped = false;
10731076
}
1074-
} else if (isPouchItemWeapon(type)) {
1077+
break;
1078+
case PouchItemType::ArmorHead:
1079+
case PouchItemType::ArmorUpper:
1080+
case PouchItemType::ArmorLower:
10751081
for (auto& other : list) {
1076-
if (other.getType() > PouchItemType::Shield)
1082+
if (other.getType() > PouchItemType::ArmorLower)
10771083
break;
10781084
if (other.getType() == type)
10791085
other.mEquipped = false;
10801086
}
1087+
break;
1088+
default:
1089+
break;
10811090
}
10821091

10831092
item->mEquipped = true;
@@ -1086,27 +1095,25 @@ const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item,
10861095
return sead::SafeString::cEmptyString;
10871096
}
10881097

1089-
// NON_MATCHING: harmless reordering
10901098
void PauseMenuDataMgr::unequipAll(PouchItemType type) {
10911099
const auto lock = sead::makeScopedLock(mCritSection);
10921100

10931101
if (type == PouchItemType::Arrow)
10941102
return;
10951103

10961104
for (auto& item : getItems()) {
1097-
if (type == PouchItemType::Invalid) {
1098-
if (item.getType() > PouchItemType::ArmorLower)
1099-
break;
1100-
if (item.isEquipped() && item.getType() != PouchItemType::Arrow)
1101-
item.mEquipped = false;
1105+
if (item.getType() > PouchItemType::ArmorLower)
1106+
break;
1107+
if (!item.isEquipped())
1108+
continue;
11021109

1103-
} else {
1104-
if (item.getType() > PouchItemType::ArmorLower)
1105-
break;
1106-
if (item.isEquipped() && item.getType() == type) {
1110+
if (type == PouchItemType::Invalid) {
1111+
if (item.getType() != PouchItemType::Arrow) {
11071112
item.mEquipped = false;
1108-
break;
11091113
}
1114+
} else if (item.getType() == type) {
1115+
item.mEquipped = false;
1116+
break;
11101117
}
11111118
}
11121119
}
@@ -2207,6 +2214,7 @@ const sead::SafeString* PauseMenuDataMgr::getEquippedItemName(PouchItemType type
22072214
if (item->isEquipped() && item->getType() == type)
22082215
return &item->getName();
22092216
}
2217+
22102218
return nullptr;
22112219
}
22122220

0 commit comments

Comments
 (0)