Crossfire Server, Trunk
recipe.cpp
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 #include <memory>
42 
43 #include "object.h"
44 #include "assets.h"
45 #include "AssetsManager.h"
46 
47 static void build_stringlist(const char *str, char ***result_list, size_t *result_size);
48 
51 
60 static recipelist *init_recipelist(void) {
61  recipelist *tl = (recipelist *)malloc(sizeof(recipelist));
62  if (tl == NULL)
64  tl->total_chance = 0;
65  tl->number = 0;
66  tl->items = NULL;
67  tl->next = NULL;
68  return tl;
69 }
70 
79 static recipe *get_empty_formula(void) {
80  // This used to be a malloc followed by setting everything to zero.
81  // So just use calloc to make it faster.
82  // SilverNexus -- 2018-10-22
83  recipe *t = (recipe *)calloc(1, sizeof(recipe));
84  if (t == NULL)
86  return t;
87 }
88 
99  recipelist *fl = formulalist;
100  int number = i;
101 
102  while (fl && number > 1) {
103  if (!(fl = fl->next))
104  break;
105  number--;
106  }
107  return fl;
108 }
109 
120 static int check_recipe(const recipe *rp) {
121  size_t i;
122  int result;
123 
124  result = 1;
125  for (i = 0; i < rp->arch_names; i++) {
126  if (try_find_archetype(rp->arch_name[i]) != NULL) {
127  if (strcmp(rp->title, "NONE")) {
128  const artifact *art = locate_recipe_artifact(rp, i);
129 
130  if (!art) {
131  LOG(llevError, "Formula %s of %s has no artifact.\n", rp->arch_name[i], rp->title);
132  result = 0;
133  }
134  }
135  } else {
136  LOG(llevError, "Can't find archetype %s for formula %s\n", rp->arch_name[i], rp->title);
137  result = 0;
138  }
139  }
140 
141  return result;
142 }
143 
149  const recipelist *rl = formulalist;
150  int abort = 0;
151  while (rl) {
152  const recipe *rp = rl->items;
153  while (rp) {
154  if (!check_recipe(rp)) {
155  abort = 1;
156  }
157  rp = rp->next;
158  }
159  rl = rl->next;
160  }
161  if (abort) {
163  }
164 }
165 
169 void init_formulae(BufferReader *reader, const char *filename) {
170  char *buf, *cp, *next;
171  recipe *formula = NULL;
172  recipelist *fl;
173  linked_char *tmp;
174  int value;
175 
176  if (!formulalist)
178 
179  while ((buf = bufferreader_next_line(reader)) != NULL) {
180  if (*buf == '#' || *buf == '\0')
181  continue;
182  cp = buf;
183  while (*cp == ' ') /* Skip blanks */
184  cp++;
185 
186  if (!strncmp(cp, "Remove ", 7)) {
187  if (strcmp(cp + 7, "*") == 0) {
190  } else {
191  LOG(llevError, "Recipes: only '*' is accepted for 'Remove' at %s:%zu\n", filename, bufferreader_current_line(reader));
192  }
193  continue;
194  }
195  if (!strncmp(cp, "Object", 6)) {
196  formula = get_empty_formula();
197  formula->title = add_string(strchr(cp, ' ')+1);
198  } else if (formula == NULL) {
199  LOG(llevError, "recipe.c: First key in formulae file %s is not \"Object\".\n", filename);
201  } else if (!strncmp(cp, "keycode", 7)) {
202  formula->keycode = add_string(strchr(cp, ' ')+1);
203  } else if (sscanf(cp, "trans %d", &value)) {
204  formula->transmute = value;
205  } else if (sscanf(cp, "yield %d", &value)) {
206  formula->yield = value;
207  } else if (sscanf(cp, "chance %d", &value)) {
208  formula->chance = value;
209  } else if (sscanf(cp, "exp %d", &value)) {
210  formula->exp = value;
211  } else if (sscanf(cp, "diff %d", &value)) {
212  formula->diff = value;
213  } else if (!strncmp(cp, "ingred", 6)) {
214  int numb_ingred;
215  formula->ingred_count = 1;
216  cp = strchr(cp, ' ')+1;
217  do {
218  if ((next = strchr(cp, ',')) != NULL) {
219  *(next++) = '\0';
220  formula->ingred_count++;
221  }
222  tmp = (linked_char *)malloc(sizeof(linked_char));
223  /* trim the string */
224  while (*cp == ' ')
225  cp++;
226  while (*cp != '\0' && cp[strlen(cp) - 1] == ' ')
227  cp[strlen(cp) - 1] = '\0';
228  tmp->name = add_string(cp);
229  tmp->next = formula->ingred;
230  formula->ingred = tmp;
231  /* each ingredient's ASCII value is coadded. Later on this
232  * value will be used allow us to search the formula lists
233  * quickly for the right recipe.
234  */
235  formula->index += strtoint(cp);
236  } while ((cp = next) != NULL);
237  /* now find the correct (# of ingred ordered) formulalist */
238  numb_ingred = formula->ingred_count;
239  fl = formulalist;
240  while (numb_ingred != 1) {
241  if (!fl->next)
242  fl->next = init_recipelist();
243  fl = fl->next;
244  numb_ingred--;
245  }
246  formula->next = fl->items;
247  fl->items = formula;
248  } else if (!strncmp(cp, "arch", 4)) {
249  build_stringlist(strchr(cp, ' ')+1, &formula->arch_name, &formula->arch_names);
250  } else if (!strncmp(cp, "skill", 5)) {
251  formula->skill = add_string(strchr(cp, ' ')+1);
252  } else if (!strncmp(cp, "cauldron", 8)) {
253  formula->cauldron = add_string(strchr(cp, ' ')+1);
254  } else if (!strncmp(cp, "failure_arch ", 13)) {
255  formula->failure_arch = add_string(strchr(cp, ' ')+1);
256  } else if (!strncmp(cp, "failure_message ", 16)) {
257  formula->failure_message = add_string(strchr(cp, ' ')+1);
258  } else if (sscanf(cp, "min_level %d", &value)) {
259  formula->min_level = value;
260  } else if (!strncmp(cp, "tool ", 5)) {
261  build_stringlist(strchr(cp, ' ')+1, &formula->tool, &formula->tool_size);
262  } else if (sscanf(cp, "combination %d", &value)) {
263  formula->is_combination = value ? 1 : 0;
264  } else
265  LOG(llevError, "Unknown input in file %s: %s\n", filename, buf);
266  }
267  /* Set the total chance and count for each formula list.
268  * This needs to be done at the end to avoid dependancies on the field order in the file
269  */
270  for (fl = formulalist; fl; fl = fl->next) {
271  fl->total_chance = 0;
272  fl->number = 0;
273  for (formula = fl->items; formula; formula = formula->next) {
274  fl->total_chance += formula->chance;
275  fl->number++;
276  }
277  }
278  LOG(llevDebug, "done.\n");
279 }
280 
295 void check_formulae(void) {
296  recipelist *fl;
297  recipe *check, *formula;
298  int numb = 1, tool_match;
299  size_t tool_i,tool_j;
300 
301  LOG(llevDebug, "Checking formulae lists...\n");
302 
303  for (fl = formulalist; fl != NULL; fl = fl->next) {
304  for (formula = fl->items; formula != NULL; formula = formula->next) {
305  for (check = formula->next; check != NULL; check = check->next)
306  /* If one recipe has a tool and another a caudron, we should be able to handle it */
307  if (check->index == formula->index &&
308  ((check->cauldron && formula->cauldron && strcmp(check->cauldron, formula->cauldron) == 0) ||
309  (check->tool_size == formula->tool_size && check->tool_size > 0))) {
310  /* Check the tool list to make sure they have no matches */
311  if (check->tool && formula->tool)
312  {
313  tool_match = 0;
314  for (tool_i = 0; tool_i < formula->tool_size; ++tool_i)
315  /* If it turns out these lists are sorted, then we could optimize this better. */
316  for (tool_j = 0; tool_j < check->tool_size; ++tool_j)
317  if (strcmp(formula->tool[tool_i], check->tool[tool_j]) == 0) {
318  tool_match = 1;
319  break; /* TODO: break out of the double loop */
320  }
321  }
322  else
323  tool_match = 1; /* If we get here, we matched on the cauldron */
324  /* Check to see if we have a denoted match */
325  if (tool_match) {
326  /* if the recipes don't have the same facility, then no issue anyway. */
327  LOG(llevError, " ERROR: On %d ingred list:\n", numb);
328  LOG(llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n",
329  formula->arch_name[0], formula->title, check->arch_name[0], check->title, formula->index);
330  }
331  }
332  for (size_t idx = 0; idx < formula->arch_names; idx++) {
333  if (try_find_archetype(formula->arch_name[idx]) == NULL) {
334  LOG(llevError, "Formulae %s of %s (%d ingredients) references non existent archetype %s\n",
335  formula->arch_name[0], formula->title, numb, formula->arch_name[idx]);
336  }
337  }
338  }
339  numb++;
340  }
341 
342  LOG(llevDebug, "done checking.\n");
343 }
344 
352 void dump_alchemy(void) {
353  recipelist *fl = formulalist;
354  recipe *formula = NULL;
355  linked_char *next;
356  int num_ingred = 1;
357 
358  fprintf(logfile, "\n");
359  while (fl) {
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) {
362  const artifact *art = NULL;
363  char buf[MAX_BUF];
364  size_t i;
365 
366  for (i = 0; i < formula->arch_names; i++) {
367  const char *string = formula->arch_name[i];
368 
369  if (try_find_archetype(string) != NULL) {
370  art = locate_recipe_artifact(formula, i);
371  if (!art && strcmp(formula->title, "NONE"))
372  LOG(llevError, "Formula %s has no artifact\n", formula->title);
373  else {
374  if (strcmp(formula->title, "NONE"))
375  snprintf(buf, sizeof(buf), "%s of %s", string, formula->title);
376  else
377  strlcpy(buf, string, sizeof(buf));
378  fprintf(logfile, "%-30s(%d) bookchance %3d ", buf, formula->index, formula->chance);
379  fprintf(logfile, "skill %s", formula->skill);
380  fprintf(logfile, "\n");
381  if (formula->ingred != NULL) {
382  int nval = 0, tval = 0;
383  fprintf(logfile, "\tIngred: ");
384  for (next = formula->ingred; next != NULL; next = next->next) {
385  if (nval != 0)
386  fprintf(logfile, ",");
387  fprintf(logfile, "%s(%d)", next->name, (nval = strtoint(next->name)));
388  tval += nval;
389  }
390  fprintf(logfile, "\n");
391  if (tval != formula->index)
392  fprintf(logfile, "WARNING:ingredient list and formula values not equal.\n");
393  }
394  if (formula->skill != NULL)
395  fprintf(logfile, "\tSkill Required: %s", formula->skill);
396  if (formula->cauldron != NULL)
397  fprintf(logfile, "\tCauldron: %s\n", formula->cauldron);
398  fprintf(logfile, "\tDifficulty: %d\t Exp: %d\n", formula->diff, formula->exp);
399  }
400  } else
401  LOG(llevError, "Can't find archetype:%s for formula %s\n", string, formula->title);
402  }
403  }
404  fprintf(logfile, "\n");
405  fl = fl->next;
406  num_ingred++;
407  }
408 }
409 
424 archetype *find_treasure_by_name(const treasure *t, const char *name, int depth) {
425  treasurelist *tl;
426  archetype *at;
427 
428  if (depth > 10)
429  return NULL;
430 
431  while (t != NULL) {
432  if (t->name != NULL) {
433  tl = find_treasurelist(t->name);
434  at = find_treasure_by_name(tl->items, name, depth+1);
435  if (at != NULL)
436  return at;
437  } else {
438  if (!strcasecmp(t->item->clone.name, name))
439  return t->item;
440  }
441  if (t->next_yes != NULL) {
442  at = find_treasure_by_name(t->next_yes, name, depth);
443  if (at != NULL)
444  return at;
445  }
446  if (t->next_no != NULL) {
447  at = find_treasure_by_name(t->next_no, name, depth);
448  if (at != NULL)
449  return at;
450  }
451  t = t->next;
452  }
453  return NULL;
454 }
455 
475 static long recipe_find_ingredient_cost(const char *name) {
476  long mult;
477  const char *cp;
478  char part1[100];
479  char part2[100];
480 
481  /* same as atoi(), but skip number */
482  mult = 0;
483  while (isdigit(*name)) {
484  mult = 10*mult+(*name-'0');
485  name++;
486  }
487  if (mult > 0)
488  name++;
489  else
490  mult = 1;
491  /* first, try to match the name of an archetype */
492 
493  long value = 0;
494  bool found = false;
495  getManager()->archetypes()->each([&value, &found, &name, &part1] (const archetype *at) {
496  if (found) {
497  return;
498  }
499 
500  if (at->clone.title != NULL) {
501  /* inefficient, but who cares? */
502  snprintf(part1, sizeof(part1), "%s %s", at->clone.name, at->clone.title);
503  if (!strcasecmp(part1, name)) {
504  value = at->clone.value;
505  found = true;
506  return;
507  }
508  }
509  if (!strcasecmp(at->clone.name, name)) {
510  value = at->clone.value;
511  found = true;
512  return;
513  }
514  });
515  if (found) {
516  return mult * value;
517  }
518 
519  /* second, try to match an artifact ("arch of something") */
520  cp = strstr(name, " of ");
521  if (cp != NULL) {
522  safe_strncpy(part1, name, sizeof(part1));
523  part1[cp-name] = '\0';
524  safe_strncpy(part2, cp + 4, sizeof(part2));
525  getManager()->archetypes()->each([&value, &found, &part1, &part2] (const archetype *at) {
526  if (found) {
527  return;
528  }
529 
530  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
531  /* find the first artifact derived from that archetype (same type) */
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;
537  found = true;
538  return;
539  }
540  }
541  }
542  }
543  }
544  });
545  }
546  if (found) {
547  return mult * value;
548  }
549 
550  /* third, try to match a body part ("arch's something") */
551  cp = strstr(name, "'s ");
552  if (cp != NULL) {
553  safe_strncpy(part1, name, sizeof(part1));
554  part1[cp-name] = '\0';
555  safe_strncpy(part2, cp + 3, sizeof(part2));
556  /* examine all archetypes matching the first part of the name */
557  getManager()->archetypes()->each([&value, &found, &part1, &part2] (const archetype *at) {
558  if (found) {
559  return;
560  }
561  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
562  if (at->clone.randomitems != NULL) {
563  auto at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
564  if (at2 != NULL) {
565  value = at2->clone.value * isqrt(at->clone.level * 2);
566  found = true;
567  return;
568  }
569  }
570  }
571  });
572  }
573  if (found) {
574  return mult * value;
575  }
576 
577  /* failed to find any matching items -- formula should be checked */
578  LOG(llevError, "Couldn't find cost for ingredient %s\n", name);
579  return -1;
580 }
581 
590 void dump_alchemy_costs(void) {
591  recipelist *fl = formulalist;
592  recipe *formula = NULL;
593  linked_char *next;
594  int num_ingred = 1;
595  int num_errors = 0;
596  long cost;
597  long tcost;
598 
599  fprintf(logfile, "\n");
600  while (fl) {
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) {
603  const artifact *art = NULL;
604  const archetype *at = NULL;
605  char buf[MAX_BUF];
606  size_t i;
607 
608  for (i = 0; i < formula->arch_names; i++) {
609  const char *string = formula->arch_name[i];
610 
611  if ((at = try_find_archetype(string)) != NULL) {
612  art = locate_recipe_artifact(formula, i);
613  if (!art && strcmp(formula->title, "NONE"))
614  LOG(llevError, "Formula %s has no artifact\n", formula->title);
615  else {
616  if (!strcmp(formula->title, "NONE"))
617  strlcpy(buf, string, sizeof(buf));
618  else
619  snprintf(buf, sizeof(buf), "%s of %s", string, formula->title);
620  fprintf(logfile, "\n%-40s bookchance %3d skill %s\n", buf, formula->chance, formula->skill);
621  if (formula->ingred != NULL) {
622  tcost = 0;
623  for (next = formula->ingred; next != NULL; next = next->next) {
625  if (cost < 0)
626  num_errors++;
627  fprintf(logfile, "\t%-33s%5ld\n", next->name, cost);
628  if (cost < 0 || tcost < 0)
629  tcost = -1;
630  else
631  tcost += cost;
632  }
633  if (art != NULL && art->item != NULL)
634  cost = at->clone.value*art->item->value;
635  else
636  cost = at->clone.value;
637  fprintf(logfile, "\t\tBuying result costs: %5ld", cost);
638  if (formula->yield > 1) {
639  fprintf(logfile, " to %ld (max %d items)\n", cost*formula->yield, formula->yield);
640  cost = cost*(formula->yield+1L)/2L;
641  } else
642  fprintf(logfile, "\n");
643  fprintf(logfile, "\t\tIngredients cost: %5ld\n\t\tComment: ", tcost);
644  if (tcost < 0)
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");
652  else
653  fprintf(logfile, "OK.\n");
654  }
655  }
656  } else
657  LOG(llevError, "Can't find archetype:%s for formula %s\n", string, formula->title);
658  }
659  }
660  fprintf(logfile, "\n");
661  fl = fl->next;
662  num_ingred++;
663  }
664  if (num_errors > 0)
665  fprintf(logfile, "WARNING: %d objects required by the formulae do not exist in the game.\n", num_errors);
666 }
667 
676 static const char *ingred_name(const char *name) {
677  const char *cp = name;
678 
679  if (atoi(cp))
680  cp = strchr(cp, ' ')+1;
681  return cp;
682 }
683 
692 static int numb_ingred(const char *buf) {
693  int numb;
694 
695  if ((numb = atoi(buf)))
696  return numb;
697  else
698  return 1;
699 }
700 
711 int strtoint(const char *buf) {
712  const char *cp = ingred_name(buf);
713  int val = 0, len = strlen(cp), mult = numb_ingred(buf);
714 
715  while (len) {
716  val += tolower(*cp);
717  cp++; len--;
718  }
719  return val*mult;
720 }
721 
732 const artifact *locate_recipe_artifact(const recipe *rp, size_t idx) {
733  std::unique_ptr<object, void(*)(object *)> item(create_archetype(rp->arch_name[idx]), object_free_drop_inventory);
734  const artifactlist *at = NULL;
735 
736  if (!item)
737  return (artifact *)NULL;
738 
739  if ((at = find_artifactlist(item->type)))
740  for (auto art : at->items)
741  if (!strcmp(art->item->name, rp->title) && legal_artifact_combination(item.get(), art))
742  return art;
743 
744  return nullptr;
745 }
746 
754  recipelist *fl = NULL;
755  int number = 0, roll = 0;
756 
757  /* first, determine # of recipelist we have */
758  for (fl = get_formulalist(1); fl; fl = fl->next)
759  number++;
760 
761  /* now, randomly choose one */
762  if (number > 0)
763  roll = RANDOM()%number;
764 
765  fl = get_formulalist(1);
766  while (roll && fl) {
767  if (fl->next)
768  fl = fl->next;
769  else
770  break;
771  roll--;
772  }
773  if (!fl) /* failed! */
774  LOG(llevError, "get_random_recipelist(): no recipelists found!\n");
775  else if (fl->total_chance == 0)
776  fl = get_random_recipelist();
777 
778  return fl;
779 }
780 
790  recipelist *fl = rpl;
791  recipe *rp = NULL;
792  int r = 0;
793 
794  /* looks like we have to choose a random one */
795  if (fl == NULL)
796  if ((fl = get_random_recipelist()) == NULL)
797  return rp;
798 
799  if (fl->total_chance > 0) {
800  r = RANDOM()%fl->total_chance;
801  for (rp = fl->items; rp; rp = rp->next) {
802  r -= rp->chance;
803  if (r < 0)
804  break;
805  }
806  }
807  return rp;
808 }
809 
813 void free_all_recipes(void) {
814  recipelist *fl, *flnext;
815  recipe *formula = NULL, *next;
816  linked_char *lchar, *charnext;
817 
818  LOG(llevDebug, "Freeing all the recipes\n");
819  for (fl = formulalist; fl != NULL; fl = flnext) {
820  flnext = fl->next;
821 
822  for (formula = fl->items; formula != NULL; formula = next) {
823  next = formula->next;
824 
825  free(formula->arch_name[0]);
826  free(formula->arch_name);
827  if (formula->title)
828  free_string(formula->title);
829  if (formula->skill)
830  free_string(formula->skill);
831  if (formula->cauldron)
832  free_string(formula->cauldron);
833  if (formula->failure_arch)
834  free_string(formula->failure_arch);
835  if (formula->failure_message)
836  free_string(formula->failure_message);
837  for (lchar = formula->ingred; lchar; lchar = charnext) {
838  charnext = lchar->next;
839  free_string(lchar->name);
840  free(lchar);
841  }
842  if (formula->tool)
843  free(formula->tool[0]);
844  free(formula->tool);
845  free(formula);
846  }
847  free(fl);
848  }
849  formulalist = NULL;
850 }
851 
863 static void build_stringlist(const char *str, char ***result_list, size_t *result_size) {
864  char *dup;
865  char *p;
866  size_t size;
867  size_t i;
868 
869  dup = strdup_local(str);
870  if (dup == NULL)
872 
873  size = 0;
874  for (p = strtok(dup, ","); p != NULL; p = strtok(NULL, ","))
875  size++;
876 
877  assert(size > 0);
878  *result_list = static_cast<char **>(malloc(sizeof(**result_list) * size));
879  if (*result_list == NULL)
881  *result_size = size;
882 
883  for (i = 0; i < size; i++) {
884  (*result_list)[i] = dup;
885  dup = dup+strlen(dup)+1;
886  }
887 }
888 
896 recipe *find_recipe_for_tool(const char *tool, recipe *from) {
897  size_t t;
899  recipe *test = from ? from->next : list->items;
900 
901  while (list) {
902  while (test) {
903  for (t = 0; t < test->tool_size; t++) {
904  if (strcmp(test->tool[t], tool) == 0) {
905  return test;
906  }
907  }
908  test = test->next;
909  }
910 
911  list = list->next;
912  }
913 
914  return NULL;
915 }
916 
922 const Face *recipe_get_face(const recipe *rp) {
923  const artifact *art;
924  archetype *arch;
925  object *item;
926  const Face *face;
927 
928  if (rp->arch_names == 0)
929  return NULL;
930 
932  if (arch == NULL) {
933  return NULL;
934  }
935  if (strcmp(rp->title, "NONE") == 0) {
936  return arch->clone.face;
937  }
938 
939  art = locate_recipe_artifact(rp, 0);
940  if (art == NULL)
941  return arch->clone.face;
942 
943  face = arch->clone.face;
947  if (item->face != NULL && item->face != blank_face)
948  face = item->face;
950 
951  return face;
952 }
find_recipe_for_tool
recipe * find_recipe_for_tool(const char *tool, recipe *from)
Definition: recipe.cpp:896
give.next
def next
Definition: give.py:44
Face
Definition: face.h:14
global.h
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:534
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
get_formulalist
recipelist * get_formulalist(int i)
Definition: recipe.cpp:98
recipe::tool_size
size_t tool_size
Definition: recipe.h:33
bufferreader_current_line
size_t bufferreader_current_line(BufferReader *br)
Definition: bufferreader.cpp:140
llevError
@ llevError
Definition: logger.h:11
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
strdup_local
#define strdup_local
Definition: compat.h:29
recipe::arch_names
size_t arch_names
Definition: recipe.h:12
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
treasurelist::items
treasure * items
Definition: treasure.h:92
AssetsManager.h
dump_alchemy_costs
void dump_alchemy_costs(void)
Definition: recipe.cpp:590
init_recipelist
static recipelist * init_recipelist(void)
Definition: recipe.cpp:60
recipe::yield
int yield
Definition: recipe.h:21
get_random_recipelist
static recipelist * get_random_recipelist(void)
Definition: recipe.cpp:753
recipe::failure_arch
sstring failure_arch
Definition: recipe.h:28
guildoracle.list
list
Definition: guildoracle.py:87
give_artifact_abilities
void give_artifact_abilities(object *op, const object *artifact)
Definition: artifact.cpp:230
recipelist::next
recipelist * next
Definition: recipe.h:41
artifact::item
object * item
Definition: artifact.h:15
recipelist::items
recipe * items
Definition: recipe.h:40
check_recipe
static int check_recipe(const recipe *rp)
Definition: recipe.cpp:120
tolower
#define tolower(C)
Definition: c_new.cpp:30
find_treasurelist
treasurelist * find_treasurelist(const char *name)
Definition: assets.cpp:249
recipe::failure_message
sstring failure_message
Definition: recipe.h:29
Ice.tmp
int tmp
Definition: Ice.py:207
recipe::arch_name
char ** arch_name
Definition: recipe.h:13
blank_face
const Face * blank_face
Definition: image.cpp:36
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
recipe::transmute
int transmute
Definition: recipe.h:19
npc_dialog.filename
filename
Definition: npc_dialog.py:99
object::title
sstring title
Definition: object.h:323
recipe_find_ingredient_cost
static long recipe_find_ingredient_cost(const char *name)
Definition: recipe.cpp:475
recipe::exp
int exp
Definition: recipe.h:17
diamondslots.object
object
Definition: diamondslots.py:34
buf
StringBuffer * buf
Definition: readable.cpp:1551
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
recipelist::total_chance
int total_chance
Definition: recipe.h:38
formulalist
static recipelist * formulalist
Definition: recipe.cpp:50
linked_char
Definition: global.h:96
recipe::is_combination
int is_combination
Definition: recipe.h:31
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.cpp:1560
linked_char::name
const char * name
Definition: global.h:97
recipelist
Definition: recipe.h:37
rotate-tower.result
bool result
Definition: rotate-tower.py:13
check_formulae
void check_formulae(void)
Definition: recipe.cpp:295
treasurelist
Definition: treasure.h:85
archetype::clone
object clone
Definition: object.h:476
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
make_face_from_files.str
str
Definition: make_face_from_files.py:24
object::value
int32_t value
Definition: object.h:358
recipe::index
int index
Definition: recipe.h:18
numb_ingred
static int numb_ingred(const char *buf)
Definition: recipe.cpp:692
linked_char::next
struct linked_char * next
Definition: global.h:98
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1592
artifactlist
Definition: artifact.h:24
archetype
Definition: object.h:472
logfile
FILE * logfile
Definition: init.cpp:114
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:158
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
fatal
void fatal(enum fatal_error err)
Definition: utils.cpp:570
recipe::ingred_count
int ingred_count
Definition: recipe.h:23
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
MAX_BUF
#define MAX_BUF
Definition: define.h:35
free_all_recipes
void free_all_recipes(void)
Definition: recipe.cpp:813
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.cpp:222
create_archetype
object * create_archetype(const char *name)
Definition: arch.cpp:278
free_string
void free_string(sstring str)
Definition: shstr.cpp:280
RANDOM
#define RANDOM()
Definition: define.h:644
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
recipe
Definition: recipe.h:10
recipe::tool
char ** tool
Definition: recipe.h:32
check_recipes
void check_recipes()
Definition: recipe.cpp:148
Floor.t
t
Definition: Floor.py:62
object::name
sstring name
Definition: object.h:317
get_random_recipe
recipe * get_random_recipe(recipelist *rpl)
Definition: recipe.cpp:789
bigchest.check
check
Definition: bigchest.py:10
locate_recipe_artifact
const artifact * locate_recipe_artifact(const recipe *rp, size_t idx)
Definition: recipe.cpp:732
ingred_name
static const char * ingred_name(const char *name)
Definition: recipe.cpp:676
find_treasure_by_name
archetype * find_treasure_by_name(const treasure *t, const char *name, int depth)
Definition: recipe.cpp:424
recipe::chance
int chance
Definition: recipe.h:14
item
Definition: item.py:1
autojail.value
value
Definition: autojail.py:6
dump_alchemy
void dump_alchemy(void)
Definition: recipe.cpp:352
strtoint
int strtoint(const char *buf)
Definition: recipe.cpp:711
recipe::diff
int diff
Definition: recipe.h:16
assets.h
arch_to_object
object * arch_to_object(archetype *at)
Definition: arch.cpp:229
object_give_identified_properties
void object_give_identified_properties(object *op)
Definition: item.cpp:1344
init_formulae
void init_formulae(BufferReader *reader, const char *filename)
Definition: recipe.cpp:169
strcasecmp
int strcasecmp(const char *s1, const char *s2)
recipe::keycode
sstring keycode
Definition: recipe.h:25
recipelist::number
int number
Definition: recipe.h:39
recipe::min_level
int min_level
Definition: recipe.h:30
get_empty_formula
static recipe * get_empty_formula(void)
Definition: recipe.cpp:79
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:270
recipe::ingred
linked_char * ingred
Definition: recipe.h:22
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Definition: object.h:533
recipe::next
recipe * next
Definition: recipe.h:24
recipe::skill
sstring skill
Definition: recipe.h:26
say.item
dictionary item
Definition: say.py:149
treasure
Definition: treasure.h:63
artifact
Definition: artifact.h:14
diamondslots.cost
int cost
Definition: diamondslots.py:21
build_stringlist
static void build_stringlist(const char *str, char ***result_list, size_t *result_size)
Definition: recipe.cpp:863
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
BufferReader
Definition: bufferreader.cpp:21
find_artifactlist
artifactlist * find_artifactlist(int type)
Definition: artifact.cpp:574
recipe_get_face
const Face * recipe_get_face(const recipe *rp)
Definition: recipe.cpp:922
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6
object.h
llevDebug
@ llevDebug
Definition: logger.h:13
give.name
name
Definition: give.py:27
legal_artifact_combination
int legal_artifact_combination(const object *op, const artifact *art)
Definition: artifact.cpp:252
recipe::cauldron
sstring cauldron
Definition: recipe.h:27
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Definition: bufferreader.cpp:102
recipe::title
sstring title
Definition: recipe.h:11