Improve sorting
This commit is contained in:
@@ -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
|
||||
);
|
||||
Reference in New Issue
Block a user