Crossfire Server, Trunk  R20739
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;
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 (check->index == formula->index && strcmp(check->cauldron, formula->cauldron) == 0) {
282  /* if the recipes don't have the same facility, then no issue anyway. */
283  LOG(llevError, " ERROR: On %d ingred list:\n", numb);
284  LOG(llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n", formula->arch_name[0], formula->title, check->arch_name[0], check->title, formula->index);
285  }
286  numb++;
287  }
288 
289  LOG(llevDebug, "done checking.\n");
290 }
291 
299 void dump_alchemy(void) {
300  recipelist *fl = formulalist;
301  recipe *formula = NULL;
302  linked_char *next;
303  int num_ingred = 1;
304 
305  fprintf(logfile, "\n");
306  while (fl) {
307  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);
308  for (formula = fl->items; formula != NULL; formula = formula->next) {
309  const artifact *art = NULL;
310  char buf[MAX_BUF];
311  size_t i;
312 
313  for (i = 0; i < formula->arch_names; i++) {
314  const char *string = formula->arch_name[i];
315 
316  if (find_archetype(string) != NULL) {
317  art = locate_recipe_artifact(formula, i);
318  if (!art && strcmp(formula->title, "NONE"))
319  LOG(llevError, "Formula %s has no artifact\n", formula->title);
320  else {
321  if (strcmp(formula->title, "NONE"))
322  snprintf(buf, sizeof(buf), "%s of %s", string, formula->title);
323  else
324  snprintf(buf, sizeof(buf), "%s", string);
325  fprintf(logfile, "%-30s(%d) bookchance %3d ", buf, formula->index, formula->chance);
326  fprintf(logfile, "skill %s", formula->skill);
327  fprintf(logfile, "\n");
328  if (formula->ingred != NULL) {
329  int nval = 0, tval = 0;
330  fprintf(logfile, "\tIngred: ");
331  for (next = formula->ingred; next != NULL; next = next->next) {
332  if (nval != 0)
333  fprintf(logfile, ",");
334  fprintf(logfile, "%s(%d)", next->name, (nval = strtoint(next->name)));
335  tval += nval;
336  }
337  fprintf(logfile, "\n");
338  if (tval != formula->index)
339  fprintf(logfile, "WARNING:ingredient list and formula values not equal.\n");
340  }
341  if (formula->skill != NULL)
342  fprintf(logfile, "\tSkill Required: %s", formula->skill);
343  if (formula->cauldron != NULL)
344  fprintf(logfile, "\tCauldron: %s\n", formula->cauldron);
345  fprintf(logfile, "\tDifficulty: %d\t Exp: %d\n", formula->diff, formula->exp);
346  }
347  } else
348  LOG(llevError, "Can't find archetype:%s for formula %s\n", string, formula->title);
349  }
350  }
351  fprintf(logfile, "\n");
352  fl = fl->next;
353  num_ingred++;
354  }
355 }
356 
371 archetype *find_treasure_by_name(const treasure *t, const char *name, int depth) {
372  treasurelist *tl;
373  archetype *at;
374 
375  if (depth > 10)
376  return NULL;
377 
378  while (t != NULL) {
379  if (t->name != NULL) {
380  tl = find_treasurelist(t->name);
381  at = find_treasure_by_name(tl->items, name, depth+1);
382  if (at != NULL)
383  return at;
384  } else {
385  if (!strcasecmp(t->item->clone.name, name))
386  return t->item;
387  }
388  if (t->next_yes != NULL) {
389  at = find_treasure_by_name(t->next_yes, name, depth);
390  if (at != NULL)
391  return at;
392  }
393  if (t->next_no != NULL) {
394  at = find_treasure_by_name(t->next_no, name, depth);
395  if (at != NULL)
396  return at;
397  }
398  t = t->next;
399  }
400  return NULL;
401 }
402 
422 static long find_ingred_cost(const char *name) {
423  archetype *at;
424  archetype *at2;
425  const artifactlist *al;
426  const artifact *art;
427  long mult;
428  char *cp;
429  char part1[100];
430  char part2[100];
431 
432  /* same as atoi(), but skip number */
433  mult = 0;
434  while (isdigit(*name)) {
435  mult = 10*mult+(*name-'0');
436  name++;
437  }
438  if (mult > 0)
439  name++;
440  else
441  mult = 1;
442  /* first, try to match the name of an archetype */
443  for (at = first_archetype; at != NULL; at = at->next) {
444  if (at->clone.title != NULL) {
445  /* inefficient, but who cares? */
446  snprintf(part1, sizeof(part1), "%s %s", at->clone.name, at->clone.title);
447  if (!strcasecmp(part1, name))
448  return mult*at->clone.value;
449  }
450  if (!strcasecmp(at->clone.name, name))
451  return mult*at->clone.value;
452  }
453  /* second, try to match an artifact ("arch of something") */
454  cp = strstr(name, " of ");
455  if (cp != NULL) {
456  safe_strncpy(part1, name, sizeof(part1));
457  part1[cp-name] = '\0';
458  safe_strncpy(part2, cp + 4, sizeof(part2));
459  /* find the first archetype matching the first part of the name */
460  for (at = first_archetype; at != NULL; at = at->next)
461  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL)
462  break;
463  if (at != NULL) {
464  /* find the first artifact derived from that archetype (same type) */
465  for (al = first_artifactlist; al != NULL; al = al->next)
466  if (al->type == at->clone.type) {
467  for (art = al->items; art != NULL; art = art->next)
468  if (!strcasecmp(art->item->name, part2))
469  return mult*at->clone.value*art->item->value;
470  }
471  }
472  }
473  /* third, try to match a body part ("arch's something") */
474  cp = strstr(name, "'s ");
475  if (cp != NULL) {
476  safe_strncpy(part1, name, sizeof(part1));
477  part1[cp-name] = '\0';
478  safe_strncpy(part2, cp + 3, sizeof(part2));
479  /* examine all archetypes matching the first part of the name */
480  for (at = first_archetype; at != NULL; at = at->next)
481  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
482  if (at->clone.randomitems != NULL) {
483  at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
484  if (at2 != NULL)
485  return mult*at2->clone.value*isqrt(at->clone.level*2);
486  }
487  }
488  }
489  /* failed to find any matching items -- formula should be checked */
490  return -1;
491 }
492 
501 void dump_alchemy_costs(void) {
502  recipelist *fl = formulalist;
503  recipe *formula = NULL;
504  linked_char *next;
505  int num_ingred = 1;
506  int num_errors = 0;
507  long cost;
508  long tcost;
509 
510  fprintf(logfile, "\n");
511  while (fl) {
512  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);
513  for (formula = fl->items; formula != NULL; formula = formula->next) {
514  const artifact *art = NULL;
515  const archetype *at = NULL;
516  char buf[MAX_BUF];
517  size_t i;
518 
519  for (i = 0; i < formula->arch_names; i++) {
520  const char *string = formula->arch_name[i];
521 
522  if ((at = find_archetype(string)) != NULL) {
523  art = locate_recipe_artifact(formula, i);
524  if (!art && strcmp(formula->title, "NONE"))
525  LOG(llevError, "Formula %s has no artifact\n", formula->title);
526  else {
527  if (!strcmp(formula->title, "NONE"))
528  snprintf(buf, sizeof(buf), "%s", string);
529  else
530  snprintf(buf, sizeof(buf), "%s of %s", string, formula->title);
531  fprintf(logfile, "\n%-40s bookchance %3d skill %s\n", buf, formula->chance, formula->skill);
532  if (formula->ingred != NULL) {
533  tcost = 0;
534  for (next = formula->ingred; next != NULL; next = next->next) {
535  cost = find_ingred_cost(next->name);
536  if (cost < 0)
537  num_errors++;
538  fprintf(logfile, "\t%-33s%5ld\n", next->name, cost);
539  if (cost < 0 || tcost < 0)
540  tcost = -1;
541  else
542  tcost += cost;
543  }
544  if (art != NULL && art->item != NULL)
545  cost = at->clone.value*art->item->value;
546  else
547  cost = at->clone.value;
548  fprintf(logfile, "\t\tBuying result costs: %5ld", cost);
549  if (formula->yield > 1) {
550  fprintf(logfile, " to %ld (max %d items)\n", cost*formula->yield, formula->yield);
551  cost = cost*(formula->yield+1L)/2L;
552  } else
553  fprintf(logfile, "\n");
554  fprintf(logfile, "\t\tIngredients cost: %5ld\n\t\tComment: ", tcost);
555  if (tcost < 0)
556  fprintf(logfile, "Could not find some ingredients. Check the formula!\n");
557  else if (tcost > cost)
558  fprintf(logfile, "Ingredients are much too expensive. Useless formula.\n");
559  else if (tcost*2L > cost)
560  fprintf(logfile, "Ingredients are too expensive.\n");
561  else if (tcost*10L < cost)
562  fprintf(logfile, "Ingredients are too cheap.\n");
563  else
564  fprintf(logfile, "OK.\n");
565  }
566  }
567  } else
568  LOG(llevError, "Can't find archetype:%s for formula %s\n", string, formula->title);
569  }
570  }
571  fprintf(logfile, "\n");
572  fl = fl->next;
573  num_ingred++;
574  }
575  if (num_errors > 0)
576  fprintf(logfile, "WARNING: %d objects required by the formulae do not exist in the game.\n", num_errors);
577 }
578 
587 static const char *ingred_name(const char *name) {
588  const char *cp = name;
589 
590  if (atoi(cp))
591  cp = strchr(cp, ' ')+1;
592  return cp;
593 }
594 
603 static int numb_ingred(const char *buf) {
604  int numb;
605 
606  if ((numb = atoi(buf)))
607  return numb;
608  else
609  return 1;
610 }
611 
622 int strtoint(const char *buf) {
623  const char *cp = ingred_name(buf);
624  int val = 0, len = strlen(cp), mult = numb_ingred(buf);
625 
626  while (len) {
627  val += tolower(*cp);
628  cp++; len--;
629  }
630  return val*mult;
631 }
632 
643 const artifact *locate_recipe_artifact(const recipe *rp, size_t idx) {
644  object *item = create_archetype(rp->arch_name[idx]);
645  const artifactlist *at = NULL;
646  const artifact *art = NULL;
647 
648  if (!item)
649  return (artifact *)NULL;
650 
651  if ((at = find_artifactlist(item->type)))
652  for (art = at->items; art; art = art->next)
653  if (!strcmp(art->item->name, rp->title) && legal_artifact_combination(item, art))
654  break;
655 
657 
658  return art;
659 }
660 
668  recipelist *fl = NULL;
669  int number = 0, roll = 0;
670 
671  /* first, determine # of recipelist we have */
672  for (fl = get_formulalist(1); fl; fl = fl->next)
673  number++;
674 
675  /* now, randomly choose one */
676  if (number > 0)
677  roll = RANDOM()%number;
678 
679  fl = get_formulalist(1);
680  while (roll && fl) {
681  if (fl->next)
682  fl = fl->next;
683  else
684  break;
685  roll--;
686  }
687  if (!fl) /* failed! */
688  LOG(llevError, "get_random_recipelist(): no recipelists found!\n");
689  else if (fl->total_chance == 0)
690  fl = get_random_recipelist();
691 
692  return fl;
693 }
694 
704  recipelist *fl = rpl;
705  recipe *rp = NULL;
706  int r = 0;
707 
708  /* looks like we have to choose a random one */
709  if (fl == NULL)
710  if ((fl = get_random_recipelist()) == NULL)
711  return rp;
712 
713  if (fl->total_chance > 0) {
714  r = RANDOM()%fl->total_chance;
715  for (rp = fl->items; rp; rp = rp->next) {
716  r -= rp->chance;
717  if (r < 0)
718  break;
719  }
720  }
721  return rp;
722 }
723 
727 void free_all_recipes(void) {
728  recipelist *fl, *flnext;
729  recipe *formula = NULL, *next;
730  linked_char *lchar, *charnext;
731 
732  LOG(llevDebug, "Freeing all the recipes\n");
733  for (fl = formulalist; fl != NULL; fl = flnext) {
734  flnext = fl->next;
735 
736  for (formula = fl->items; formula != NULL; formula = next) {
737  next = formula->next;
738 
739  free(formula->arch_name[0]);
740  free(formula->arch_name);
741  if (formula->title)
742  free_string(formula->title);
743  if (formula->skill)
744  free_string(formula->skill);
745  if (formula->cauldron)
746  free_string(formula->cauldron);
747  if (formula->failure_arch)
748  free_string(formula->failure_arch);
749  if (formula->failure_message)
750  free_string(formula->failure_message);
751  for (lchar = formula->ingred; lchar; lchar = charnext) {
752  charnext = lchar->next;
753  free_string(lchar->name);
754  free(lchar);
755  }
756  if (formula->tool)
757  free(formula->tool[0]);
758  free(formula->tool);
759  free(formula);
760  }
761  free(fl);
762  }
763  formulalist = NULL;
764 }
765 
777 static void build_stringlist(const char *str, char ***result_list, size_t *result_size) {
778  char *dup;
779  char *p;
780  size_t size;
781  size_t i;
782 
783  dup = strdup_local(str);
784  if (dup == NULL)
786 
787  size = 0;
788  for (p = strtok(dup, ","); p != NULL; p = strtok(NULL, ","))
789  size++;
790 
791  assert(size > 0);
792  *result_list = malloc(sizeof(**result_list) * size);
793  if (*result_list == NULL)
795  *result_size = size;
796 
797  for (i = 0; i < size; i++) {
798  (*result_list)[i] = dup;
799  dup = dup+strlen(dup)+1;
800  }
801 }
802 
810 recipe *find_recipe_for_tool(const char *tool, recipe *from) {
811  size_t t;
812  recipelist *list = from ? get_formulalist(from->ingred_count) : formulalist;
813  recipe *test = from ? from->next : list->items;
814 
815  while (list) {
816  while (test) {
817  for (t = 0; t < test->tool_size; t++) {
818  if (strcmp(test->tool[t], tool) == 0) {
819  return test;
820  }
821  }
822  test = test->next;
823  }
824 
825  list = list->next;
826  }
827 
828  return NULL;
829 }
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:371
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:777
recipe * get_random_recipe(recipelist *rpl)
Definition: recipe.c:703
#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:810
int isqrt(int n)
Definition: utils.c:586
static int numb_ingred(const char *buf)
Definition: recipe.c:603
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:667
Definition: object.h:465
void dump_alchemy_costs(void)
Definition: recipe.c:501
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:1368
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:587
int total_chance
Definition: recipe.h:38
const artifact * locate_recipe_artifact(const recipe *rp, size_t idx)
Definition: recipe.c:643
#define snprintf
Definition: win32.h:46
void dump_alchemy(void)
Definition: recipe.c:299
struct linked_char * next
Definition: global.h:88
int strtoint(const char *buf)
Definition: recipe.c:622
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:727
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:679
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:422
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