Fix sorting bag by type (#7488)

This commit is contained in:
Martin Griffin 2025-08-05 18:24:34 +01:00 committed by GitHub
parent 7f493948ed
commit 76b8ffc12e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -146,7 +146,7 @@ const struct Item gItemsInfo[] =
.price = 0,
.description = sQuestionMarksDesc,
.pocket = POCKET_ITEMS,
.sortType = ITEM_TYPE_FIELD_USE,
.sortType = ITEM_TYPE_UNCATEGORIZED,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.iconPic = gItemIcon_QuestionMark,

View File

@ -2954,13 +2954,18 @@ static s32 CompareItemsByMost(enum Pocket pocketId, struct ItemSlot item1, struc
static s32 CompareItemsByType(enum Pocket pocketId, struct ItemSlot item1, struct ItemSlot item2)
{
if (item1.itemId == ITEM_NONE)
return 1;
else if (item2.itemId == ITEM_NONE)
return -1;
enum ItemSortType type1 = gItemsInfo[item1.itemId].sortType;
enum ItemSortType type2 = gItemsInfo[item2.itemId].sortType;
// Null and uncategorized items go last
if (type1 && !type2)
// Uncategorized items go last.
if (type1 != ITEM_TYPE_UNCATEGORIZED && type2 == ITEM_TYPE_UNCATEGORIZED)
return -1;
else if (type2 && !type1)
else if (type2 != ITEM_TYPE_UNCATEGORIZED && type1 == ITEM_TYPE_UNCATEGORIZED)
return 1;
else if (type1 < type2)
return -1;