transfered from codeberg

This commit is contained in:
2026-03-26 14:46:39 -05:00
parent 630f28bb7e
commit 5ed2173793
136 changed files with 14932 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#include "item.h"
#include <string.h>
/**
* Initializes an item structure with specific properties.
* This function is used to populate item data from the global item registry
* into specific instances (like inventory slots or world drops).
*/
void initialize_item(item_struct *item,
uint32_t new_item_id,
uint16_t new_max_durability,
uint8_t new_max_stack,
item_type_struct new_item_type,
bool new_is_placeable)
{
memset(item, 0, sizeof(item_struct));
item->item_id = new_item_id;
item->max_durability = new_max_durability;
item->max_stack = new_max_stack;
item->item_type = new_item_type;
item->is_placeable = new_is_placeable;
}

View File

@@ -0,0 +1,57 @@
#ifndef item_h
#define item_h
#include <stdint.h>
#include <stdbool.h>
/**
* Constants defining default item behaviors and limits.
* 'no_id' represents an empty slot, while 'infinite_durability' is used
* for items like blocks or materials that do not break upon use.
*/
#define no_item_id 0
#define infinite_durability 0
#define default_max_stack_size 64
#define item_is_not_placeable false
#define item_is_placeable true
/**
* Categorizes an item to determine its behavior when the player interacts
* with the world or uses the item.
*/
typedef uint8_t item_type_struct;
enum {
item_type_block = 0,
item_type_tool = 1,
item_type_consumable = 2,
item_type_miscellaneous = 3
};
/**
* The core definition of an item instance within the game.
* This structure stores the static properties of an item, such as its
* identification, durability limits, and whether it can be placed in the
* world as a block.
*/
typedef struct item_struct {
uint32_t item_id;
uint16_t max_durability;
uint8_t max_stack;
item_type_struct item_type;
bool is_placeable;
} item_struct;
/**
* Initializes an item structure with specific properties.
* This function is used to populate item data from the global item registry
* into specific instances (like inventory slots or world drops).
*/
void initialize_item(item_struct *item,
uint32_t new_item_id,
uint16_t new_max_durability,
uint8_t new_max_stack,
item_type_struct new_item_type,
bool new_is_placeable);
#endif