… | |
… | |
52 | > tl_map_t; |
52 | > tl_map_t; |
53 | |
53 | |
54 | static tl_map_t tl_map; |
54 | static tl_map_t tl_map; |
55 | |
55 | |
56 | //TODO: class method |
56 | //TODO: class method |
|
|
57 | static void free_treasurestruct (treasure *t); // bleh desu |
57 | static void |
58 | static void |
58 | clear (treasurelist *tl) |
59 | clear (treasurelist *tl) |
59 | { |
60 | { |
60 | void free_treasurestruct (treasure *t); |
|
|
61 | |
|
|
62 | if (tl->items) |
61 | if (tl->items) |
63 | { |
62 | { |
64 | free_treasurestruct (tl->items); |
63 | free_treasurestruct (tl->items); |
65 | tl->items = 0; |
64 | tl->items = 0; |
66 | } |
65 | } |
… | |
… | |
497 | * This code presumes that op has had its spell object created (in op->inv) |
496 | * This code presumes that op has had its spell object created (in op->inv) |
498 | * |
497 | * |
499 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
498 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
500 | * Removed multiplicator, too many high-level items were generated on low-difficulty maps. |
499 | * Removed multiplicator, too many high-level items were generated on low-difficulty maps. |
501 | */ |
500 | */ |
502 | int |
501 | static int |
503 | level_for_item (const object *op, int difficulty) |
502 | level_for_item (const object *op, int difficulty) |
504 | { |
503 | { |
505 | if (!op->inv) |
504 | if (!op->inv) |
506 | { |
505 | { |
507 | LOG (llevError, "level_for_item: Object %s has no inventory!\n", &op->name); |
506 | LOG (llevError, "level_for_item: Object %s has no inventory!\n", &op->name); |
… | |
… | |
524 | * elmex Thu Aug 10 18:45:44 CEST 2006: |
523 | * elmex Thu Aug 10 18:45:44 CEST 2006: |
525 | * Scaling difficulty by max_level, as difficulty is a level and not some |
524 | * Scaling difficulty by max_level, as difficulty is a level and not some |
526 | * weird integer between 1-31. |
525 | * weird integer between 1-31. |
527 | * |
526 | * |
528 | */ |
527 | */ |
529 | int |
528 | static int |
530 | magic_from_difficulty (int difficulty) |
529 | magic_from_difficulty (int difficulty) |
531 | { |
530 | { |
532 | int percent = 0, magic = 0; |
531 | int percent = 0, magic = 0; |
533 | int scaled_diff = (int) (((double) difficulty / settings.max_level) * DIFFLEVELS); |
532 | int scaled_diff = (int) (((double) difficulty / settings.max_level) * DIFFLEVELS); |
534 | |
533 | |
… | |
… | |
624 | * 1) Since rings can have multiple bonuses, if the same bonus |
623 | * 1) Since rings can have multiple bonuses, if the same bonus |
625 | * is rolled again, increase it - the bonuses now stack with |
624 | * is rolled again, increase it - the bonuses now stack with |
626 | * other bonuses previously rolled and ones the item might natively have. |
625 | * other bonuses previously rolled and ones the item might natively have. |
627 | * 2) Add code to deal with new PR method. |
626 | * 2) Add code to deal with new PR method. |
628 | */ |
627 | */ |
629 | void |
628 | static void |
630 | set_ring_bonus (object *op, int bonus) |
629 | set_ring_bonus (object *op, int bonus) |
631 | { |
630 | { |
632 | |
|
|
633 | int r = rndm (bonus > 0 ? 25 : 11); |
631 | int r = rndm (bonus > 0 ? 25 : 11); |
634 | |
632 | |
635 | if (op->type == AMULET) |
633 | if (op->type == AMULET) |
636 | { |
634 | { |
637 | if (!(rndm (21))) |
635 | if (!(rndm (21))) |
… | |
… | |
760 | * higher is the chance of returning a low number. |
758 | * higher is the chance of returning a low number. |
761 | * It is only used in fix_generated_treasure() to set bonuses on |
759 | * It is only used in fix_generated_treasure() to set bonuses on |
762 | * rings and amulets. |
760 | * rings and amulets. |
763 | * Another scheme is used to calculate the magic of weapons and armours. |
761 | * Another scheme is used to calculate the magic of weapons and armours. |
764 | */ |
762 | */ |
765 | int |
763 | static int |
766 | get_magic (int diff) |
764 | get_magic (int diff) |
767 | { |
765 | { |
768 | int i; |
766 | int i; |
769 | |
767 | |
770 | if (diff < 3) |
768 | if (diff < 3) |
… | |
… | |
776 | |
774 | |
777 | return 4; |
775 | return 4; |
778 | } |
776 | } |
779 | |
777 | |
780 | /* special_potion() - so that old potion code is still done right. */ |
778 | /* special_potion() - so that old potion code is still done right. */ |
781 | int |
779 | static int |
782 | special_potion (object *op) |
780 | special_potion (object *op) |
783 | { |
781 | { |
784 | if (op->attacktype) |
782 | if (op->attacktype) |
785 | return 1; |
783 | return 1; |
786 | |
784 | |
… | |
… | |
1660 | |
1658 | |
1661 | SET_FLAG (item, FLAG_NO_STEAL); |
1659 | SET_FLAG (item, FLAG_NO_STEAL); |
1662 | } |
1660 | } |
1663 | } |
1661 | } |
1664 | |
1662 | |
1665 | void |
1663 | static void |
1666 | free_treasurestruct (treasure *t) |
1664 | free_treasurestruct (treasure *t) |
1667 | { |
1665 | { |
1668 | if (t->next) free_treasurestruct (t->next); |
1666 | if (t->next) free_treasurestruct (t->next); |
1669 | if (t->next_yes) free_treasurestruct (t->next_yes); |
1667 | if (t->next_yes) free_treasurestruct (t->next_yes); |
1670 | if (t->next_no) free_treasurestruct (t->next_no); |
1668 | if (t->next_no) free_treasurestruct (t->next_no); |
1671 | |
1669 | |
1672 | delete t; |
1670 | delete t; |
1673 | } |
1671 | } |
1674 | |
1672 | |
1675 | void |
1673 | static void |
1676 | free_charlinks (linked_char *lc) |
1674 | free_charlinks (linked_char *lc) |
1677 | { |
1675 | { |
1678 | if (lc->next) |
1676 | if (lc->next) |
1679 | free_charlinks (lc->next); |
1677 | free_charlinks (lc->next); |
1680 | |
1678 | |
1681 | delete lc; |
1679 | delete lc; |
1682 | } |
1680 | } |
1683 | |
1681 | |
1684 | void |
1682 | static void |
1685 | free_artifact (artifact *at) |
1683 | free_artifact (artifact *at) |
1686 | { |
1684 | { |
1687 | if (at->next) free_artifact (at->next); |
1685 | if (at->next) free_artifact (at->next); |
1688 | if (at->allowed) free_charlinks (at->allowed); |
1686 | if (at->allowed) free_charlinks (at->allowed); |
1689 | |
1687 | |
1690 | at->item->destroy (); |
1688 | at->item->destroy (); |
1691 | |
1689 | |
1692 | sfree (at); |
1690 | sfree (at); |
1693 | } |
1691 | } |
1694 | |
1692 | |
1695 | void |
1693 | static void |
1696 | free_artifactlist (artifactlist *al) |
1694 | free_artifactlist (artifactlist *al) |
1697 | { |
1695 | { |
1698 | artifactlist *nextal; |
1696 | artifactlist *nextal; |
1699 | |
1697 | |
1700 | for (al = first_artifactlist; al; al = nextal) |
1698 | for (al = first_artifactlist; al; al = nextal) |
… | |
… | |
1706 | |
1704 | |
1707 | sfree (al); |
1705 | sfree (al); |
1708 | } |
1706 | } |
1709 | } |
1707 | } |
1710 | |
1708 | |
1711 | void |
1709 | static void |
1712 | free_all_treasures (void) |
1710 | free_all_treasures (void) |
1713 | { |
1711 | { |
1714 | treasurelist *tl, *next; |
1712 | treasurelist *tl, *next; |
1715 | |
1713 | |
1716 | for (tl = first_treasurelist; tl; tl = next) |
1714 | for (tl = first_treasurelist; tl; tl = next) |