From 76b8ffc12ebd9fba51d204253c170e6d22fccd57 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Tue, 5 Aug 2025 18:24:34 +0100 Subject: [PATCH] Fix sorting bag by type (#7488) --- src/data/items.h | 2 +- src/item_menu.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/data/items.h b/src/data/items.h index 1a39f409b5..69806c26da 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -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, diff --git a/src/item_menu.c b/src/item_menu.c index 2ac5e27da9..5ec54f07c4 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -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;