… | |
… | |
354 | { |
354 | { |
355 | treasurelist *tl; |
355 | treasurelist *tl; |
356 | archetype *at; |
356 | archetype *at; |
357 | |
357 | |
358 | if (depth > 10) |
358 | if (depth > 10) |
359 | return NULL; |
359 | return 0; |
360 | while (t != NULL) |
360 | |
|
|
361 | while (t) |
361 | { |
362 | { |
362 | if (t->name != NULL) |
363 | if (t->name) |
363 | { |
364 | { |
364 | tl = find_treasurelist (t->name); |
365 | tl = find_treasurelist (t->name); |
|
|
366 | |
|
|
367 | if (tl) |
|
|
368 | { |
365 | at = find_treasure_by_name (tl->items, name, depth + 1); |
369 | at = find_treasure_by_name (tl->items, name, depth + 1); |
366 | if (at != NULL) |
370 | |
|
|
371 | if (at) |
367 | return at; |
372 | return at; |
|
|
373 | } |
368 | } |
374 | } |
369 | else |
375 | else |
370 | { |
376 | { |
371 | if (!strcasecmp (t->item->clone.name, name)) |
377 | if (!strcasecmp (t->item->clone.name, name)) |
372 | return t->item; |
378 | return t->item; |
373 | } |
379 | } |
|
|
380 | |
374 | if (t->next_yes != NULL) |
381 | if (t->next_yes) |
375 | { |
382 | { |
376 | at = find_treasure_by_name (t->next_yes, name, depth); |
383 | at = find_treasure_by_name (t->next_yes, name, depth); |
377 | if (at != NULL) |
384 | if (at) |
378 | return at; |
385 | return at; |
379 | } |
386 | } |
|
|
387 | |
380 | if (t->next_no != NULL) |
388 | if (t->next_no) |
381 | { |
389 | { |
382 | at = find_treasure_by_name (t->next_no, name, depth); |
390 | at = find_treasure_by_name (t->next_no, name, depth); |
383 | if (at != NULL) |
391 | if (at) |
384 | return at; |
392 | return at; |
385 | } |
393 | } |
386 | t = t->next; |
394 | t = t->next; |
387 | } |
395 | } |
388 | return NULL; |
396 | return 0; |
389 | } |
397 | } |
390 | |
398 | |
391 | /* If several archetypes have the same name, the value of the first |
399 | /* If several archetypes have the same name, the value of the first |
392 | * one with that name will be returned. This happens for the |
400 | * one with that name will be returned. This happens for the |
393 | * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the |
401 | * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the |
… | |
… | |
467 | if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
475 | if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
468 | { |
476 | { |
469 | if (at->clone.randomitems != NULL) |
477 | if (at->clone.randomitems != NULL) |
470 | { |
478 | { |
471 | at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); |
479 | at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); |
472 | if (at2 != NULL) |
480 | if (at2) |
473 | return mult * at2->clone.value * isqrt (at->clone.level * 2); |
481 | return mult * at2->clone.value * isqrt (at->clone.level * 2); |
474 | } |
482 | } |
475 | } |
483 | } |
476 | } |
484 | } |
477 | /* failed to find any matching items -- formula should be checked */ |
485 | /* failed to find any matching items -- formula should be checked */ |
… | |
… | |
613 | if ((at = find_artifactlist (item->type))) |
621 | if ((at = find_artifactlist (item->type))) |
614 | for (art = at->items; art; art = art->next) |
622 | for (art = at->items; art; art = art->next) |
615 | if (!strcmp (art->item->name, rp->title)) |
623 | if (!strcmp (art->item->name, rp->title)) |
616 | break; |
624 | break; |
617 | |
625 | |
618 | item->destroy (0); |
626 | item->destroy (); |
619 | |
627 | |
620 | return art; |
628 | return art; |
621 | } |
629 | } |
622 | |
630 | |
623 | int |
631 | int |