… | |
… | |
94 | { |
94 | { |
95 | artifact *art = locate_recipe_artifact (rp, i); |
95 | artifact *art = locate_recipe_artifact (rp, i); |
96 | |
96 | |
97 | if (!art && strcmp (rp->title, "NONE") != 0) |
97 | if (!art && strcmp (rp->title, "NONE") != 0) |
98 | { |
98 | { |
99 | LOG (llevError, "\nWARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], &rp->title); |
99 | LOG (llevError, "WARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], &rp->title); |
100 | result = 0; |
100 | result = 0; |
101 | } |
101 | } |
102 | } |
102 | } |
103 | else |
103 | else |
104 | { |
104 | { |
105 | LOG (llevError, "\nWARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], &rp->title); |
105 | LOG (llevError, "WARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], &rp->title); |
106 | result = 0; |
106 | result = 0; |
107 | } |
107 | } |
108 | } |
108 | } |
109 | |
109 | |
110 | return result; |
110 | return result; |
… | |
… | |
134 | return; |
134 | return; |
135 | else |
135 | else |
136 | has_been_done = 1; |
136 | has_been_done = 1; |
137 | |
137 | |
138 | sprintf (filename, "%s/formulae", settings.datadir); |
138 | sprintf (filename, "%s/formulae", settings.datadir); |
139 | LOG (llevDebug, "Reading alchemical formulae from %s...", filename); |
139 | LOG (llevDebug, "Reading alchemical formulae from %s...\n", filename); |
140 | if ((fp = open_and_uncompress (filename, 0, &comp)) == NULL) |
140 | if ((fp = open_and_uncompress (filename, 0, &comp)) == NULL) |
141 | { |
141 | { |
142 | LOG (llevError, "Can't open %s.\n", filename); |
142 | LOG (llevError, "Can't open %s.\n", filename); |
143 | return; |
143 | return; |
144 | } |
144 | } |
… | |
… | |
254 | { |
254 | { |
255 | recipelist *fl; |
255 | recipelist *fl; |
256 | recipe *check, *formula; |
256 | recipe *check, *formula; |
257 | int numb = 1; |
257 | int numb = 1; |
258 | |
258 | |
259 | LOG (llevDebug, "Checking formulae lists..."); |
259 | LOG (llevDebug, "Checking formulae lists...\n"); |
260 | |
260 | |
261 | for (fl = formulalist; fl != NULL; fl = fl->next) |
261 | for (fl = formulalist; fl != NULL; fl = fl->next) |
262 | { |
262 | { |
263 | for (formula = fl->items; formula != NULL; formula = formula->next) |
263 | for (formula = fl->items; formula != NULL; formula = formula->next) |
264 | for (check = formula->next; check != NULL; check = check->next) |
264 | for (check = formula->next; check != NULL; check = check->next) |
… | |
… | |
373 | return at; |
373 | return at; |
374 | } |
374 | } |
375 | } |
375 | } |
376 | else |
376 | else |
377 | { |
377 | { |
378 | if (!strcasecmp (t->item->clone.name, name)) |
378 | if (t->item && !strcasecmp (t->item->clone.name, name)) |
379 | return t->item; |
379 | return t->item; |
380 | } |
380 | } |
381 | |
381 | |
382 | if (t->next_yes) |
382 | if (t->next_yes) |
383 | { |
383 | { |
… | |
… | |
650 | for (fl = get_formulalist (1); fl; fl = fl->next) |
650 | for (fl = get_formulalist (1); fl; fl = fl->next) |
651 | number++; |
651 | number++; |
652 | |
652 | |
653 | /* now, randomly choose one */ |
653 | /* now, randomly choose one */ |
654 | if (number > 0) |
654 | if (number > 0) |
655 | roll = RANDOM () % number; |
655 | roll = rndm (number); |
656 | |
656 | |
657 | fl = get_formulalist (1); |
657 | fl = get_formulalist (1); |
658 | while (roll && fl) |
658 | while (roll && fl) |
659 | { |
659 | { |
660 | if (fl->next) |
660 | if (fl->next) |
… | |
… | |
683 | if ((fl = get_random_recipelist ()) == NULL) |
683 | if ((fl = get_random_recipelist ()) == NULL) |
684 | return rp; |
684 | return rp; |
685 | |
685 | |
686 | if (fl->total_chance > 0) |
686 | if (fl->total_chance > 0) |
687 | { |
687 | { |
688 | r = RANDOM () % fl->total_chance; |
688 | r = rndm (fl->total_chance); |
689 | for (rp = fl->items; rp; rp = rp->next) |
689 | for (rp = fl->items; rp; rp = rp->next) |
690 | { |
690 | { |
691 | r -= rp->chance; |
691 | r -= rp->chance; |
692 | if (r < 0) |
692 | if (r < 0) |
693 | break; |
693 | break; |