transfered from codeberg
This commit is contained in:
12
source_code/inventory_module/inventory/inventory.c
Normal file
12
source_code/inventory_module/inventory/inventory.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "inventory.h"
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Prepares an inventory for use by zeroing out all slots.
|
||||
* This function ensures that every item_struct within the inventory
|
||||
* is initialized to an 'empty' or 'null' state to prevent undefined behavior.
|
||||
*/
|
||||
void create_inventory(inventory_struct *inventory)
|
||||
{
|
||||
memset(inventory, 0, sizeof(inventory_struct));
|
||||
}
|
||||
25
source_code/inventory_module/inventory/inventory.h
Normal file
25
source_code/inventory_module/inventory/inventory.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef inventory_h
|
||||
#define inventory_h
|
||||
|
||||
#include "item.h"
|
||||
|
||||
#define inventory_size 36
|
||||
|
||||
/**
|
||||
* A container structure that manages a fixed collection of items.
|
||||
* This structure acts as the primary data storage for player belongings,
|
||||
* including the hotbar and the main storage slots.
|
||||
*/
|
||||
typedef struct inventory_struct
|
||||
{
|
||||
item_struct slots[inventory_size];
|
||||
} inventory_struct;
|
||||
|
||||
/**
|
||||
* Prepares an inventory for use by zeroing out all slots.
|
||||
* This function ensures that every item_struct within the inventory
|
||||
* is initialized to an 'empty' or 'null' state to prevent undefined behavior.
|
||||
*/
|
||||
void create_inventory(inventory_struct *inventory);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user