diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp index 03006e8c..6e5d5740 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.cpp +++ b/src/Game/UI/uiPauseMenuDataMgr.cpp @@ -464,9 +464,6 @@ void PauseMenuDataMgr::restoreMasterSword(bool only_if_broken) { using SortPredicate = int (*)(const PouchItem* lhs, const PouchItem* rhs, ksys::act::InfoData* data); -static sead::SafeArray sSortPredicates{ - {sortWeapon, sortBow, sortShield, sortArmor, sortMaterial, sortFood, sortKeyItem}}; - static PouchCategory getTypeForCategory(PouchItemType type) { static constexpr sead::SafeArray sMap{{ PouchCategory::Weapon, // Weapon @@ -483,6 +480,12 @@ static PouchCategory getTypeForCategory(PouchItemType type) { return sMap[s32(type)]; } +static auto getSortPredicateTable() { + sead::SafeArray table{ + {sortWeapon, sortBow, sortShield, sortArmor, sortMaterial, sortFood, sortKeyItem}}; + return table; +} + int pouchItemSortPredicate(const PouchItem* lhs, const PouchItem* rhs) { if (!lhs || !rhs) return 0; @@ -500,8 +503,7 @@ int pouchItemSortPredicate(const PouchItem* lhs, const PouchItem* rhs) { if (cat3 != PouchCategory::Invalid && cat1 != cat3) return 0; - decltype(sSortPredicates) predicate_table{}; - sead::MemUtil::copy(&predicate_table, &sSortPredicates, sizeof(predicate_table)); + auto predicate_table = getSortPredicateTable(); const auto* fn = &predicate_table[0]; if (u32(cat1) < u32(predicate_table.size())) fn = &predicate_table(u32(cat1)); @@ -596,8 +598,7 @@ int pouchItemSortPredicateForArrow(const PouchItem* lhs, const PouchItem* rhs) { if (cat3 != PouchCategory::Invalid && cat1 != cat3) return 0; - decltype(sSortPredicates) predicate_table{}; - sead::MemUtil::copy(&predicate_table, &sSortPredicates, sizeof(predicate_table)); + const auto predicate_table = getSortPredicateTable(); const auto* fn = &predicate_table[0]; if (u32(cat1) < u32(predicate_table.size())) fn = &predicate_table(u32(cat1));