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.87 by sf-marcmagus, Thu Oct 15 16:00:37 2009 UTC vs.
Revision 1.88 by root, Fri Nov 6 12:27:05 2009 UTC

51 slice_allocator< std::pair<const char *const, treasurelist *> > 51 slice_allocator< std::pair<const char *const, treasurelist *> >
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
57static void
58clear (treasurelist *tl)
59{
60 void free_treasurestruct (treasure *t);
61
62 if (tl->items)
63 {
64 free_treasurestruct (tl->items);
65 tl->items = 0;
66 }
67
68 tl->total_chance = 0;
69}
70
56/* 71/*
57 * Searches for the given treasurelist 72 * Searches for the given treasurelist
58 */ 73 */
59treasurelist * 74treasurelist *
60treasurelist::find (const char *name) 75treasurelist::find (const char *name)
89 104
90 tl_map.insert (std::make_pair (tl->name, tl)); 105 tl_map.insert (std::make_pair (tl->name, tl));
91 } 106 }
92 107
93 return tl; 108 return tl;
94}
95
96//TODO: class method
97void
98clear (treasurelist *tl)
99{
100 if (tl->items)
101 {
102 free_treasurestruct (tl->items);
103 tl->items = 0;
104 }
105
106 tl->total_chance = 0;
107} 109}
108 110
109#ifdef TREASURE_DEBUG 111#ifdef TREASURE_DEBUG
110/* recursived checks the linked list. Treasurelist is passed only 112/* recursived checks the linked list. Treasurelist is passed only
111 * so that the treasure name can be printed out 113 * so that the treasure name can be printed out
773 return i; 775 return i;
774 776
775 return 4; 777 return 4;
776} 778}
777 779
780/* special_potion() - so that old potion code is still done right. */
781int
782special_potion (object *op)
783{
784 if (op->attacktype)
785 return 1;
786
787 if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha)
788 return 1;
789
790 for (int i = 0; i < NROFATTACKS; i++)
791 if (op->resist[i])
792 return 1;
793
794 return 0;
795}
796
778#define DICE2 (get_magic(2)==2?2:1) 797#define DICE2 (get_magic(2)==2?2:1)
779#define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3)) 798#define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3))
780 799
781/* 800/*
782 * fix_generated_item(): This is called after an item is generated, in 801 * fix_generated_item(): This is called after an item is generated, in
1641 1660
1642 SET_FLAG (item, FLAG_NO_STEAL); 1661 SET_FLAG (item, FLAG_NO_STEAL);
1643 } 1662 }
1644} 1663}
1645 1664
1646/* special_potion() - so that old potion code is still done right. */
1647int
1648special_potion (object *op)
1649{
1650 if (op->attacktype)
1651 return 1;
1652
1653 if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha)
1654 return 1;
1655
1656 for (int i = 0; i < NROFATTACKS; i++)
1657 if (op->resist[i])
1658 return 1;
1659
1660 return 0;
1661}
1662
1663void 1665void
1664free_treasurestruct (treasure *t) 1666free_treasurestruct (treasure *t)
1665{ 1667{
1666 if (t->next) free_treasurestruct (t->next); 1668 if (t->next) free_treasurestruct (t->next);
1667 if (t->next_yes) free_treasurestruct (t->next_yes); 1669 if (t->next_yes) free_treasurestruct (t->next_yes);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines