Go to the documentation of this file.
102 while (fl && number > 1) {
103 if (!(fl = fl->
next))
127 if (strcmp(rp->
title,
"NONE")) {
180 if (*
buf ==
'#' || *
buf ==
'\0')
186 if (!strncmp(cp,
"Remove ", 7)) {
187 if (strcmp(cp + 7,
"*") == 0) {
195 if (!strncmp(cp,
"Object", 6)) {
198 }
else if (formula == NULL) {
201 }
else if (!strncmp(cp,
"keycode", 7)) {
203 }
else if (sscanf(cp,
"trans %d", &
value)) {
205 }
else if (sscanf(cp,
"yield %d", &
value)) {
207 }
else if (sscanf(cp,
"chance %d", &
value)) {
209 }
else if (sscanf(cp,
"exp %d", &
value)) {
211 }
else if (sscanf(cp,
"diff %d", &
value)) {
213 }
else if (!strncmp(cp,
"ingred", 6)) {
216 cp = strchr(cp,
' ')+1;
218 if ((
next = strchr(cp,
',')) != NULL) {
226 while (*cp !=
'\0' && cp[strlen(cp) - 1] ==
' ')
227 cp[strlen(cp) - 1] =
'\0';
236 }
while ((cp =
next) != NULL);
248 }
else if (!strncmp(cp,
"arch", 4)) {
250 }
else if (!strncmp(cp,
"skill", 5)) {
252 }
else if (!strncmp(cp,
"cauldron", 8)) {
254 }
else if (!strncmp(cp,
"failure_arch ", 13)) {
256 }
else if (!strncmp(cp,
"failure_message ", 16)) {
258 }
else if (sscanf(cp,
"min_level %d", &
value)) {
260 }
else if (!strncmp(cp,
"tool ", 5)) {
262 }
else if (sscanf(cp,
"combination %d", &
value)) {
273 for (formula = fl->
items; formula; formula = formula->
next) {
298 int numb = 1, tool_match;
299 size_t tool_i,tool_j;
304 for (formula = fl->
items; formula != NULL; formula = formula->
next) {
314 for (tool_i = 0; tool_i < formula->
tool_size; ++tool_i)
316 for (tool_j = 0; tool_j <
check->tool_size; ++tool_j)
317 if (strcmp(formula->
tool[tool_i],
check->tool[tool_j]) == 0) {
328 LOG(
llevError,
"Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n",
332 for (
size_t idx = 0; idx < formula->
arch_names; idx++) {
334 LOG(
llevError,
"Formulae %s of %s (%d ingredients) references non existent archetype %s\n",
360 fprintf(
logfile,
"\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", num_ingred, num_ingred > 1 ?
"s." :
".", fl->
number, fl->
total_chance);
361 for (formula = fl->
items; formula != NULL; formula = formula->
next) {
367 const char *
string = formula->
arch_name[i];
371 if (!art && strcmp(formula->
title,
"NONE"))
374 if (strcmp(formula->
title,
"NONE"))
375 snprintf(
buf,
sizeof(
buf),
"%s of %s",
string, formula->
title);
381 if (formula->
ingred != NULL) {
382 int nval = 0, tval = 0;
383 fprintf(
logfile,
"\tIngred: ");
391 if (tval != formula->
index)
392 fprintf(
logfile,
"WARNING:ingredient list and formula values not equal.\n");
394 if (formula->
skill != NULL)
395 fprintf(
logfile,
"\tSkill Required: %s", formula->
skill);
398 fprintf(
logfile,
"\tDifficulty: %d\t Exp: %d\n", formula->
diff, formula->
exp);
401 LOG(
llevError,
"Can't find archetype:%s for formula %s\n",
string, formula->
title);
432 if (
t->name != NULL) {
441 if (
t->next_yes != NULL) {
446 if (
t->next_no != NULL) {
483 while (isdigit(*
name)) {
484 mult = 10*mult+(*
name-
'0');
502 snprintf(part1, sizeof(part1),
"%s %s", at->clone.name, at->clone.title);
503 if (!strcasecmp(part1, name)) {
504 value = at->clone.value;
510 value = at->clone.value;
520 cp = strstr(
name,
" of ");
523 part1[cp-
name] =
'\0';
532 for (auto al = first_artifactlist; al != NULL; al = al->next) {
533 if (al->type == at->clone.type) {
534 for (const auto art : al->items) {
535 if (!strcasecmp(art->item->name, part2)) {
536 value = at->clone.value * art->item->value;
551 cp = strstr(
name,
"'s ");
554 part1[cp-
name] =
'\0';
562 if (at->clone.randomitems != NULL) {
563 auto at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
565 value = at2->clone.value * isqrt(at->clone.level * 2);
601 fprintf(
logfile,
"\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", num_ingred, num_ingred > 1 ?
"s." :
".", fl->
number, fl->
total_chance);
602 for (formula = fl->
items; formula != NULL; formula = formula->
next) {
609 const char *
string = formula->
arch_name[i];
613 if (!art && strcmp(formula->
title,
"NONE"))
616 if (!strcmp(formula->
title,
"NONE"))
619 snprintf(
buf,
sizeof(
buf),
"%s of %s",
string, formula->
title);
621 if (formula->
ingred != NULL) {
628 if (
cost < 0 || tcost < 0)
633 if (art != NULL && art->
item != NULL)
637 fprintf(
logfile,
"\t\tBuying result costs: %5ld",
cost);
638 if (formula->
yield > 1) {
643 fprintf(
logfile,
"\t\tIngredients cost: %5ld\n\t\tComment: ", tcost);
645 fprintf(
logfile,
"Could not find some ingredients. Check the formula!\n");
646 else if (tcost >
cost)
647 fprintf(
logfile,
"Ingredients are much too expensive. Useless formula.\n");
648 else if (tcost*2L >
cost)
649 fprintf(
logfile,
"Ingredients are too expensive.\n");
650 else if (tcost*10L <
cost)
651 fprintf(
logfile,
"Ingredients are too cheap.\n");
657 LOG(
llevError,
"Can't find archetype:%s for formula %s\n",
string, formula->
title);
665 fprintf(
logfile,
"WARNING: %d objects required by the formulae do not exist in the game.\n", num_errors);
677 const char *cp =
name;
680 cp = strchr(cp,
' ')+1;
695 if ((numb = atoi(
buf)))
740 for (
auto art : at->items)
755 int number = 0, roll = 0;
774 LOG(
llevError,
"get_random_recipelist(): no recipelists found!\n");
801 for (rp = fl->
items; rp; rp = rp->
next) {
822 for (formula = fl->
items; formula != NULL; formula =
next) {
837 for (lchar = formula->
ingred; lchar; lchar = charnext) {
838 charnext = lchar->
next;
843 free(formula->
tool[0]);
874 for (p = strtok(dup,
","); p != NULL; p = strtok(NULL,
","))
878 *result_list =
static_cast<char **
>(malloc(
sizeof(**result_list) * size));
879 if (*result_list == NULL)
883 for (i = 0; i < size; i++) {
884 (*result_list)[i] = dup;
885 dup = dup+strlen(dup)+1;
904 if (strcmp(test->
tool[
t], tool) == 0) {
935 if (strcmp(rp->
title,
"NONE") == 0) {
936 return arch->clone.face;
941 return arch->clone.face;
943 face =
arch->clone.face;
recipe * find_recipe_for_tool(const char *tool, recipe *from)
#define FREE_OBJ_NO_DESTROY_CALLBACK
recipelist * get_formulalist(int i)
size_t bufferreader_current_line(BufferReader *br)
void LOG(LogLevel logLevel, const char *format,...)
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
void dump_alchemy_costs(void)
static recipelist * init_recipelist(void)
static recipelist * get_random_recipelist(void)
void give_artifact_abilities(object *op, const object *artifact)
static int check_recipe(const recipe *rp)
treasurelist * find_treasurelist(const char *name)
static long recipe_find_ingredient_cost(const char *name)
AssetsManager * getManager()
static recipelist * formulalist
void object_free_drop_inventory(object *ob)
void check_formulae(void)
sstring add_string(const char *str)
static int numb_ingred(const char *buf)
struct linked_char * next
void object_free(object *ob, int flags)
void each(std::function< void(T *)> op)
void fatal(enum fatal_error err)
Archetypes * archetypes()
void free_all_recipes(void)
size_t strlcpy(char *dst, const char *src, size_t size)
object * create_archetype(const char *name)
void free_string(sstring str)
recipe * get_random_recipe(recipelist *rpl)
const artifact * locate_recipe_artifact(const recipe *rp, size_t idx)
static const char * ingred_name(const char *name)
archetype * find_treasure_by_name(const treasure *t, const char *name, int depth)
int strtoint(const char *buf)
object * arch_to_object(archetype *at)
void object_give_identified_properties(object *op)
void init_formulae(BufferReader *reader, const char *filename)
int strcasecmp(const char *s1, const char *s2)
static recipe * get_empty_formula(void)
archetype * try_find_archetype(const char *name)
#define FREE_OBJ_FREE_INVENTORY
static void build_stringlist(const char *str, char ***result_list, size_t *result_size)
artifactlist * find_artifactlist(int type)
const Face * recipe_get_face(const recipe *rp)
int legal_artifact_combination(const object *op, const artifact *art)
char * bufferreader_next_line(BufferReader *br)