Improve sorting
Some checks failed
Build Dusk / run-tests (push) Successful in 1m53s
Build Dusk / build-linux (push) Successful in 1m35s
Build Dusk / build-psp (push) Failing after 1m50s

This commit is contained in:
2026-01-06 11:30:26 -06:00
parent 0df7845f2c
commit 5e39097faa
5 changed files with 103 additions and 24 deletions

View File

@@ -10,6 +10,13 @@
#define ITEM_STACK_QUANTITY_MAX UINT8_MAX
typedef enum {
INVENTORY_SORT_BY_ID,
INVENTORY_SORT_BY_TYPE,
INVENTORY_SORT_COUNT
} inventorysort_t;
typedef struct {
itemid_t item;
uint8_t quantity;
@@ -103,15 +110,14 @@ bool_t inventoryIsFull(const inventory_t *inventory);
bool_t inventoryItemFull(const inventory_t *inventory, const itemid_t item);
/**
* Sorts the inventory by item ID in ascending order.
* Sorts the inventory based on the specified criteria.
*
* @param inventory The inventory to sort.
* @param sortBy The sorting criteria.
* @param reverse Whether to sort in reverse order.
*/
void inventorySortById(inventory_t *inventory);
/**
* Sorts the inventory by item type in ascending order.
*
* @param inventory The inventory to sort.
*/
void inventorySortByType(inventory_t *inventory);
void inventorySort(
inventory_t *inventory,
const inventorysort_t sortBy,
const bool_t reverse
);