Crossfire Server, Branches 1.12
R18729
|
Go to the source code of this file.
Functions | |
static void | build_stringlist (const char *str, char ***result_list, size_t *result_size) |
static void | check_formulae (void) |
static int | check_recipe (const recipe *rp) |
void | dump_alchemy (void) |
void | dump_alchemy_costs (void) |
static long | find_ingred_cost (const char *name) |
archetype * | find_treasure_by_name (const treasure *t, const char *name, int depth) |
void | free_all_recipes (void) |
static recipe * | get_empty_formula (void) |
recipelist * | get_formulalist (int i) |
recipe * | get_random_recipe (recipelist *rpl) |
static recipelist * | get_random_recipelist (void) |
static const char * | ingred_name (const char *name) |
void | init_formulae (void) |
static recipelist * | init_recipelist (void) |
artifact * | locate_recipe_artifact (const recipe *rp, size_t idx) |
static int | numb_ingred (const char *buf) |
int | strtoint (const char *buf) |
Variables | |
static recipelist * | formulalist |
Basic stuff for use with the alchemy code. Clearly some of this stuff could go into server/alchemy, but I left it here just in case it proves more generally useful.
Nov 1995 - file created by b.t. thoma s@as tro.p su.e du
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 in libdir/formulae: Object transparency chance 10 ingred dust of beholdereye,gem arch potion_generic
An ingredient is a name, which can contain an initial number for how many are needed.
Definition in file recipe.c.
|
static |
Split a comma separated string list into words.
str | the string to split | |
[out] | result_list | pointer to return value for the newly created list; the caller is responsible for freeing both *result_list and **result_list. |
[out] | result_size | pointer to return value for the size of the newly created list |
Definition at line 764 of file recipe.c.
References fatal(), OUT_OF_MEMORY, and strdup_local().
Referenced by init_formulae().
|
static |
Check if formula don't have the same index.
Since we are doing a squential search on the formulae lists now, we have to be carefull that we dont 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. -b.t.
LOG() to error level.
Definition at line 265 of file recipe.c.
References recipestruct::arch_name, recipestruct::cauldron, recipestruct::index, recipeliststruct::items, llevDebug, llevError, LOG(), recipestruct::next, recipeliststruct::next, and recipestruct::title.
Referenced by init_formulae().
|
static |
Makes sure we actually have the requested artifact and archetype.
rp | recipe we want to check. |
Definition at line 134 of file recipe.c.
References recipestruct::arch_name, recipestruct::arch_names, find_archetype(), llevError, locate_recipe_artifact(), LOG(), and recipestruct::title.
Referenced by init_formulae().
void dump_alchemy | ( | void | ) |
Dumps alchemy recipes to output. Borrowed (again) from the artifacts code for this.
Definition at line 293 of file recipe.c.
References recipestruct::arch_name, recipestruct::arch_names, recipestruct::cauldron, recipestruct::chance, recipestruct::diff, recipestruct::exp, find_archetype(), formulalist, recipestruct::index, recipestruct::ingred, recipeliststruct::items, llevError, locate_recipe_artifact(), LOG(), logfile, MAX_BUF, linked_char::name, recipestruct::next, recipeliststruct::next, linked_char::next, recipeliststruct::number, recipestruct::skill, snprintf(), strtoint(), recipestruct::title, and recipeliststruct::total_chance.
Referenced by init_beforeplay().
void dump_alchemy_costs | ( | void | ) |
Dumps to output all costs of recipes.
Code copied from dump_alchemy() and modified by Raphael Quinet
Definition at line 495 of file recipe.c.
References recipestruct::arch_name, recipestruct::arch_names, recipestruct::chance, archt::clone, find_archetype(), find_ingred_cost(), formulalist, recipestruct::ingred, artifactstruct::item, recipeliststruct::items, llevError, locate_recipe_artifact(), LOG(), logfile, MAX_BUF, linked_char::name, recipestruct::next, recipeliststruct::next, linked_char::next, recipeliststruct::number, recipestruct::skill, snprintf(), recipestruct::title, recipeliststruct::total_chance, obj::value, and recipestruct::yield.
Referenced by init_beforeplay().
|
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.
name | ingredient we're searching for. Can start with a number. |
Definition at line 416 of file recipe.c.
References archt::clone, find_treasure_by_name(), first_archetype, first_artifactlist, isqrt(), artifactstruct::item, artifactliststruct::items, treasureliststruct::items, obj::level, obj::name, artifactstruct::next, artifactliststruct::next, archt::next, obj::randomitems, snprintf(), strcasecmp(), obj::title, artifactliststruct::type, obj::type, and obj::value.
Referenced by dump_alchemy_costs().
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).
t | item of treasure list to search from |
name | name we're trying to find. Doesn't need to be a shared string. |
depth | current depth. Code will exit if greater than 10. |
Definition at line 365 of file recipe.c.
References archt::clone, find_treasure_by_name(), find_treasurelist(), treasurestruct::item, treasureliststruct::items, treasurestruct::name, obj::name, treasurestruct::next, treasurestruct::next_no, treasurestruct::next_yes, and strcasecmp().
Referenced by find_ingred_cost(), and find_treasure_by_name().
void free_all_recipes | ( | void | ) |
Frees all memory allocated to recipes and recipes lists.
Definition at line 721 of file recipe.c.
References recipestruct::arch_name, recipestruct::cauldron, formulalist, free_string(), recipestruct::ingred, recipeliststruct::items, llevDebug, LOG(), linked_char::name, recipestruct::next, recipeliststruct::next, linked_char::next, recipestruct::skill, and recipestruct::title.
Referenced by cleanup().
|
static |
Allocates a new recipe.
Will call fatal() if memory allocation error.
Definition at line 82 of file recipe.c.
References recipestruct::arch_name, recipestruct::arch_names, recipestruct::cauldron, recipestruct::chance, recipestruct::diff, recipestruct::exp, fatal(), recipestruct::index, recipestruct::ingred, recipestruct::keycode, recipestruct::next, OUT_OF_MEMORY, recipestruct::skill, recipestruct::title, recipestruct::transmute, and recipestruct::yield.
Referenced by init_formulae().
recipelist* get_formulalist | ( | int | i | ) |
Gets a formula list by ingredients count.
i | number of ingredients. |
Definition at line 112 of file recipe.c.
References formulalist, and recipeliststruct::next.
Referenced by alchemy_failure_effect(), attempt_do_alchemy(), CREResourcesWindow::fillFormulae(), get_random_recipelist(), and make_formula_book().
recipe* get_random_recipe | ( | recipelist * | rpl | ) |
Gets a random recipe from a list, based on chance.
rpl | recipelist we want a recipe from. Can be NULL in which case a random one is selected. |
Definition at line 697 of file recipe.c.
References recipestruct::chance, get_random_recipelist(), recipeliststruct::items, recipestruct::next, and recipeliststruct::total_chance.
Referenced by alchemy_failure_effect().
|
static |
Gets a random recipe list.
Definition at line 661 of file recipe.c.
References get_formulalist(), llevError, LOG(), recipeliststruct::next, and recipeliststruct::total_chance.
Referenced by get_random_recipe().
|
static |
Extracts the name from an ingredient.
name | ingredient to extract from. Can contain a number at start. |
Definition at line 581 of file recipe.c.
Referenced by strtoint().
void init_formulae | ( | void | ) |
Builds up the lists of formula from the file in the libdir. -b.t.
Definition at line 159 of file recipe.c.
References add_string(), recipestruct::arch_name, recipestruct::arch_names, build_stringlist(), recipestruct::cauldron, recipestruct::chance, check_formulae(), check_recipe(), close_and_delete(), Settings::datadir, recipestruct::diff, recipestruct::exp, formulalist, get_empty_formula(), recipestruct::index, recipestruct::ingred, init_recipelist(), recipeliststruct::items, recipestruct::keycode, llevDebug, llevError, LOG(), MAX_BUF, linked_char::name, recipestruct::next, recipeliststruct::next, linked_char::next, numb_ingred(), recipeliststruct::number, open_and_uncompress(), settings, recipestruct::skill, snprintf(), strtoint(), recipestruct::title, recipeliststruct::total_chance, recipestruct::transmute, and recipestruct::yield.
Referenced by init_beforeplay(), and main().
|
static |
Allocates a new recipelist.
Will call fatal() if memory allocation error.
Definition at line 63 of file recipe.c.
References fatal(), recipeliststruct::items, recipeliststruct::next, recipeliststruct::number, OUT_OF_MEMORY, and recipeliststruct::total_chance.
Referenced by init_formulae().
Finds an artifact for a recipe.
rp | recipe |
idx | index of ingredient in recipe. |
Definition at line 637 of file recipe.c.
References recipestruct::arch_name, create_archetype(), find_artifactlist(), free_object(), artifactstruct::item, artifactliststruct::items, legal_artifact_combination(), obj::name, artifactstruct::next, recipestruct::title, and obj::type.
Referenced by check_recipe(), dump_alchemy(), dump_alchemy_costs(), and make_item_from_recipe().
|
static |
Extracts the number part of an ingredient.
buf | ingredient. |
Definition at line 597 of file recipe.c.
Referenced by init_formulae(), and strtoint().
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).
buf | buffer we want to convert. Can contain an initial number. |
Definition at line 616 of file recipe.c.
References ingred_name(), numb_ingred(), and tolower.
Referenced by add_book_to_list(), calc_alch_danger(), content_recipe_value(), dump_alchemy(), find_title(), and init_formulae().
|
static |
Pointer to first recipelist.
Definition at line 53 of file recipe.c.
Referenced by dump_alchemy(), dump_alchemy_costs(), free_all_recipes(), get_formulalist(), and init_formulae().