ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/treasure.C
(Generate patch)

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.88 by root, Fri Nov 6 12:27:05 2009 UTC vs.
Revision 1.89 by root, Fri Nov 6 13:03:34 2009 UTC

52> tl_map_t; 52> tl_map_t;
53 53
54static tl_map_t tl_map; 54static tl_map_t tl_map;
55 55
56//TODO: class method 56//TODO: class method
57static void free_treasurestruct (treasure *t); // bleh desu
57static void 58static void
58clear (treasurelist *tl) 59clear (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 */
502int 501static int
503level_for_item (const object *op, int difficulty) 502level_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 */
529int 528static int
530magic_from_difficulty (int difficulty) 529magic_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 */
629void 628static void
630set_ring_bonus (object *op, int bonus) 629set_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 */
765int 763static int
766get_magic (int diff) 764get_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. */
781int 779static int
782special_potion (object *op) 780special_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
1665void 1663static void
1666free_treasurestruct (treasure *t) 1664free_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
1675void 1673static void
1676free_charlinks (linked_char *lc) 1674free_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
1684void 1682static void
1685free_artifact (artifact *at) 1683free_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
1695void 1693static void
1696free_artifactlist (artifactlist *al) 1694free_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
1711void 1709static void
1712free_all_treasures (void) 1710free_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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines