Atrinik Server 2.5
Functions | Variables
server/recipe.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

static void check_formulae ()
static archetypefind_treasure_by_name (treasure *t, char *name, int depth)
static long find_ingred_cost (const char *name)
static const char * ingred_name (const char *name)
static int numb_ingred (const char *buf)
static recipelistget_random_recipelist ()
static recipelistinit_recipelist ()
static recipeget_empty_formula ()
recipelistget_formulalist (int i)
static int check_recipe (recipe *rp)
void init_formulae ()
void dump_alchemy ()
void dump_alchemy_costs ()
int strtoint (const char *buf)
artifactlocate_recipe_artifact (recipe *rp)
recipeget_random_recipe (recipelist *rpl)
void free_all_recipes ()

Variables

static recipelistformulalist

Detailed Description

Basic stuff for use with the alchemy code.

Our definition of 'formula' is any product of an alchemical process. Ingredients are just comma delimited list of archetype (or object) names.

Example 'formula' entry:

 	Object transparency
	chance 10
	ingred dust of beholdereye,gem
	arch potion_generic
 

Definition in file recipe.c.


Function Documentation

static void check_formulae ( ) [static]

Check if formula doesn't have the same index.

Since we are doing a sequential search on the formulae lists now, we have to be careful that we don't have 2 formula with the exact same index value. Under the new nbatches code, it is possible to have multiples of ingredients in a cauldron which could result in an index formula mismatch. We *don't* check for that possibility here.

Definition at line 290 of file recipe.c.

static int check_recipe ( recipe rp) [static]

Makes sure we actually have the requested artifact and archetype.

Parameters:
rpRecipe we want to check.
Returns:
1 if recipe is ok, 0 if missing something.

Definition at line 123 of file recipe.c.

void dump_alchemy ( )

Dumps alchemy recipes using LOG().

Definition at line 320 of file recipe.c.

void dump_alchemy_costs ( )

Dumps all costs of recipes using LOG().

Definition at line 601 of file recipe.c.

static long find_ingred_cost ( const char *  name) [static]

Try to find an ingredient with specified name.

If several archetypes have the same name, the value of the first one with that name will be returned. This happens for the mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the monsters' body parts, there may be several monsters with the same name. This is not a problem if these monsters have the same level (e.g. sage & c_sage) or if only one of the monsters generates the body parts that we are looking for (e.g. big_dragon and big_dragon_worthless).

Will also search in artifacts.

Parameters:
nameIngredient we're searching for. Can start with a number.
Returns:
Cost of ingredient, -1 if wasn't found.

Definition at line 484 of file recipe.c.

static archetype * find_treasure_by_name ( treasure t,
char *  name,
int  depth 
) [static]

Find a treasure with a matching name. The 'depth' parameter is only there to prevent infinite loops in treasure lists (a list referencing another list pointing back to the first one).

Parameters:
tItem of treasure list to search from.
nameName we're trying to find. Doesn't need to be a shared string.
depthCurrent depth. Function will exit if greater than 10.
Returns:
Archetype with name, or NULL if nothing found.

Definition at line 414 of file recipe.c.

void free_all_recipes ( )

Frees all memory allocated to recipes and recipes lists.

Definition at line 914 of file recipe.c.

static recipe* get_empty_formula ( ) [static]

Allocates a new recipe.

Returns:
New structure initialized. Never NULL.

Definition at line 76 of file recipe.c.

recipelist* get_formulalist ( int  i)

Gets a formula list by ingredients count.

Parameters:
iNumber of ingredients.
Returns:
Pointer to the formula list, or NULL if it doesn't exist.

Definition at line 101 of file recipe.c.

recipe* get_random_recipe ( recipelist rpl)

Gets a random recipe from a list, based on chance.

Parameters:
rplRecipelist we want a recipe from. Can be NULL in which case a random one is selected.
Returns:
Random recipe. Can be NULL if recipelist has a total_chance of 0.

Definition at line 879 of file recipe.c.

static recipelist * get_random_recipelist ( ) [static]

Gets a random recipe list.

Returns:
Random recipe list.

Definition at line 827 of file recipe.c.

static const char * ingred_name ( const char *  name) [static]

Extracts the name from an ingredient.

Parameters:
nameIngredient to extract from. Can contain a number at start.
Returns:
Pointer in name to the first character of the ingredient's name.

Definition at line 744 of file recipe.c.

void init_formulae ( )

Builds up the lists of formula from the file in the libdir.

Definition at line 146 of file recipe.c.

static recipelist* init_recipelist ( ) [static]

Allocates a new recipelist.

Returns:
New structure initialized. Never NULL.

Definition at line 57 of file recipe.c.

artifact* locate_recipe_artifact ( recipe rp)

Finds an artifact for a recipe.

Parameters:
rpRecipe.
Returns:
Artifact, or NULL if not found.

Definition at line 783 of file recipe.c.

static int numb_ingred ( const char *  buf) [static]

Extracts the number part of an ingredient.

Parameters:
bufIngredient.
Returns:
Number part of an ingredient.

Definition at line 812 of file recipe.c.

int strtoint ( const char *  buf)

Convert buf into an integer equal to the coadded sum of the (lowercase) character.

ASCII values in buf (times prepended integers).

Parameters:
bufBuffer we want to convert. Can contain an initial number.
Returns:
Sum of lowercase characters of the ingredient's name.

Definition at line 763 of file recipe.c.


Variable Documentation

Pointer to first recipelist.

Definition at line 45 of file recipe.c.