1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * under the terms of the GNU General Public License as published by the Free |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, but |
13 | * This program is distributed in the hope that it will be useful, |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* TREASURE_DEBUG does some checking on the treasurelists after loading. |
25 | /* TREASURE_DEBUG does some checking on the treasurelists after loading. |
26 | * It is useful for finding bugs in the treasures file. Since it only |
26 | * It is useful for finding bugs in the treasures file. Since it only |
27 | * slows the startup some (and not actual game play), it is by default |
27 | * slows the startup some (and not actual game play), it is by default |
… | |
… | |
33 | |
33 | |
34 | //#define TREASURE_VERBOSE |
34 | //#define TREASURE_VERBOSE |
35 | |
35 | |
36 | #include <global.h> |
36 | #include <global.h> |
37 | #include <treasure.h> |
37 | #include <treasure.h> |
38 | #include <funcpoint.h> |
|
|
39 | #include <loader.h> |
|
|
40 | |
38 | |
41 | extern char *spell_mapping[]; |
39 | extern char *spell_mapping[]; |
42 | |
40 | |
43 | static treasurelist *first_treasurelist; |
41 | static treasurelist *first_treasurelist; |
44 | |
42 | |
… | |
… | |
47 | typedef std::tr1::unordered_map< |
45 | typedef std::tr1::unordered_map< |
48 | const char *, |
46 | const char *, |
49 | treasurelist *, |
47 | treasurelist *, |
50 | str_hash, |
48 | str_hash, |
51 | str_equal, |
49 | str_equal, |
52 | slice_allocator< std::pair<const char *const, treasurelist *> >, |
50 | slice_allocator< std::pair<const char *const, treasurelist *> > |
53 | true |
|
|
54 | > tl_map_t; |
51 | > tl_map_t; |
55 | |
52 | |
56 | static tl_map_t tl_map; |
53 | static tl_map_t tl_map; |
|
|
54 | |
|
|
55 | //TODO: class method |
|
|
56 | static void free_treasurestruct (treasure *t); // bleh desu |
|
|
57 | static void |
|
|
58 | clear (treasurelist *tl) |
|
|
59 | { |
|
|
60 | if (tl->items) |
|
|
61 | { |
|
|
62 | free_treasurestruct (tl->items); |
|
|
63 | tl->items = 0; |
|
|
64 | } |
|
|
65 | |
|
|
66 | tl->total_chance = 0; |
|
|
67 | } |
57 | |
68 | |
58 | /* |
69 | /* |
59 | * Searches for the given treasurelist |
70 | * Searches for the given treasurelist |
60 | */ |
71 | */ |
61 | treasurelist * |
72 | treasurelist * |
… | |
… | |
93 | } |
104 | } |
94 | |
105 | |
95 | return tl; |
106 | return tl; |
96 | } |
107 | } |
97 | |
108 | |
98 | //TODO: class method |
|
|
99 | void |
|
|
100 | clear (treasurelist *tl) |
|
|
101 | { |
|
|
102 | if (tl->items) |
|
|
103 | { |
|
|
104 | free_treasurestruct (tl->items); |
|
|
105 | tl->items = 0; |
|
|
106 | } |
|
|
107 | |
|
|
108 | tl->total_chance = 0; |
|
|
109 | } |
|
|
110 | |
|
|
111 | #ifdef TREASURE_DEBUG |
109 | #ifdef TREASURE_DEBUG |
112 | /* recursived checks the linked list. Treasurelist is passed only |
110 | /* recursived checks the linked list. Treasurelist is passed only |
113 | * so that the treasure name can be printed out |
111 | * so that the treasure name can be printed out |
114 | */ |
112 | */ |
115 | static void |
113 | static void |
… | |
… | |
140 | |
138 | |
141 | f.next (); |
139 | f.next (); |
142 | |
140 | |
143 | for (;;) |
141 | for (;;) |
144 | { |
142 | { |
145 | coroapi::cede_to_tick_every (10); |
143 | coroapi::cede_to_tick (); |
146 | |
144 | |
147 | switch (f.kw) |
145 | switch (f.kw) |
148 | { |
146 | { |
149 | case KW_arch: |
147 | case KW_arch: |
150 | t->item = archetype::get (f.get_str ()); |
148 | t->item = archetype::find (f.get_str ()); |
|
|
149 | |
|
|
150 | if (!t->item) |
|
|
151 | { |
|
|
152 | f.parse_warn ("treasure references unknown archetype"); |
|
|
153 | t->item = archetype::empty; |
|
|
154 | } |
|
|
155 | |
151 | break; |
156 | break; |
152 | |
157 | |
153 | case KW_list: f.get (t->name); break; |
158 | case KW_list: f.get (t->name); break; |
154 | case KW_change_name: f.get (t->change_arch.name); break; |
159 | case KW_change_name: f.get (t->change_arch.name); break; |
155 | case KW_change_title: f.get (t->change_arch.title); break; |
160 | case KW_change_title: f.get (t->change_arch.title); break; |
… | |
… | |
169 | t->next = read_treasure (f); |
174 | t->next = read_treasure (f); |
170 | return t; |
175 | return t; |
171 | |
176 | |
172 | default: |
177 | default: |
173 | if (!f.parse_error ("treasurelist", t->name)) |
178 | if (!f.parse_error ("treasurelist", t->name)) |
174 | return 0; |
179 | goto error; |
175 | |
180 | |
176 | return t; |
181 | return t; |
177 | } |
182 | } |
178 | |
183 | |
179 | f.next (); |
184 | f.next (); |
180 | } |
185 | } |
|
|
186 | |
|
|
187 | // not reached |
|
|
188 | |
|
|
189 | error: |
|
|
190 | delete t; |
|
|
191 | return 0; |
181 | } |
192 | } |
182 | |
193 | |
183 | /* |
194 | /* |
184 | * Each treasure is parsed with the help of load_treasure(). |
195 | * Each treasure is parsed with the help of load_treasure(). |
185 | */ |
196 | */ |
… | |
… | |
244 | return; |
255 | return; |
245 | } |
256 | } |
246 | |
257 | |
247 | op->expand_tail (); |
258 | op->expand_tail (); |
248 | |
259 | |
249 | if (ob_blocked (op, creator->map, creator->x, creator->y)) |
260 | if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y)) |
250 | op->destroy (); |
261 | op->destroy (); |
251 | else |
262 | else |
252 | { |
263 | { |
253 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
264 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
254 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
265 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
… | |
… | |
258 | { |
269 | { |
259 | op = creator->insert (op); |
270 | op = creator->insert (op); |
260 | |
271 | |
261 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
272 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
262 | monster_check_apply (creator, op); |
273 | monster_check_apply (creator, op); |
263 | |
|
|
264 | if (flags & GT_UPDATE_INV) |
|
|
265 | if (object *tmp = creator->in_player ()) |
|
|
266 | esrv_send_item (tmp, op); |
|
|
267 | } |
274 | } |
268 | } |
275 | } |
269 | |
276 | |
270 | /* if there are change_xxx commands in the treasure, we include the changes |
277 | /* if there are change_xxx commands in the treasure, we include the changes |
271 | * in the generated object |
278 | * in the generated object |
… | |
… | |
302 | } |
309 | } |
303 | else |
310 | else |
304 | { |
311 | { |
305 | if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) |
312 | if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) |
306 | { |
313 | { |
307 | object *tmp = arch_to_object (t->item); |
314 | object *tmp = t->item->instance (); |
308 | |
315 | |
309 | if (t->nrof && tmp->nrof <= 1) |
316 | if (t->nrof && tmp->nrof <= 1) |
310 | tmp->nrof = rndm (t->nrof) + 1; |
317 | tmp->nrof = rndm (t->nrof) + 1; |
311 | |
318 | |
312 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
319 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
… | |
… | |
359 | else if (t->nrof) |
366 | else if (t->nrof) |
360 | create_one_treasure (tl, op, flag, difficulty, tries); |
367 | create_one_treasure (tl, op, flag, difficulty, tries); |
361 | } |
368 | } |
362 | else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) |
369 | else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) |
363 | { |
370 | { |
364 | if (object *tmp = arch_to_object (t->item)) |
371 | if (object *tmp = t->item->instance ()) |
365 | { |
372 | { |
366 | if (t->nrof && tmp->nrof <= 1) |
373 | if (t->nrof && tmp->nrof <= 1) |
367 | tmp->nrof = rndm (t->nrof) + 1; |
374 | tmp->nrof = rndm (t->nrof) + 1; |
368 | |
375 | |
369 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
376 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
… | |
… | |
435 | |
442 | |
436 | if (ob->inv) |
443 | if (ob->inv) |
437 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
444 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
438 | |
445 | |
439 | ob->destroy (); |
446 | ob->destroy (); |
|
|
447 | |
440 | return tmp; |
448 | return tmp; |
441 | } |
449 | } |
442 | |
450 | |
443 | /* |
451 | /* |
444 | * This is a new way of calculating the chance for an item to have |
452 | * This is a new way of calculating the chance for an item to have |
… | |
… | |
487 | * This code presumes that op has had its spell object created (in op->inv) |
495 | * This code presumes that op has had its spell object created (in op->inv) |
488 | * |
496 | * |
489 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
497 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
490 | * Removed multiplicator, too many high-level items were generated on low-difficulty maps. |
498 | * Removed multiplicator, too many high-level items were generated on low-difficulty maps. |
491 | */ |
499 | */ |
492 | int |
500 | static int |
493 | level_for_item (const object *op, int difficulty) |
501 | level_for_item (const object *op, int difficulty) |
494 | { |
502 | { |
495 | int olevel = 0; |
|
|
496 | |
|
|
497 | if (!op->inv) |
503 | if (!op->inv) |
498 | { |
504 | { |
499 | LOG (llevError, "level_for_item: Object %s has no inventory!\n", &op->name); |
505 | LOG (llevError, "level_for_item: Object %s has no inventory!\n", &op->name); |
500 | return 0; |
506 | return 0; |
501 | } |
507 | } |
502 | |
508 | |
503 | olevel = (int) (op->inv->level + (double) difficulty * (1 - drand48 () * drand48 () * 2)); |
509 | int olevel = op->inv->level + int (difficulty * (1. - rndm () * rndm () * 2.)); |
504 | |
510 | |
505 | if (olevel <= 0) |
511 | if (olevel <= 0) |
506 | olevel = rndm (1, MIN (op->inv->level, 1)); |
512 | olevel = rndm (1, op->inv->level); |
507 | |
513 | |
508 | if (olevel > MAXLEVEL) |
514 | return min (olevel, MAXLEVEL); |
509 | olevel = MAXLEVEL; |
|
|
510 | |
|
|
511 | return olevel; |
|
|
512 | } |
515 | } |
513 | |
516 | |
514 | /* |
517 | /* |
515 | * Based upon the specified difficulty and upon the difftomagic_list array, |
518 | * Based upon the specified difficulty and upon the difftomagic_list array, |
516 | * a random magical bonus is returned. This is used when determine |
519 | * a random magical bonus is returned. This is used when determine |
… | |
… | |
519 | * elmex Thu Aug 10 18:45:44 CEST 2006: |
522 | * elmex Thu Aug 10 18:45:44 CEST 2006: |
520 | * Scaling difficulty by max_level, as difficulty is a level and not some |
523 | * Scaling difficulty by max_level, as difficulty is a level and not some |
521 | * weird integer between 1-31. |
524 | * weird integer between 1-31. |
522 | * |
525 | * |
523 | */ |
526 | */ |
524 | int |
527 | static int |
525 | magic_from_difficulty (int difficulty) |
528 | magic_from_difficulty (int difficulty) |
526 | { |
529 | { |
527 | int percent = 0, magic = 0; |
530 | int percent = 0, magic = 0; |
528 | int scaled_diff = (int) (((double) difficulty / settings.max_level) * DIFFLEVELS); |
531 | int scaled_diff = (int) (((double) difficulty / settings.max_level) * DIFFLEVELS); |
529 | |
532 | |
… | |
… | |
576 | if (op->type == ARMOUR) |
579 | if (op->type == ARMOUR) |
577 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; |
580 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; |
578 | |
581 | |
579 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
582 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
580 | magic = (-magic); |
583 | magic = (-magic); |
|
|
584 | |
581 | op->weight = (op->arch->weight * (100 - magic * 10)) / 100; |
585 | op->weight = (op->arch->weight * (100 - magic * 10)) / 100; |
582 | } |
586 | } |
583 | else |
587 | else |
584 | { |
588 | { |
585 | if (op->type == ARMOUR) |
589 | if (op->type == ARMOUR) |
586 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; |
590 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; |
|
|
591 | |
587 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
592 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
588 | magic = (-magic); |
593 | magic = (-magic); |
|
|
594 | |
589 | op->weight = (op->weight * (100 - magic * 10)) / 100; |
595 | op->weight = (op->weight * (100 - magic * 10)) / 100; |
590 | } |
596 | } |
591 | } |
597 | } |
592 | |
598 | |
593 | /* |
599 | /* |
… | |
… | |
616 | * 1) Since rings can have multiple bonuses, if the same bonus |
622 | * 1) Since rings can have multiple bonuses, if the same bonus |
617 | * is rolled again, increase it - the bonuses now stack with |
623 | * is rolled again, increase it - the bonuses now stack with |
618 | * other bonuses previously rolled and ones the item might natively have. |
624 | * other bonuses previously rolled and ones the item might natively have. |
619 | * 2) Add code to deal with new PR method. |
625 | * 2) Add code to deal with new PR method. |
620 | */ |
626 | */ |
621 | void |
627 | static void |
622 | set_ring_bonus (object *op, int bonus) |
628 | set_ring_bonus (object *op, int bonus) |
623 | { |
629 | { |
624 | |
|
|
625 | int r = rndm (bonus > 0 ? 25 : 11); |
630 | int r = rndm (bonus > 0 ? 25 : 11); |
626 | |
631 | |
627 | if (op->type == AMULET) |
632 | if (op->type == AMULET) |
628 | { |
633 | { |
629 | if (!(rndm (21))) |
634 | if (!(rndm (21))) |
… | |
… | |
752 | * higher is the chance of returning a low number. |
757 | * higher is the chance of returning a low number. |
753 | * It is only used in fix_generated_treasure() to set bonuses on |
758 | * It is only used in fix_generated_treasure() to set bonuses on |
754 | * rings and amulets. |
759 | * rings and amulets. |
755 | * Another scheme is used to calculate the magic of weapons and armours. |
760 | * Another scheme is used to calculate the magic of weapons and armours. |
756 | */ |
761 | */ |
757 | int |
762 | static int |
758 | get_magic (int diff) |
763 | get_magic (int diff) |
759 | { |
764 | { |
760 | int i; |
765 | int i; |
761 | |
766 | |
762 | if (diff < 3) |
767 | if (diff < 3) |
… | |
… | |
765 | for (i = 0; i < 4; i++) |
770 | for (i = 0; i < 4; i++) |
766 | if (rndm (diff)) |
771 | if (rndm (diff)) |
767 | return i; |
772 | return i; |
768 | |
773 | |
769 | return 4; |
774 | return 4; |
|
|
775 | } |
|
|
776 | |
|
|
777 | /* special_potion() - so that old potion code is still done right. */ |
|
|
778 | static int |
|
|
779 | special_potion (object *op) |
|
|
780 | { |
|
|
781 | if (op->attacktype) |
|
|
782 | return 1; |
|
|
783 | |
|
|
784 | if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha) |
|
|
785 | return 1; |
|
|
786 | |
|
|
787 | for (int i = 0; i < NROFATTACKS; i++) |
|
|
788 | if (op->resist[i]) |
|
|
789 | return 1; |
|
|
790 | |
|
|
791 | return 0; |
770 | } |
792 | } |
771 | |
793 | |
772 | #define DICE2 (get_magic(2)==2?2:1) |
794 | #define DICE2 (get_magic(2)==2?2:1) |
773 | #define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3)) |
795 | #define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3)) |
774 | |
796 | |
… | |
… | |
811 | create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0); |
833 | create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0); |
812 | /* So the treasure doesn't get created again */ |
834 | /* So the treasure doesn't get created again */ |
813 | op->randomitems = 0; |
835 | op->randomitems = 0; |
814 | } |
836 | } |
815 | |
837 | |
816 | if (difficulty < 1) |
838 | max_it (difficulty, 1); |
817 | difficulty = 1; |
|
|
818 | |
839 | |
819 | if (INVOKE_OBJECT (ADD_BONUS, op, |
840 | if (INVOKE_OBJECT (ADD_BONUS, op, |
820 | ARG_OBJECT (creator != op ? creator : 0), |
841 | ARG_OBJECT (creator != op ? creator : 0), |
821 | ARG_INT (difficulty), ARG_INT (max_magic), |
842 | ARG_INT (difficulty), ARG_INT (max_magic), |
822 | ARG_INT (flags))) |
843 | ARG_INT (flags))) |
823 | return; |
844 | return; |
824 | |
845 | |
825 | if (!(flags & GT_MINIMAL)) |
846 | if (!(flags & GT_MINIMAL)) |
826 | { |
847 | { |
827 | if (op->arch == crown_arch) |
848 | if (IS_ARCH (op->arch, crown)) |
828 | { |
849 | { |
829 | set_magic (difficulty, op, max_magic, flags); |
850 | set_magic (difficulty, op, max_magic, flags); |
830 | num_enchantments = calc_item_power (op, 1); |
851 | num_enchantments = calc_item_power (op, 1); |
831 | generate_artifact (op, difficulty); |
852 | generate_artifact (op, difficulty); |
832 | } |
853 | } |
… | |
… | |
837 | |
858 | |
838 | num_enchantments = calc_item_power (op, 1); |
859 | num_enchantments = calc_item_power (op, 1); |
839 | |
860 | |
840 | if ((!was_magic && !rndm (CHANCE_FOR_ARTIFACT)) |
861 | if ((!was_magic && !rndm (CHANCE_FOR_ARTIFACT)) |
841 | || op->type == HORN |
862 | || op->type == HORN |
842 | || difficulty >= settings.max_level) /* high difficulties always generate an artifact, |
863 | || difficulty >= settings.max_level) /* high difficulties always generate an artifact, used for shop_floors or treasures */ |
843 | * used for shop_floors or treasures */ |
|
|
844 | generate_artifact (op, difficulty); |
864 | generate_artifact (op, difficulty); |
845 | } |
865 | } |
846 | |
866 | |
847 | /* Object was made an artifact. Calculate its item_power rating. |
867 | /* Object was made an artifact. Calculate its item_power rating. |
848 | * the item_power in the object is what the artfiact adds. |
868 | * the item_power in the object is what the artfiact adds. |
… | |
… | |
882 | * again below */ |
902 | * again below */ |
883 | } |
903 | } |
884 | } |
904 | } |
885 | |
905 | |
886 | /* materialtype modifications. Note we allow this on artifacts. */ |
906 | /* materialtype modifications. Note we allow this on artifacts. */ |
887 | set_materialname (op, difficulty, NULL); |
907 | select_material (op, difficulty); |
888 | |
908 | |
889 | if (flags & GT_MINIMAL) |
909 | if (flags & GT_MINIMAL) |
890 | { |
910 | { |
891 | if (op->type == POTION) |
911 | if (op->type == POTION) |
892 | /* Handle healing and magic power potions */ |
912 | /* Handle healing and magic power potions */ |
893 | if (op->stats.sp && !op->randomitems) |
913 | if (op->stats.sp && !op->randomitems) |
894 | { |
914 | { |
895 | object *tmp; |
|
|
896 | |
|
|
897 | tmp = get_archetype (spell_mapping[op->stats.sp]); |
915 | object *tmp = get_archetype (spell_mapping [op->stats.sp]); |
898 | insert_ob_in_ob (tmp, op); |
916 | insert_ob_in_ob (tmp, op); |
899 | op->stats.sp = 0; |
917 | op->stats.sp = 0; |
900 | } |
918 | } |
901 | } |
919 | } |
902 | else if (!op->title) /* Only modify object if not special */ |
920 | else if (!op->title) /* Only modify object if not special */ |
… | |
… | |
925 | int too_many_tries = 0, is_special = 0; |
943 | int too_many_tries = 0, is_special = 0; |
926 | |
944 | |
927 | /* Handle healing and magic power potions */ |
945 | /* Handle healing and magic power potions */ |
928 | if (op->stats.sp && !op->randomitems) |
946 | if (op->stats.sp && !op->randomitems) |
929 | { |
947 | { |
930 | object *tmp; |
|
|
931 | |
|
|
932 | tmp = get_archetype (spell_mapping[op->stats.sp]); |
948 | object *tmp = get_archetype (spell_mapping[op->stats.sp]); |
933 | insert_ob_in_ob (tmp, op); |
949 | insert_ob_in_ob (tmp, op); |
934 | op->stats.sp = 0; |
950 | op->stats.sp = 0; |
935 | } |
951 | } |
936 | |
952 | |
937 | while (!(is_special = special_potion (op)) && !op->inv) |
953 | while (!(is_special = special_potion (op)) && !op->inv) |
… | |
… | |
945 | * since the value set on those is already correct. |
961 | * since the value set on those is already correct. |
946 | */ |
962 | */ |
947 | if (op->inv && op->randomitems) |
963 | if (op->inv && op->randomitems) |
948 | { |
964 | { |
949 | /* value multiplier is same as for scrolls */ |
965 | /* value multiplier is same as for scrolls */ |
950 | op->value = (op->value * op->inv->value); |
966 | op->value *= op->inv->value; |
951 | op->level = op->inv->level / 2 + rndm (difficulty) + rndm (difficulty); |
967 | op->level = op->inv->level / 2 + rndm (difficulty) + rndm (difficulty); |
952 | } |
968 | } |
953 | else |
969 | else |
954 | { |
970 | { |
955 | op->name = "potion"; |
971 | op->name = "potion"; |
956 | op->name_pl = "potions"; |
972 | op->name_pl = "potions"; |
957 | } |
973 | } |
958 | |
974 | |
959 | if (!(flags & GT_ONLY_GOOD) && rndm (2)) |
975 | if (!(flags & GT_ONLY_GOOD) && rndm (2)) |
960 | SET_FLAG (op, FLAG_CURSED); |
976 | SET_FLAG (op, FLAG_CURSED); |
|
|
977 | |
961 | break; |
978 | break; |
962 | } |
979 | } |
963 | |
980 | |
964 | case AMULET: |
981 | case AMULET: |
965 | if (op->arch == amulet_arch) |
982 | if (IS_ARCH (op->arch, amulet)) |
966 | op->value *= 5; /* Since it's not just decoration */ |
983 | op->value *= 5; /* Since it's not just decoration */ |
967 | |
984 | |
968 | case RING: |
985 | case RING: |
969 | if (op->arch == NULL) |
|
|
970 | { |
|
|
971 | op->destroy (); |
|
|
972 | op = 0; |
|
|
973 | break; |
|
|
974 | } |
|
|
975 | |
|
|
976 | if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ |
986 | if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ |
977 | break; |
987 | break; |
978 | |
988 | |
979 | if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) |
989 | if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) |
980 | SET_FLAG (op, FLAG_CURSED); |
990 | SET_FLAG (op, FLAG_CURSED); |
981 | |
991 | |
… | |
… | |
1001 | op->value *= 5; |
1011 | op->value *= 5; |
1002 | set_ring_bonus (op, d); |
1012 | set_ring_bonus (op, d); |
1003 | } |
1013 | } |
1004 | } |
1014 | } |
1005 | |
1015 | |
1006 | if (GET_ANIM_ID (op)) |
1016 | if (op->animation_id) |
1007 | SET_ANIMATION (op, rndm (NUM_ANIMATIONS (op))); |
1017 | op->set_anim_frame (rndm (op->anim_frames ())); |
1008 | |
1018 | |
1009 | break; |
1019 | break; |
1010 | |
1020 | |
1011 | case BOOK: |
1021 | case BOOK: |
1012 | /* Is it an empty book?, if yes lets make a special· |
1022 | /* Is it an empty book?, if yes lets make a special· |
… | |
… | |
1027 | op->level = rndm (creator->level); |
1037 | op->level = rndm (creator->level); |
1028 | |
1038 | |
1029 | tailor_readable_ob (op, (creator && creator->stats.sp) ? creator->stats.sp : -1); |
1039 | tailor_readable_ob (op, (creator && creator->stats.sp) ? creator->stats.sp : -1); |
1030 | /* books w/ info are worth more! */ |
1040 | /* books w/ info are worth more! */ |
1031 | op->value *= ((op->level > 10 ? op->level : (op->level + 1) / 2) * ((strlen (op->msg) / 250) + 1)); |
1041 | op->value *= ((op->level > 10 ? op->level : (op->level + 1) / 2) * ((strlen (op->msg) / 250) + 1)); |
1032 | /* creator related stuff */ |
|
|
1033 | |
|
|
1034 | /* for library, chained books. Note that some monsters have no_pick |
|
|
1035 | * set - we don't want to set no pick in that case. |
|
|
1036 | */ |
|
|
1037 | if (QUERY_FLAG (creator, FLAG_NO_PICK) && !QUERY_FLAG (creator, FLAG_MONSTER)) |
|
|
1038 | SET_FLAG (op, FLAG_NO_PICK); |
|
|
1039 | if (creator->slaying && !op->slaying) /* for check_inv floors */ |
|
|
1040 | op->slaying = creator->slaying; |
|
|
1041 | |
1042 | |
1042 | /* add exp so reading it gives xp (once) */ |
1043 | /* add exp so reading it gives xp (once) */ |
1043 | op->stats.exp = op->value > 10000 ? op->value / 5 : op->value / 10; |
1044 | op->stats.exp = op->value > 10000 ? op->value / 5 : op->value / 10; |
1044 | } |
1045 | } |
|
|
1046 | |
|
|
1047 | /* creator related stuff */ |
|
|
1048 | |
|
|
1049 | /* for library, chained books. Note that some monsters have no_pick |
|
|
1050 | * set - we don't want to set no pick in that case. |
|
|
1051 | */ |
|
|
1052 | if (QUERY_FLAG (creator, FLAG_NO_PICK) && !QUERY_FLAG (creator, FLAG_MONSTER)) |
|
|
1053 | SET_FLAG (op, FLAG_NO_PICK); |
|
|
1054 | if (creator->slaying && !op->slaying) /* for check_inv floors */ |
|
|
1055 | op->slaying = creator->slaying; |
1045 | break; |
1056 | break; |
1046 | |
1057 | |
1047 | case SPELLBOOK: |
1058 | case SPELLBOOK: |
1048 | op->value = op->value * op->inv->value; |
1059 | op->value = op->value * op->inv->value; |
1049 | /* add exp so learning gives xp */ |
1060 | /* add exp so learning gives xp */ |
… | |
… | |
1083 | * 10 time multiplier). This way, the value are a bit more reasonable. |
1094 | * 10 time multiplier). This way, the value are a bit more reasonable. |
1084 | */ |
1095 | */ |
1085 | op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); |
1096 | op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); |
1086 | /* maxhp is used to denote how many 'charges' the rod holds before */ |
1097 | /* maxhp is used to denote how many 'charges' the rod holds before */ |
1087 | if (op->stats.maxhp) |
1098 | if (op->stats.maxhp) |
1088 | op->stats.maxhp *= MAX (op->inv->stats.sp, op->inv->stats.grace); |
1099 | op->stats.maxhp *= max (op->inv->stats.sp, op->inv->stats.grace); |
1089 | else |
1100 | else |
1090 | op->stats.maxhp = 2 * MAX (op->inv->stats.sp, op->inv->stats.grace); |
1101 | op->stats.maxhp = 2 * max (op->inv->stats.sp, op->inv->stats.grace); |
1091 | |
1102 | |
1092 | op->stats.hp = op->stats.maxhp; |
1103 | op->stats.hp = op->stats.maxhp; |
1093 | break; |
1104 | break; |
1094 | |
1105 | |
1095 | case SCROLL: |
1106 | case SCROLL: |
… | |
… | |
1132 | |
1143 | |
1133 | /* |
1144 | /* |
1134 | * Allocate and return the pointer to an empty artifactlist structure. |
1145 | * Allocate and return the pointer to an empty artifactlist structure. |
1135 | */ |
1146 | */ |
1136 | static artifactlist * |
1147 | static artifactlist * |
1137 | get_empty_artifactlist (void) |
1148 | get_empty_artifactlist () |
1138 | { |
1149 | { |
1139 | return salloc0 <artifactlist> (); |
1150 | return salloc0<artifactlist> (); |
1140 | } |
1151 | } |
1141 | |
1152 | |
1142 | /* |
1153 | /* |
1143 | * Allocate and return the pointer to an empty artifact structure. |
1154 | * Allocate and return the pointer to an empty artifact structure. |
1144 | */ |
1155 | */ |
1145 | static artifact * |
1156 | static artifact * |
1146 | get_empty_artifact (void) |
1157 | get_empty_artifact () |
1147 | { |
1158 | { |
1148 | return salloc0 <artifact> (); |
1159 | return salloc0<artifact> (); |
1149 | } |
1160 | } |
1150 | |
1161 | |
1151 | /* |
1162 | /* |
1152 | * Searches the artifact lists and returns one that has the same type |
1163 | * Searches the artifact lists and returns one that has the same type |
1153 | * of objects on it. |
1164 | * of objects on it. |
… | |
… | |
1161 | |
1172 | |
1162 | return 0; |
1173 | return 0; |
1163 | } |
1174 | } |
1164 | |
1175 | |
1165 | /* |
1176 | /* |
1166 | * For debugging purposes. Dumps all tables. |
1177 | * Builds up the lists of artifacts from the file in the libdir. |
1167 | */ |
1178 | */ |
1168 | void |
1179 | void |
1169 | dump_artifacts (void) |
|
|
1170 | { |
|
|
1171 | artifactlist *al; |
|
|
1172 | artifact *art; |
|
|
1173 | linked_char *next; |
|
|
1174 | |
|
|
1175 | fprintf (logfile, "\n"); |
|
|
1176 | for (al = first_artifactlist; al != NULL; al = al->next) |
|
|
1177 | { |
|
|
1178 | fprintf (logfile, "Artifact has type %d, total_chance=%d\n", al->type, al->total_chance); |
|
|
1179 | for (art = al->items; art != NULL; art = art->next) |
|
|
1180 | { |
|
|
1181 | fprintf (logfile, "Artifact %-30s Difficulty %3d Chance %5d\n", &art->item->name, art->difficulty, art->chance); |
|
|
1182 | if (art->allowed != NULL) |
|
|
1183 | { |
|
|
1184 | fprintf (logfile, "\tallowed combinations:"); |
|
|
1185 | for (next = art->allowed; next != NULL; next = next->next) |
|
|
1186 | fprintf (logfile, "%s,", &next->name); |
|
|
1187 | fprintf (logfile, "\n"); |
|
|
1188 | } |
|
|
1189 | } |
|
|
1190 | } |
|
|
1191 | fprintf (logfile, "\n"); |
|
|
1192 | } |
|
|
1193 | |
|
|
1194 | /* |
|
|
1195 | * For debugging purposes. Dumps all treasures recursively (see below). |
|
|
1196 | */ |
|
|
1197 | void |
|
|
1198 | dump_monster_treasure_rec (const char *name, treasure *t, int depth) |
|
|
1199 | { |
|
|
1200 | treasurelist *tl; |
|
|
1201 | int i; |
|
|
1202 | |
|
|
1203 | if (depth > 100) |
|
|
1204 | return; |
|
|
1205 | |
|
|
1206 | while (t) |
|
|
1207 | { |
|
|
1208 | if (t->name) |
|
|
1209 | { |
|
|
1210 | for (i = 0; i < depth; i++) |
|
|
1211 | fprintf (logfile, " "); |
|
|
1212 | |
|
|
1213 | fprintf (logfile, "{ (list: %s)\n", &t->name); |
|
|
1214 | |
|
|
1215 | tl = treasurelist::find (t->name); |
|
|
1216 | if (tl) |
|
|
1217 | dump_monster_treasure_rec (name, tl->items, depth + 2); |
|
|
1218 | |
|
|
1219 | for (i = 0; i < depth; i++) |
|
|
1220 | fprintf (logfile, " "); |
|
|
1221 | |
|
|
1222 | fprintf (logfile, "} (end of list: %s)\n", &t->name); |
|
|
1223 | } |
|
|
1224 | else |
|
|
1225 | { |
|
|
1226 | for (i = 0; i < depth; i++) |
|
|
1227 | fprintf (logfile, " "); |
|
|
1228 | |
|
|
1229 | if (t->item && t->item->type == FLESH) |
|
|
1230 | fprintf (logfile, "%s's %s\n", name, &t->item->object::name); |
|
|
1231 | else |
|
|
1232 | fprintf (logfile, "%s\n", &t->item->object::name); |
|
|
1233 | } |
|
|
1234 | |
|
|
1235 | if (t->next_yes) |
|
|
1236 | { |
|
|
1237 | for (i = 0; i < depth; i++) |
|
|
1238 | fprintf (logfile, " "); |
|
|
1239 | |
|
|
1240 | fprintf (logfile, " (if yes)\n"); |
|
|
1241 | dump_monster_treasure_rec (name, t->next_yes, depth + 1); |
|
|
1242 | } |
|
|
1243 | |
|
|
1244 | if (t->next_no) |
|
|
1245 | { |
|
|
1246 | for (i = 0; i < depth; i++) |
|
|
1247 | fprintf (logfile, " "); |
|
|
1248 | |
|
|
1249 | fprintf (logfile, " (if no)\n"); |
|
|
1250 | dump_monster_treasure_rec (name, t->next_no, depth + 1); |
|
|
1251 | } |
|
|
1252 | |
|
|
1253 | t = t->next; |
|
|
1254 | } |
|
|
1255 | } |
|
|
1256 | |
|
|
1257 | /* |
|
|
1258 | * For debugging purposes. Dumps all treasures for a given monster. |
|
|
1259 | * Created originally by Raphael Quinet for debugging the alchemy code. |
|
|
1260 | */ |
|
|
1261 | void |
|
|
1262 | dump_monster_treasure (const char *name) |
|
|
1263 | { |
|
|
1264 | archetype *at; |
|
|
1265 | int found; |
|
|
1266 | |
|
|
1267 | found = 0; |
|
|
1268 | fprintf (logfile, "\n"); |
|
|
1269 | |
|
|
1270 | for_all_archetypes (at) |
|
|
1271 | if (!strcasecmp (at->object::name, name) && at->title == NULL) |
|
|
1272 | { |
|
|
1273 | fprintf (logfile, "treasures for %s (arch: %s)\n", &at->object::name, &at->archname); |
|
|
1274 | if (at->randomitems != NULL) |
|
|
1275 | dump_monster_treasure_rec (at->object::name, at->randomitems->items, 1); |
|
|
1276 | else |
|
|
1277 | fprintf (logfile, "(nothing)\n"); |
|
|
1278 | |
|
|
1279 | fprintf (logfile, "\n"); |
|
|
1280 | found++; |
|
|
1281 | } |
|
|
1282 | |
|
|
1283 | if (found == 0) |
|
|
1284 | fprintf (logfile, "No objects have the name %s!\n\n", name); |
|
|
1285 | } |
|
|
1286 | |
|
|
1287 | /* |
|
|
1288 | * Builds up the lists of artifacts from the file in the libdir. |
|
|
1289 | */ |
|
|
1290 | void |
|
|
1291 | init_artifacts (void) |
1180 | init_artifacts () |
1292 | { |
1181 | { |
1293 | static int has_been_inited = 0; |
1182 | static int has_been_inited = 0; |
1294 | char filename[MAX_BUF]; |
1183 | char filename[MAX_BUF]; |
1295 | artifact *art = NULL; |
1184 | artifact *art = NULL; |
1296 | artifactlist *al; |
1185 | artifactlist *al; |
… | |
… | |
1304 | object_thawer f (filename); |
1193 | object_thawer f (filename); |
1305 | |
1194 | |
1306 | if (!f) |
1195 | if (!f) |
1307 | return; |
1196 | return; |
1308 | |
1197 | |
1309 | f.next (); |
|
|
1310 | |
|
|
1311 | for (;;) |
1198 | for (;;) |
1312 | { |
1199 | { |
1313 | switch (f.kw) |
1200 | switch (f.kw) |
1314 | { |
1201 | { |
1315 | case KW_allowed: |
1202 | case KW_allowed: |
… | |
… | |
1318 | |
1205 | |
1319 | { |
1206 | { |
1320 | if (!strcmp (f.get_str (), "all")) |
1207 | if (!strcmp (f.get_str (), "all")) |
1321 | break; |
1208 | break; |
1322 | |
1209 | |
1323 | char *next, *cp = f.get_str (); |
1210 | const char *cp = f.get_str (); |
1324 | |
1211 | char *next; |
1325 | do |
1212 | do |
1326 | { |
1213 | { |
1327 | if ((next = strchr (cp, ','))) |
1214 | if ((next = (char *)strchr (cp, ','))) |
1328 | *next++ = '\0'; |
1215 | *next++ = '\0'; |
1329 | |
1216 | |
1330 | linked_char *tmp = new linked_char; |
1217 | linked_char *tmp = new linked_char; |
1331 | |
1218 | |
1332 | tmp->name = cp; |
1219 | tmp->name = cp; |
… | |
… | |
1476 | * to cast. So convert that to into a spell and put it into |
1363 | * to cast. So convert that to into a spell and put it into |
1477 | * this object. |
1364 | * this object. |
1478 | */ |
1365 | */ |
1479 | if (op->type == HORN || op->type == POTION) |
1366 | if (op->type == HORN || op->type == POTION) |
1480 | { |
1367 | { |
1481 | object *tmp_obj; |
|
|
1482 | |
|
|
1483 | /* Remove any spells this object currently has in it */ |
1368 | /* Remove any spells this object currently has in it */ |
1484 | while (op->inv) |
|
|
1485 | op->inv->destroy (); |
1369 | op->destroy_inv (false); |
1486 | |
1370 | |
1487 | tmp_obj = arch_to_object (change->other_arch); |
1371 | object *tmp = change->other_arch->instance (); |
1488 | insert_ob_in_ob (tmp_obj, op); |
1372 | insert_ob_in_ob (tmp, op); |
1489 | } |
1373 | } |
1490 | /* No harm setting this for potions/horns */ |
1374 | /* No harm setting this for potions/horns */ |
1491 | op->other_arch = change->other_arch; |
1375 | op->other_arch = change->other_arch; |
1492 | } |
1376 | } |
1493 | |
1377 | |
… | |
… | |
1578 | op->value *= change->value; |
1462 | op->value *= change->value; |
1579 | |
1463 | |
1580 | if (change->materials) |
1464 | if (change->materials) |
1581 | op->materials = change->materials; |
1465 | op->materials = change->materials; |
1582 | |
1466 | |
1583 | if (change->materialname) |
1467 | if (change->material != MATERIAL_NULL) |
1584 | op->materialname = change->materialname; |
1468 | op->material = change->material; |
1585 | |
1469 | |
1586 | if (change->slaying) |
1470 | if (change->slaying) |
1587 | op->slaying = change->slaying; |
1471 | op->slaying = change->slaying; |
1588 | |
1472 | |
1589 | if (change->race) |
1473 | if (change->race) |
… | |
… | |
1698 | #if 1 |
1582 | #if 1 |
1699 | LOG (llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type); |
1583 | LOG (llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type); |
1700 | #endif |
1584 | #endif |
1701 | return; |
1585 | return; |
1702 | } |
1586 | } |
1703 | if (!strcmp (art->item->name, "NONE")) |
1587 | |
|
|
1588 | if (art->item->name == shstr_NONE) |
1704 | return; |
1589 | return; |
|
|
1590 | |
1705 | if (FABS (op->magic) < art->item->magic) |
1591 | if (fabs (op->magic) < art->item->magic) |
1706 | continue; /* Not magic enough to be this item */ |
1592 | continue; /* Not magic enough to be this item */ |
1707 | |
1593 | |
1708 | /* Map difficulty not high enough */ |
1594 | /* Map difficulty not high enough */ |
1709 | if (difficulty < art->difficulty) |
1595 | if (difficulty < art->difficulty) |
1710 | continue; |
1596 | continue; |
… | |
… | |
1761 | item->level = donor->level; |
1647 | item->level = donor->level; |
1762 | |
1648 | |
1763 | /* if donor has some attacktypes, the flesh is poisonous */ |
1649 | /* if donor has some attacktypes, the flesh is poisonous */ |
1764 | if (donor->attacktype & AT_POISON) |
1650 | if (donor->attacktype & AT_POISON) |
1765 | item->type = POISON; |
1651 | item->type = POISON; |
|
|
1652 | |
1766 | if (donor->attacktype & AT_ACID) |
1653 | if (donor->attacktype & AT_ACID) |
1767 | item->stats.hp = -1 * item->stats.food; |
1654 | item->stats.hp = -1 * item->stats.food; |
|
|
1655 | |
1768 | SET_FLAG (item, FLAG_NO_STEAL); |
1656 | SET_FLAG (item, FLAG_NO_STEAL); |
1769 | } |
1657 | } |
1770 | } |
1658 | } |
1771 | |
1659 | |
1772 | /* special_potion() - so that old potion code is still done right. */ |
1660 | static void |
1773 | int |
|
|
1774 | special_potion (object *op) |
|
|
1775 | { |
|
|
1776 | if (op->attacktype) |
|
|
1777 | return 1; |
|
|
1778 | |
|
|
1779 | if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha) |
|
|
1780 | return 1; |
|
|
1781 | |
|
|
1782 | for (int i = 0; i < NROFATTACKS; i++) |
|
|
1783 | if (op->resist[i]) |
|
|
1784 | return 1; |
|
|
1785 | |
|
|
1786 | return 0; |
|
|
1787 | } |
|
|
1788 | |
|
|
1789 | void |
|
|
1790 | free_treasurestruct (treasure *t) |
1661 | free_treasurestruct (treasure *t) |
1791 | { |
1662 | { |
1792 | if (t->next) free_treasurestruct (t->next); |
1663 | if (t->next) free_treasurestruct (t->next); |
1793 | if (t->next_yes) free_treasurestruct (t->next_yes); |
1664 | if (t->next_yes) free_treasurestruct (t->next_yes); |
1794 | if (t->next_no) free_treasurestruct (t->next_no); |
1665 | if (t->next_no) free_treasurestruct (t->next_no); |
1795 | |
1666 | |
1796 | delete t; |
1667 | delete t; |
1797 | } |
1668 | } |
1798 | |
1669 | |
1799 | void |
1670 | static void |
1800 | free_charlinks (linked_char *lc) |
1671 | free_charlinks (linked_char *lc) |
1801 | { |
1672 | { |
1802 | if (lc->next) |
1673 | if (lc->next) |
1803 | free_charlinks (lc->next); |
1674 | free_charlinks (lc->next); |
1804 | |
1675 | |
1805 | delete lc; |
1676 | delete lc; |
1806 | } |
1677 | } |
1807 | |
1678 | |
1808 | void |
1679 | static void |
1809 | free_artifact (artifact *at) |
1680 | free_artifact (artifact *at) |
1810 | { |
1681 | { |
1811 | if (at->next) free_artifact (at->next); |
1682 | if (at->next) free_artifact (at->next); |
1812 | if (at->allowed) free_charlinks (at->allowed); |
1683 | if (at->allowed) free_charlinks (at->allowed); |
1813 | |
1684 | |
1814 | at->item->destroy (1); |
1685 | at->item->destroy (); |
1815 | |
1686 | |
1816 | sfree (at); |
1687 | sfree (at); |
1817 | } |
1688 | } |
1818 | |
1689 | |
1819 | void |
|
|
1820 | free_artifactlist (artifactlist *al) |
|
|
1821 | { |
|
|
1822 | artifactlist *nextal; |
|
|
1823 | |
|
|
1824 | for (al = first_artifactlist; al; al = nextal) |
|
|
1825 | { |
|
|
1826 | nextal = al->next; |
|
|
1827 | |
|
|
1828 | if (al->items) |
|
|
1829 | free_artifact (al->items); |
|
|
1830 | |
|
|
1831 | sfree (al); |
|
|
1832 | } |
|
|
1833 | } |
|
|
1834 | |
|
|
1835 | void |
|
|
1836 | free_all_treasures (void) |
|
|
1837 | { |
|
|
1838 | treasurelist *tl, *next; |
|
|
1839 | |
|
|
1840 | for (tl = first_treasurelist; tl; tl = next) |
|
|
1841 | { |
|
|
1842 | clear (tl); |
|
|
1843 | |
|
|
1844 | next = tl->next; |
|
|
1845 | delete tl; |
|
|
1846 | } |
|
|
1847 | |
|
|
1848 | free_artifactlist (first_artifactlist); |
|
|
1849 | } |
|
|