13void init_ability(
ability_t* ability,
char* name,
int roll_amount,
int accuracy,
int resource_cost, dice_size_t dice_size, damage_type_t damage_type);
17 NULL_PTR_HANDLER_RETURN(memory_pool, NULL,
"Ability",
"Memory pool is NULL");
20 NULL_PTR_HANDLER_RETURN(rows, NULL,
"Ability",
"Could not fetch ability data from DB");
23 NULL_PTR_HANDLER_RETURN(table, NULL,
"Ability",
"Failed to allocate memory for ability table");
26 for (
int i = 0; i < MAX_ABILITIES; ++i) {
27 if (rows[i].name == NULL)
30 const int slot = rows[i].ability_number;
36 rows[i].resource_cost,
46 NULL_PTR_HANDLER_RETURN(memory_pool, ,
"Ability",
"In free_ability_table memory pool is NULL");
47 NULL_PTR_HANDLER_RETURN(table, ,
"Ability",
"In free_ability_table table is NULL");
62void init_ability(
ability_t* ability,
char* name,
const int roll_amount,
const int accuracy,
const int resource_cost,
const dice_size_t dice_size,
const damage_type_t damage_type) {
63 NULL_PTR_HANDLER_RETURN(ability, ,
"Ability",
"In init_ability ability is NULL");
64 NULL_PTR_HANDLER_RETURN(name, ,
"Ability",
"In init_ability name is NULL");
66 snprintf(ability->name,
sizeof(ability->name),
"%s", name);
67 ability->roll_amount = roll_amount;
68 ability->accuracy = accuracy;
69 ability->resource_cost = resource_cost;
70 ability->dice_size = dice_size;
71 ability->damage_type = damage_type;
void init_ability(ability_t *ability, char *name, int roll_amount, int accuracy, int resource_cost, dice_size_t dice_size, damage_type_t damage_type)
Initializes an ability with the given parameters.
void free_ability_table(memory_pool_t *memory_pool, ability_table_t *table)
Free the ability table, deallocates memory in the memory pool.
ability_table_t * init_ability_table(memory_pool_t *memory_pool, const db_connection_t *db_connection)
Initialize the ability table, allocates memory and returns the pointer to the table.
Exposes functions for working with abilities.
ability_init_t * get_ability_table_from_db(const db_connection_t *db_connection)
Get the ability table from the database.
void free_ability_table_from_db(ability_init_t *ability_init_table)
Clean up the ability table Call this function to free the memory allocated for the ability table.
Declares functions to load and free ability definitions from the game database.
void * memory_pool_alloc(memory_pool_t *pool, size_t size)
Allocates memory on the given memory pool.
void memory_pool_free(memory_pool_t *pool, void *ptr)
Sets the given data pointer to not active in the given memory pool.
To get the ability table from the database, we need to define a struct This struct is for the initial...
This struct is used for the database connection in SQLite.