… | |
… | |
16 | * chance 10 |
16 | * chance 10 |
17 | * ingred dust of beholdereye,gem |
17 | * ingred dust of beholdereye,gem |
18 | * arch potion_generic |
18 | * arch potion_generic |
19 | */ |
19 | */ |
20 | |
20 | |
|
|
21 | #include <cctype> |
|
|
22 | |
21 | #include <global.h> |
23 | #include <global.h> |
22 | #include <object.h> |
24 | #include <object.h> |
23 | #include <ctype.h> |
|
|
24 | |
25 | |
25 | static void build_stringlist (const char *str, char ***result_list, size_t * result_size); |
26 | static void build_stringlist (const char *str, char ***result_list, size_t * result_size); |
26 | |
27 | |
27 | static recipelist *formulalist; |
28 | static recipelist *formulalist; |
28 | |
29 | |
… | |
… | |
354 | { |
355 | { |
355 | treasurelist *tl; |
356 | treasurelist *tl; |
356 | archetype *at; |
357 | archetype *at; |
357 | |
358 | |
358 | if (depth > 10) |
359 | if (depth > 10) |
359 | return NULL; |
360 | return 0; |
360 | while (t != NULL) |
361 | |
|
|
362 | while (t) |
361 | { |
363 | { |
362 | if (t->name != NULL) |
364 | if (t->name) |
363 | { |
365 | { |
364 | tl = find_treasurelist (t->name); |
366 | tl = find_treasurelist (t->name); |
|
|
367 | |
|
|
368 | if (tl) |
|
|
369 | { |
365 | at = find_treasure_by_name (tl->items, name, depth + 1); |
370 | at = find_treasure_by_name (tl->items, name, depth + 1); |
366 | if (at != NULL) |
371 | |
|
|
372 | if (at) |
367 | return at; |
373 | return at; |
|
|
374 | } |
368 | } |
375 | } |
369 | else |
376 | else |
370 | { |
377 | { |
371 | if (!strcasecmp (t->item->clone.name, name)) |
378 | if (!strcasecmp (t->item->clone.name, name)) |
372 | return t->item; |
379 | return t->item; |
373 | } |
380 | } |
|
|
381 | |
374 | if (t->next_yes != NULL) |
382 | if (t->next_yes) |
375 | { |
383 | { |
376 | at = find_treasure_by_name (t->next_yes, name, depth); |
384 | at = find_treasure_by_name (t->next_yes, name, depth); |
377 | if (at != NULL) |
385 | if (at) |
378 | return at; |
386 | return at; |
379 | } |
387 | } |
|
|
388 | |
380 | if (t->next_no != NULL) |
389 | if (t->next_no) |
381 | { |
390 | { |
382 | at = find_treasure_by_name (t->next_no, name, depth); |
391 | at = find_treasure_by_name (t->next_no, name, depth); |
383 | if (at != NULL) |
392 | if (at) |
384 | return at; |
393 | return at; |
385 | } |
394 | } |
386 | t = t->next; |
395 | t = t->next; |
387 | } |
396 | } |
388 | return NULL; |
397 | return 0; |
389 | } |
398 | } |
390 | |
399 | |
391 | /* If several archetypes have the same name, the value of the first |
400 | /* If several archetypes have the same name, the value of the first |
392 | * one with that name will be returned. This happens for the |
401 | * one with that name will be returned. This happens for the |
393 | * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the |
402 | * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the |
… | |
… | |
467 | if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
476 | if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
468 | { |
477 | { |
469 | if (at->clone.randomitems != NULL) |
478 | if (at->clone.randomitems != NULL) |
470 | { |
479 | { |
471 | at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); |
480 | at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); |
472 | if (at2 != NULL) |
481 | if (at2) |
473 | return mult * at2->clone.value * isqrt (at->clone.level * 2); |
482 | return mult * at2->clone.value * isqrt (at->clone.level * 2); |
474 | } |
483 | } |
475 | } |
484 | } |
476 | } |
485 | } |
477 | /* failed to find any matching items -- formula should be checked */ |
486 | /* failed to find any matching items -- formula should be checked */ |
… | |
… | |
735 | char *dup; |
744 | char *dup; |
736 | char *p; |
745 | char *p; |
737 | size_t size; |
746 | size_t size; |
738 | size_t i; |
747 | size_t i; |
739 | |
748 | |
740 | dup = strdup_local (str); |
749 | dup = strdup (str); |
741 | if (dup == NULL) |
750 | if (dup == NULL) |
742 | fatal (OUT_OF_MEMORY); |
751 | fatal (OUT_OF_MEMORY); |
743 | |
752 | |
744 | size = 0; |
753 | size = 0; |
745 | for (p = strtok (dup, ","); p != NULL; p = strtok (NULL, ",")) |
754 | for (p = strtok (dup, ","); p != NULL; p = strtok (NULL, ",")) |