Crossfire Server, Trunk  R21024
recipe.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
35 #include "global.h"
36 
37 #include <assert.h>
38 #include <ctype.h>
39 #include <stdlib.h>
40 #include <string.h>
41 
42 #include "object.h"
43 
44 static void build_stringlist(const char *str, char ***result_list, size_t *result_size);
45 static void check_formulae(void);
46 
49 
58 static recipelist *init_recipelist(void) {
59  recipelist *tl = (recipelist *)malloc(sizeof(recipelist));
60  if (tl == NULL)
62  tl->total_chance = 0;
63  tl->number = 0;
64  tl->items = NULL;
65  tl->next = NULL;
66  return tl;
67 }
68 
77 static recipe *get_empty_formula(void) {
78  // This used to be a malloc followed by setting everything to zero.
79  // So just use calloc to make it faster.
80  // SilverNexus -- 2018-10-22
81  recipe *t = (recipe *)calloc(1, sizeof(recipe));
82  if (t == NULL)
84  return t;
85 }
86 
97  recipelist *fl = formulalist;
98  int number = i;
99 
100  while (fl && number > 1) {
101  if (!(fl = fl->next))
102  break;
103  number--;
104  }
105  return fl;
106 }
107 
118 static int check_recipe(const recipe *rp) {
119  size_t i;
120  int result;
121 
122  result = 1;
123  for (i = 0; i < rp->arch_names; i++) {
124  if (find_archetype(rp->arch_name[i]) != NULL) {
125  const artifact *art = locate_recipe_artifact(rp, i);
126 
127  if (!art && strcmp(rp->title, "NONE") != 0) {
128  LOG(llevError, "\nWARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], rp->title);
129  result = 0;
130  }
131  } else {
132  LOG(llevError, "\nWARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], rp->title);
133  result = 0;
134  }
135  }
136 
137  return result;
138 }
139 
143 void init_formulae(void) {
144  static int has_been_done = 0;
145  FILE *fp;
146  char filename[MAX_BUF], buf[MAX_BUF], *cp, *next;
147  recipe *formula = NULL;
148  recipelist *fl = init_recipelist();
149  linked_char *tmp;
150  int value;
151 
152  if (!formulalist)
153  formulalist = fl;
154 
155  if (has_been_done)
156  return;
157  else
158  has_been_done = 1;
159 
160  snprintf(filename, sizeof(filename), "%s/formulae", settings.datadir);
161  LOG(llevDebug, "Reading alchemical formulae from %s...\n", filename);
162  if ((fp = fopen(filename, "r")) == NULL) {
163  LOG(llevError, "Can't open %s.\n", filename);
164  return;
165  }
166 
167  while (fgets(buf, MAX_BUF, fp) != NULL) {
168  if (*buf == '#')
169  continue;
170  if ((cp = strchr(buf, '\n')) != NULL)
171  *cp = '\0';
172  cp = buf;
173  while (*cp == ' ') /* Skip blanks */
174  cp++;
175 
176  if (!strncmp(cp, "Object", 6)) {
177  formula = get_empty_formula();
178  formula->title = add_string(strchr(cp, ' ')+1);
179  } else if (formula == NULL) {
180  LOG(llevError, "recipe.c: First key in formulae file is not \"Object\".\n");
182  } else if (!strncmp(cp, "keycode", 7)) {
183  formula->keycode = add_string(strchr(cp, ' ')+1);
184  } else if (sscanf(cp, "trans %d", &value)) {
185  formula->transmute = value;
186  } else if (sscanf(cp, "yield %d", &value)) {
187  formula->yield = value;
188  } else if (sscanf(cp, "chance %d", &value)) {
189  formula->chance = value;
190  } else if (sscanf(cp, "exp %d", &value)) {
191  formula->exp = value;
192  } else if (sscanf(cp, "diff %d", &value)) {
193  formula->diff = value;
194  } else if (!strncmp(cp, "ingred", 6)) {
195  int numb_ingred;
196  formula->ingred_count = 1;
197  cp = strchr(cp, ' ')+1;
198  do {
199  if ((next = strchr(cp, ',')) != NULL) {
200  *(next++) = '\0';
201  formula->ingred_count++;
202  }
203  tmp = (linked_char *)malloc(sizeof(linked_char));
204  /* trim the string */
205  while (*cp == ' ')
206  cp++;
207  while (cp != '\0' && cp[strlen(cp) - 1] == ' ')
208  cp[strlen(cp) - 1] = '\0';
209  tmp->name = add_string(cp);
210  tmp->next = formula->ingred;
211  formula->ingred = tmp;
212  /* each ingredient's ASCII value is coadded. Later on this
213  * value will be used allow us to search the formula lists
214  * quickly for the right recipe.
215  */
216  formula->index += strtoint(cp);
217  } while ((cp = next) != NULL);
218  /* now find the correct (# of ingred ordered) formulalist */
219  numb_ingred = formula->ingred_count;
220  fl = formulalist;
221  while (numb_ingred != 1) {
222  if (!fl->next)
223  fl->next = init_recipelist();
224  fl = fl->next;
225  numb_ingred--;
226  }
227  fl->total_chance += formula->chance;
228  fl->number++;
229  formula->next = fl->items;
230  fl->items = formula;
231  } else if (!strncmp(cp, "arch", 4)) {
232  build_stringlist(strchr(cp, ' ')+1, &formula->arch_name, &formula->arch_names);
233  check_recipe(formula);
234  } else if (!strncmp(cp, "skill", 5)) {
235  formula->skill = add_string(strchr(cp, ' ')+1);
236  } else if (!strncmp(cp, "cauldron", 8)) {
237  formula->cauldron = add_string(strchr(cp, ' ')+1);
238  } else if (!strncmp(cp, "failure_arch ", 13)) {
239  formula->failure_arch = add_string(strchr(cp, ' ')+1);
240  } else if (!strncmp(cp, "failure_message ", 16)) {
241  formula->failure_message = add_string(strchr(cp, ' ')+1);
242  } else if (sscanf(cp, "min_level %d", &value)) {
243  formula->min_level = value;
244  } else if (!strncmp(cp, "tool ", 5)) {
245  build_stringlist(strchr(cp, ' ')+1, &formula->tool, &formula->tool_size);
246  } else if (sscanf(cp, "combination %d", &value)) {
247  formula->is_combination = value ? 1 : 0;
248  } else
249  LOG(llevError, "Unknown input in file %s: %s\n", filename, buf);
250  }
251  LOG(llevDebug, "done.\n");
252  fclose(fp);
253  /* Lastly, lets check for problems in formula we got */
254  check_formulae();
255 }
256 
271 static void check_formulae(void) {
272  recipelist *fl;
273  recipe *check, *formula;
274  int numb = 1, tool_i, tool_j, tool_match;
275 
276  LOG(llevDebug, "Checking formulae lists...\n");
277 
278  for (fl = formulalist; fl != NULL; fl = fl->next) {
279  for (formula = fl->items; formula != NULL; formula = formula->next)
280  for (check = formula->next; check != NULL; check = check->next)
281  /* If one recipe has a tool and another a caudron, we should be able to handle it */
282  if (check->index == formula->index &&
283  ((check->cauldron && formula->cauldron && strcmp(check->cauldron, formula->cauldron) == 0) ||
284  (check->tool_size == formula->tool_size && check->tool_size > 0))) {
285  /* Check the tool list to make sure they have no matches */
286  if (check->tool && formula->tool)
287  {
288  tool_match = 0;
289  for (tool_i = 0; tool_i < formula->tool_size; ++tool_i)
290  /* If it turns out these lists are sorted, then we could optimize this better. */
291  for (tool_j = 0; tool_j < check->tool_size; ++tool_j)
292  if (strcmp(formula->tool[tool_i], check->tool[tool_j]) == 0) {
293  tool_match = 1;
294  break; /* TODO: break out of the double loop */
295  }
296  }
297  else
298  tool_match = 1; /* If we get here, we matched on the cauldron */
299  /* Check to see if we have a denoted match */
300  if (tool_match) {
301  /* if the recipes don't have the same facility, then no issue anyway. */
302  LOG(llevError, " ERROR: On %d ingred list:\n", numb);
303  LOG(llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n",
304  formula->arch_name[0], formula->title, check->arch_name[0], check->title, formula->index);
305  }
306  }
307  numb++;
308  }
309 
310  LOG(llevDebug, "done checking.\n");
311 }
312 
320 void dump_alchemy(void) {
321  recipelist *fl = formulalist;
322  recipe *formula = NULL;
323  linked_char *next;
324  int num_ingred = 1;
325 
326  fprintf(logfile, "\n");
327  while (fl) {
328  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);
329  for (formula = fl->items; formula != NULL; formula = formula->next) {
330  const artifact *art = NULL;
331  char buf[MAX_BUF];
332  size_t i;
333 
334  for (i = 0; i < formula->arch_names; i++) {
335  const char *string = formula->arch_name[i];
336 
337  if (find_archetype(string) != NULL) {
338  art = locate_recipe_artifact(formula, i);
339  if (!art && strcmp(formula->title, "NONE"))
340  LOG(llevError, "Formula %s has no artifact\n", formula->title);
341  else {
342  if (strcmp(formula->title, "NONE"))
343  snprintf(buf, sizeof(buf), "%s of %s", string, formula->title);
344  else
345  snprintf(buf, sizeof(buf), "%s", string);
346  fprintf(logfile, "%-30s(%d) bookchance %3d ", buf, formula->index, formula->chance);
347  fprintf(logfile, "skill %s", formula->skill);
348  fprintf(logfile, "\n");
349  if (formula->ingred != NULL) {
350  int nval = 0, tval = 0;
351  fprintf(logfile, "\tIngred: ");
352  for (next = formula->ingred; next != NULL; next = next->next) {
353  if (nval != 0)
354  fprintf(logfile, ",");
355  fprintf(logfile, "%s(%d)", next->name, (nval = strtoint(next->name)));
356  tval += nval;
357  }
358  fprintf(logfile, "\n");
359  if (tval != formula->index)
360  fprintf(logfile, "WARNING:ingredient list and formula values not equal.\n");
361  }
362  if (formula->skill != NULL)
363  fprintf(logfile, "\tSkill Required: %s", formula->skill);
364  if (formula->cauldron != NULL)
365  fprintf(logfile, "\tCauldron: %s\n", formula->cauldron);
366  fprintf(logfile, "\tDifficulty: %d\t Exp: %d\n", formula->diff, formula->exp);
367  }
368  } else
369  LOG(llevError, "Can't find archetype:%s for formula %s\n", string, formula->title);
370  }
371  }
372  fprintf(logfile, "\n");
373  fl = fl->next;
374  num_ingred++;
375  }
376 }
377 
392 archetype *find_treasure_by_name(const treasure *t, const char *name, int depth) {
393  treasurelist *tl;
394  archetype *at;
395 
396  if (depth > 10)
397  return NULL;
398 
399  while (t != NULL) {
400  if (t->name != NULL) {
401  tl = find_treasurelist(t->name);
402  at = find_treasure_by_name(tl->items, name, depth+1);
403  if (at != NULL)
404  return at;
405  } else {
406  if (!strcasecmp(t->item->clone.name, name))
407  return t->item;
408  }
409  if (t->next_yes != NULL) {
410  at = find_treasure_by_name(t->next_yes, name, depth);
411  if (at != NULL)
412  return at;
413  }
414  if (t->next_no != NULL) {
415  at = find_treasure_by_name(t->next_no, name, depth);
416  if (at != NULL)
417  return at;
418  }
419  t = t->next;
420  }
421  return NULL;
422 }
423 
443 static long find_ingred_cost(const char *name) {
444  archetype *at;
445  archetype *at2;
446  const artifactlist *al;
447  const artifact *art;
448  long mult;
449  char *cp;
450  char part1[100];
451  char part2[100];
452 
453  /* same as atoi(), but skip number */
454  mult = 0;
455  while (isdigit(*name)) {
456  mult = 10*mult+(*name-'0');
457  name++;
458  }
459  if (mult > 0)
460  name++;
461  else
462  mult = 1;
463  /* first, try to match the name of an archetype */
464  for (at = first_archetype; at != NULL; at = at->next) {
465  if (at->clone.title != NULL) {
466  /* inefficient, but who cares? */
467  snprintf(part1, sizeof(part1), "%s %s", at->clone.name, at->clone.title);
468  if (!strcasecmp(part1, name))
469  return mult*at->clone.value;
470  }
471  if (!strcasecmp(at->clone.name, name))
472  return mult*at->clone.value;
473  }
474  /* second, try to match an artifact ("arch of something") */
475  cp = strstr(name, " of ");
476  if (cp != NULL) {
477  safe_strncpy(part1, name, sizeof(part1));
478  part1[cp-name] = '\0';
479  safe_strncpy(part2, cp + 4, sizeof(part2));
480  /* find the first archetype matching the first part of the name */
481  for (at = first_archetype; at != NULL; at = at->next)
482  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL)
483  break;
484  if (at != NULL) {
485  /* find the first artifact derived from that archetype (same type) */
486  for (al = first_artifactlist; al != NULL; al = al->next)
487  if (al->type == at->clone.type) {
488  for (art = al->items; art != NULL; art = art->next)
489  if (!strcasecmp(art->item->name, part2))
490  return mult*at->clone.value*art->item->value;
491  }
492  }
493  }
494  /* third, try to match a body part ("arch's something") */
495  cp = strstr(name, "'s ");
496  if (cp != NULL) {
497  safe_strncpy(part1, name, sizeof(part1));
498  part1[cp-name] = '\0';
499  safe_strncpy(part2, cp + 3, sizeof(part2));
500  /* examine all archetypes matching the first part of the name */
501  for (at = first_archetype; at != NULL; at = at->next)
502  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
503  if (at->clone.randomitems != NULL) {
504  at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
505  if (at2 != NULL)
506  return mult*at2->clone.value*isqrt(at->clone.level*2);
507  }
508  }
509  }
510  /* failed to find any matching items -- formula should be checked */
511  return -1;
512 }
513 
522 void dump_alchemy_costs(void) {
523  recipelist *fl = formulalist;
524  recipe *formula = NULL;
525  linked_char *next;
526  int num_ingred = 1;
527  int num_errors = 0;
528  long cost;
529  long tcost;
530 
531  fprintf(logfile, "\n");
532  while (fl) {
533  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);
534  for (formula = fl->items; formula != NULL; formula = formula->next) {
535  const artifact *art = NULL;
536  const archetype *at = NULL;
537  char buf[MAX_BUF];
538  size_t i;
539 
540  for (i = 0; i < formula->arch_names; i++) {
541  const char *string = formula->arch_name[i];
542 
543  if ((at = find_archetype(string)) != NULL) {
544  art = locate_recipe_artifact(formula, i);
545  if (!art && strcmp(formula->title, "NONE"))
546  LOG(llevError, "Formula %s has no artifact\n", formula->title);
547  else {
548  if (!strcmp(formula->title, "NONE"))
549  snprintf(buf, sizeof(buf), "%s", string);
550  else
551  snprintf(buf, sizeof(buf), "%s of %s", string, formula->title);
552  fprintf(logfile, "\n%-40s bookchance %3d skill %s\n", buf, formula->chance, formula->skill);
553  if (formula->ingred != NULL) {
554  tcost = 0;
555  for (next = formula->ingred; next != NULL; next = next->next) {
556  cost = find_ingred_cost(next->name);
557  if (cost < 0)
558  num_errors++;
559  fprintf(logfile, "\t%-33s%5ld\n", next->name, cost);
560  if (cost < 0 || tcost < 0)
561  tcost = -1;
562  else
563  tcost += cost;
564  }
565  if (art != NULL && art->item != NULL)
566  cost = at->clone.value*art->item->value;
567  else
568  cost = at->clone.value;
569  fprintf(logfile, "\t\tBuying result costs: %5ld", cost);
570  if (formula->yield > 1) {
571  fprintf(logfile, " to %ld (max %d items)\n", cost*formula->yield, formula->yield);
572  cost = cost*(formula->yield+1L)/2L;
573  } else
574  fprintf(logfile, "\n");
575  fprintf(logfile, "\t\tIngredients cost: %5ld\n\t\tComment: ", tcost);
576  if (tcost < 0)
577  fprintf(logfile, "Could not find some ingredients. Check the formula!\n");
578  else if (tcost > cost)
579  fprintf(logfile, "Ingredients are much too expensive. Useless formula.\n");
580  else if (tcost*2L > cost)
581  fprintf(logfile, "Ingredients are too expensive.\n");
582  else if (tcost*10L < cost)
583  fprintf(logfile, "Ingredients are too cheap.\n");
584  else
585  fprintf(logfile, "OK.\n");
586  }
587  }
588  } else
589  LOG(llevError, "Can't find archetype:%s for formula %s\n", string, formula->title);
590  }
591  }
592  fprintf(logfile, "\n");
593  fl = fl->next;
594  num_ingred++;
595  }
596  if (num_errors > 0)
597  fprintf(logfile, "WARNING: %d objects required by the formulae do not exist in the game.\n", num_errors);
598 }
599 
608 static const char *ingred_name(const char *name) {
609  const char *cp = name;
610 
611  if (atoi(cp))
612  cp = strchr(cp, ' ')+1;
613  return cp;
614 }
615 
624 static int numb_ingred(const char *buf) {
625  int numb;
626 
627  if ((numb = atoi(buf)))
628  return numb;
629  else
630  return 1;
631 }
632 
643 int strtoint(const char *buf) {
644  const char *cp = ingred_name(buf);
645  int val = 0, len = strlen(cp), mult = numb_ingred(buf);
646 
647  while (len) {
648  val += tolower(*cp);
649  cp++; len--;
650  }
651  return val*mult;
652 }
653 
664 const artifact *locate_recipe_artifact(const recipe *rp, size_t idx) {
665  object *item = create_archetype(rp->arch_name[idx]);
666  const artifactlist *at = NULL;
667  const artifact *art = NULL;
668 
669  if (!item)
670  return (artifact *)NULL;
671 
672  if ((at = find_artifactlist(item->type)))
673  for (art = at->items; art; art = art->next)
674  if (!strcmp(art->item->name, rp->title) && legal_artifact_combination(item, art))
675  break;
676 
678 
679  return art;
680 }
681 
689  recipelist *fl = NULL;
690  int number = 0, roll = 0;
691 
692  /* first, determine # of recipelist we have */
693  for (fl = get_formulalist(1); fl; fl = fl->next)
694  number++;
695 
696  /* now, randomly choose one */
697  if (number > 0)
698  roll = RANDOM()%number;
699 
700  fl = get_formulalist(1);
701  while (roll && fl) {
702  if (fl->next)
703  fl = fl->next;
704  else
705  break;
706  roll--;
707  }
708  if (!fl) /* failed! */
709  LOG(llevError, "get_random_recipelist(): no recipelists found!\n");
710  else if (fl->total_chance == 0)
711  fl = get_random_recipelist();
712 
713  return fl;
714 }
715 
725  recipelist *fl = rpl;
726  recipe *rp = NULL;
727  int r = 0;
728 
729  /* looks like we have to choose a random one */
730  if (fl == NULL)
731  if ((fl = get_random_recipelist()) == NULL)
732  return rp;
733 
734  if (fl->total_chance > 0) {
735  r = RANDOM()%fl->total_chance;
736  for (rp = fl->items; rp; rp = rp->next) {
737  r -= rp->chance;
738  if (r < 0)
739  break;
740  }
741  }
742  return rp;
743 }
744 
748 void free_all_recipes(void) {
749  recipelist *fl, *flnext;
750  recipe *formula = NULL, *next;
751  linked_char *lchar, *charnext;
752 
753  LOG(llevDebug, "Freeing all the recipes\n");
754  for (fl = formulalist; fl != NULL; fl = flnext) {
755  flnext = fl->next;
756 
757  for (formula = fl->items; formula != NULL; formula = next) {
758  next = formula->next;
759 
760  free(formula->arch_name[0]);
761  free(formula->arch_name);
762  if (formula->title)
763  free_string(formula->title);
764  if (formula->skill)
765  free_string(formula->skill);
766  if (formula->cauldron)
767  free_string(formula->cauldron);
768  if (formula->failure_arch)
769  free_string(formula->failure_arch);
770  if (formula->failure_message)
771  free_string(formula->failure_message);
772  for (lchar = formula->ingred; lchar; lchar = charnext) {
773  charnext = lchar->next;
774  free_string(lchar->name);
775  free(lchar);
776  }
777  if (formula->tool)
778  free(formula->tool[0]);
779  free(formula->tool);
780  free(formula);
781  }
782  free(fl);
783  }
784  formulalist = NULL;
785 }
786 
798 static void build_stringlist(const char *str, char ***result_list, size_t *result_size) {
799  char *dup;
800  char *p;
801  size_t size;
802  size_t i;
803 
804  dup = strdup_local(str);
805  if (dup == NULL)
807 
808  size = 0;
809  for (p = strtok(dup, ","); p != NULL; p = strtok(NULL, ","))
810  size++;
811 
812  assert(size > 0);
813  *result_list = malloc(sizeof(**result_list) * size);
814  if (*result_list == NULL)
816  *result_size = size;
817 
818  for (i = 0; i < size; i++) {
819  (*result_list)[i] = dup;
820  dup = dup+strlen(dup)+1;
821  }
822 }
823 
831 recipe *find_recipe_for_tool(const char *tool, recipe *from) {
832  size_t t;
833  recipelist *list = from ? get_formulalist(from->ingred_count) : formulalist;
834  recipe *test = from ? from->next : list->items;
835 
836  while (list) {
837  while (test) {
838  for (t = 0; t < test->tool_size; t++) {
839  if (strcmp(test->tool[t], tool) == 0) {
840  return test;
841  }
842  }
843  test = test->next;
844  }
845 
846  list = list->next;
847  }
848 
849  return NULL;
850 }
EXTERN FILE * logfile
Definition: global.h:142
static void check_formulae(void)
Definition: recipe.c:271
archetype * find_archetype(const char *name)
Definition: arch.c:692
int diff
Definition: recipe.h:16
archetype * find_treasure_by_name(const treasure *t, const char *name, int depth)
Definition: recipe.c:392
const artifactlist * find_artifactlist(int type)
Definition: artifact.c:647
static void build_stringlist(const char *str, char ***result_list, size_t *result_size)
Definition: recipe.c:798
recipe * get_random_recipe(recipelist *rpl)
Definition: recipe.c:724
#define strdup_local
Definition: compat.h:25
struct recipeliststruct * next
Definition: recipe.h:41
static int check_recipe(const recipe *rp)
Definition: recipe.c:118
int yield
Definition: recipe.h:21
void fatal(enum fatal_error err)
Definition: utils.c:597
struct artifactstruct * items
Definition: artifact.h:30
treasurelist * find_treasurelist(const char *name)
Definition: treasure.c:292
void free_string(sstring str)
Definition: shstr.c:280
struct treasureliststruct * randomitems
Definition: object.h:385
object clone
Definition: object.h:470
linked_char * ingred
Definition: recipe.h:22
recipe * find_recipe_for_tool(const char *tool, recipe *from)
Definition: recipe.c:831
int isqrt(int n)
Definition: utils.c:586
static int numb_ingred(const char *buf)
Definition: recipe.c:624
static recipelist * init_recipelist(void)
Definition: recipe.c:58
int is_combination
Definition: recipe.h:31
int transmute
Definition: recipe.h:19
#define safe_strncpy
Definition: compat.h:23
static recipelist * get_random_recipelist(void)
Definition: recipe.c:688
Definition: object.h:465
void dump_alchemy_costs(void)
Definition: recipe.c:522
struct archt * item
Definition: treasure.h:64
void init_formulae(void)
Definition: recipe.c:143
int ingred_count
Definition: recipe.h:23
int chance
Definition: recipe.h:14
void object_free_drop_inventory(object *ob)
Definition: object.c:1389
const char * title
Definition: object.h:317
int legal_artifact_combination(const object *op, const artifact *art)
Definition: artifact.c:221
struct artifactliststruct * next
Definition: artifact.h:29
sstring title
Definition: recipe.h:11
object * create_archetype(const char *name)
Definition: arch.c:617
char ** arch_name
Definition: recipe.h:13
static const char * ingred_name(const char *name)
Definition: recipe.c:608
int total_chance
Definition: recipe.h:38
const artifact * locate_recipe_artifact(const recipe *rp, size_t idx)
Definition: recipe.c:664
#define snprintf
Definition: win32.h:46
void dump_alchemy(void)
Definition: recipe.c:320
struct linked_char * next
Definition: global.h:88
int strtoint(const char *buf)
Definition: recipe.c:643
const char * name
Definition: object.h:311
struct treasurestruct * next_no
Definition: treasure.h:68
sstring skill
Definition: recipe.h:26
EXTERN artifactlist * first_artifactlist
Definition: global.h:121
static recipelist * formulalist
Definition: recipe.c:48
int index
Definition: recipe.h:18
#define MAX_BUF
Definition: define.h:35
size_t tool_size
Definition: recipe.h:33
struct treasurestruct * items
Definition: treasure.h:90
#define tolower(C)
Definition: c_new.c:29
void free_all_recipes(void)
Definition: recipe.c:748
int exp
Definition: recipe.h:17
const char * datadir
Definition: global.h:242
const char * name
Definition: global.h:87
struct treasurestruct * next_yes
Definition: treasure.h:67
#define RANDOM()
Definition: define.h:681
size_t arch_names
Definition: recipe.h:12
uint8_t type
Definition: object.h:338
struct Settings settings
Definition: init.c:40
sstring failure_message
Definition: recipe.h:29
struct archt * next
Definition: object.h:467
struct recipestruct * next
Definition: recipe.h:24
sstring add_string(const char *str)
Definition: shstr.c:124
int strcasecmp(const char *s1, const char *s2)
Definition: porting.c:256
sstring failure_arch
Definition: recipe.h:28
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
static long find_ingred_cost(const char *name)
Definition: recipe.c:443
object * item
Definition: artifact.h:15
static recipe * get_empty_formula(void)
Definition: recipe.c:77
struct treasurestruct * next
Definition: treasure.h:66
int16_t level
Definition: object.h:351
const char * name
Definition: treasure.h:65
EXTERN archetype * first_archetype
Definition: global.h:122
int32_t value
Definition: object.h:350
sstring cauldron
Definition: recipe.h:27
char ** tool
Definition: recipe.h:32
sstring keycode
Definition: recipe.h:25
struct recipestruct * items
Definition: recipe.h:40
recipelist * get_formulalist(int i)
Definition: recipe.c:96
int min_level
Definition: recipe.h:30
struct artifactstruct * next
Definition: artifact.h:18