summaryrefslogtreecommitdiff
path: root/src/Game/UI/uiPauseMenuDataMgr.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-01-10 14:36:11 +0100
committerLéo Lam <leo@leolam.fr>2021-01-10 22:58:11 +0100
commitdd653e871f830b28968d32632caf68c02aaf8bba (patch)
treec8069881da8cea034d61725c1c79ec0ee3e22919 /src/Game/UI/uiPauseMenuDataMgr.cpp
parent29817a3e21f73d061f68e80d372b21060abd0efd (diff)
uking/ui: Fix minor accuracy issue (don't use memcpy)
Still matches, but the original code didn't use memcpy (according to the Wii U version)
Diffstat (limited to 'src/Game/UI/uiPauseMenuDataMgr.cpp')
-rw-r--r--src/Game/UI/uiPauseMenuDataMgr.cpp15
1 files changed, 8 insertions, 7 deletions
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<SortPredicate, 7> sSortPredicates{
- {sortWeapon, sortBow, sortShield, sortArmor, sortMaterial, sortFood, sortKeyItem}};
-
static PouchCategory getTypeForCategory(PouchItemType type) {
static constexpr sead::SafeArray<PouchCategory, NumPouchItemTypes> sMap{{
PouchCategory::Weapon, // Weapon
@@ -483,6 +480,12 @@ static PouchCategory getTypeForCategory(PouchItemType type) {
return sMap[s32(type)];
}
+static auto getSortPredicateTable() {
+ sead::SafeArray<SortPredicate, 7> 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));