Go to the documentation of this file.
102 while (fl && number > 1) {
103 if (!(fl = fl->
next))
127 if (strcmp(rp->
title,
"NONE")) {
177 if (*
buf ==
'#' || *
buf ==
'\0')
183 if (!strncmp(cp,
"Remove ", 7)) {
184 if (strcmp(cp + 7,
"*") == 0) {
192 if (!strncmp(cp,
"Object", 6)) {
195 }
else if (formula == NULL) {
198 }
else if (!strncmp(cp,
"keycode", 7)) {
200 }
else if (sscanf(cp,
"trans %d", &
value)) {
202 }
else if (sscanf(cp,
"yield %d", &
value)) {
204 }
else if (sscanf(cp,
"chance %d", &
value)) {
206 }
else if (sscanf(cp,
"exp %d", &
value)) {
208 }
else if (sscanf(cp,
"diff %d", &
value)) {
210 }
else if (!strncmp(cp,
"ingred", 6)) {
213 cp = strchr(cp,
' ')+1;
215 if ((
next = strchr(cp,
',')) != NULL) {
223 while (*cp !=
'\0' && cp[strlen(cp) - 1] ==
' ')
224 cp[strlen(cp) - 1] =
'\0';
233 }
while ((cp =
next) != NULL);
245 }
else if (!strncmp(cp,
"arch", 4)) {
247 }
else if (!strncmp(cp,
"skill", 5)) {
249 }
else if (!strncmp(cp,
"cauldron", 8)) {
251 }
else if (!strncmp(cp,
"failure_arch ", 13)) {
253 }
else if (!strncmp(cp,
"failure_message ", 16)) {
255 }
else if (sscanf(cp,
"min_level %d", &
value)) {
257 }
else if (!strncmp(cp,
"tool ", 5)) {
259 }
else if (sscanf(cp,
"combination %d", &
value)) {
270 for (formula = fl->
items; formula; formula = formula->
next) {
295 int numb = 1, tool_match;
296 size_t tool_i,tool_j;
302 for (formula = fl->
items; formula != NULL; formula = formula->
next) {
310 for (tool_i = 0; tool_i < formula->
tool_size; ++tool_i)
312 for (tool_j = 0; tool_j <
check->tool_size; ++tool_j)
313 if (strcmp(formula->
tool[tool_i],
check->tool[tool_j]) == 0) {
324 LOG(
llevError,
"Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n",
329 for (
size_t idx = 0; idx < formula->
arch_names; idx++) {
331 LOG(
llevError,
"Formulae %s of %s (%d ingredients) references non existent archetype %s\n",
358 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);
359 for (formula = fl->
items; formula != NULL; formula = formula->
next) {
365 const char *
string = formula->
arch_name[i];
369 if (!art && strcmp(formula->
title,
"NONE"))
372 if (strcmp(formula->
title,
"NONE"))
373 snprintf(
buf,
sizeof(
buf),
"%s of %s",
string, formula->
title);
379 if (formula->
ingred != NULL) {
380 int nval = 0, tval = 0;
381 fprintf(
logfile,
"\tIngred: ");
389 if (tval != formula->
index)
390 fprintf(
logfile,
"WARNING:ingredient list and formula values not equal.\n");
392 if (formula->
skill != NULL)
393 fprintf(
logfile,
"\tSkill Required: %s", formula->
skill);
396 fprintf(
logfile,
"\tDifficulty: %d\t Exp: %d\n", formula->
diff, formula->
exp);
399 LOG(
llevError,
"Can't find archetype:%s for formula %s\n",
string, formula->
title);
430 if (
t->name != NULL) {
439 if (
t->next_yes != NULL) {
444 if (
t->next_no != NULL) {
481 while (isdigit(*
name)) {
482 mult = 10*mult+(*
name-
'0');
500 snprintf(part1, sizeof(part1),
"%s %s", at->clone.name, at->clone.title);
501 if (!strcasecmp(part1, name)) {
502 value = at->clone.value;
508 value = at->clone.value;
518 cp = strstr(
name,
" of ");
521 part1[cp-
name] =
'\0';
530 for (auto al = first_artifactlist; al != NULL; al = al->next) {
531 if (al->type == at->clone.type) {
532 for (const auto art : al->items) {
533 if (!strcasecmp(art->item->name, part2)) {
534 value = at->clone.value * art->item->value;
549 cp = strstr(
name,
"'s ");
552 part1[cp-
name] =
'\0';
560 if (at->clone.randomitems != NULL) {
561 auto at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
563 value = at2->clone.value * isqrt(at->clone.level * 2);
599 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);
600 for (formula = fl->
items; formula != NULL; formula = formula->
next) {
607 const char *
string = formula->
arch_name[i];
611 if (!art && strcmp(formula->
title,
"NONE"))
614 if (!strcmp(formula->
title,
"NONE"))
617 snprintf(
buf,
sizeof(
buf),
"%s of %s",
string, formula->
title);
619 if (formula->
ingred != NULL) {
626 if (
cost < 0 || tcost < 0)
631 if (art != NULL && art->
item != NULL)
635 fprintf(
logfile,
"\t\tBuying result costs: %5ld",
cost);
636 if (formula->
yield > 1) {
641 fprintf(
logfile,
"\t\tIngredients cost: %5ld\n\t\tComment: ", tcost);
643 fprintf(
logfile,
"Could not find some ingredients. Check the formula!\n");
644 else if (tcost >
cost)
645 fprintf(
logfile,
"Ingredients are much too expensive. Useless formula.\n");
646 else if (tcost*2L >
cost)
647 fprintf(
logfile,
"Ingredients are too expensive.\n");
648 else if (tcost*10L <
cost)
649 fprintf(
logfile,
"Ingredients are too cheap.\n");
655 LOG(
llevError,
"Can't find archetype:%s for formula %s\n",
string, formula->
title);
663 fprintf(
logfile,
"WARNING: %d objects required by the formulae do not exist in the game.\n", num_errors);
675 const char *cp =
name;
678 cp = strchr(cp,
' ')+1;
693 if ((numb = atoi(
buf)))
738 for (
auto art : at->items)
753 int number = 0, roll = 0;
772 LOG(
llevError,
"get_random_recipelist(): no recipelists found!\n");
799 for (rp = fl->
items; rp; rp = rp->
next) {
820 for (formula = fl->
items; formula != NULL; formula =
next) {
835 for (lchar = formula->
ingred; lchar; lchar = charnext) {
836 charnext = lchar->
next;
841 free(formula->
tool[0]);
872 for (p = strtok(dup,
","); p != NULL; p = strtok(NULL,
","))
876 *result_list =
static_cast<char **
>(malloc(
sizeof(**result_list) * size));
877 if (*result_list == NULL)
881 for (i = 0; i < size; i++) {
882 (*result_list)[i] = dup;
883 dup = dup+strlen(dup)+1;
902 if (strcmp(test->
tool[
t], tool) == 0) {
933 if (strcmp(rp->
title,
"NONE") == 0) {
934 return arch->clone.face;
939 return arch->clone.face;
941 face =
arch->clone.face;
970 return "complicated";
974 return "challenging";
976 return "frustrating";
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)
bool 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)
const char * recipe_get_difficulty_string(int difficulty)
int legal_artifact_combination(const object *op, const artifact *art)
char * bufferreader_next_line(BufferReader *br)