DungeonCrawl
|
Implementation of the gear system. More...
#include "gear.h"
#include "../database/game/item_database.h"
#include "../logging/logger.h"
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
gear_t * | init_gear (memory_pool_t *memory_pool, const char *name, gear_identifier_t gear_identifier, gear_slot_t slot, stats_t stats, defenses_t defenses, ability_table_t *ability_table, ability_names_t *abilities, int num_abilities) |
Initializes a gear object. | |
gear_table_t * | init_gear_table (memory_pool_t *memory_pool, const db_connection_t *db_connection, ability_table_t *ability_table) |
Initializes a gear table. | |
void | free_gear_table (memory_pool_t *memory_pool, gear_table_t *table) |
Frees the memory allocated for a gear table. | |
const char * | gear_slot_to_string (gear_slot_t slot) |
Converts a gear slot enumeration value to its string representation. |
Implementation of the gear system.
Definition in file gear.c.
void free_gear_table | ( | memory_pool_t * | memory_pool, |
gear_table_t * | table ) |
Frees the memory allocated for a gear table.
This function releases all memory associated with a gear_table_t object, including the memory for each individual gear object and the table itself. It ensures that the memory pool and table pointers are not NULL before attempting to free memory.
memory_pool | A pointer to the memory pool used for memory allocation. |
table | A pointer to the gear_table_t object to be freed. |
Definition at line 74 of file gear.c.
const char * gear_slot_to_string | ( | gear_slot_t | slot | ) |
Converts a gear slot enumeration value to its string representation.
This function takes a gear_slot_t enumeration value and returns a human-readable string that represents the corresponding gear slot. If the provided slot does not match any known value, the function returns "Unknown Slot".
slot | The gear slot enumeration value of type gear_slot_t. |
Definition at line 86 of file gear.c.
gear_t * init_gear | ( | memory_pool_t * | memory_pool, |
const char * | name, | ||
gear_identifier_t | gear_identifier, | ||
gear_slot_t | slot, | ||
stats_t | stats, | ||
defenses_t | defenses, | ||
ability_table_t * | ability_table, | ||
ability_names_t * | abilities, | ||
int | num_abilities ) |
Initializes a gear object.
This function creates and initializes a new gear_t object with the specified parameters. It allocates memory, sets the properties of the object, and links it with the provided abilities.
memory_pool | A pointer to the memory pool used for memory allocation. |
name | The name of the gear as a string. |
gear_identifier | The unique identifier of the gear of type gear_identifier_t. |
slot | The slot in which the gear will be equipped, of type gear_slot_t. |
stats | The base stats of the gear, of type stats_t. |
defenses | The defense values of the gear, of type defenses_t. |
ability_table | A pointer to the ability table containing the available abilities. |
abilities | An array of ability names to be assigned to the gear. |
num_abilities | The number of abilities to be assigned to the gear. |
Definition at line 14 of file gear.c.
gear_table_t * init_gear_table | ( | memory_pool_t * | memory_pool, |
const db_connection_t * | db_connection, | ||
ability_table_t * | ability_table ) |
Initializes a gear table.
This function creates and initializes a gear_table_t object by fetching gear data from the database, allocating memory for the table, and populating it with gear objects.
memory_pool | A pointer to the memory pool used for memory allocation. |
db_connection | A pointer to the database connection used to fetch gear data. |
ability_table | A pointer to the ability table containing the available abilities. |
Definition at line 45 of file gear.c.