1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
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 |
… | |
… | |
31 | |
31 | |
32 | /* TREASURE_VERBOSE enables copious output concerning artifact generation */ |
32 | /* TREASURE_VERBOSE enables copious output concerning artifact generation */ |
33 | |
33 | |
34 | //#define TREASURE_VERBOSE |
34 | //#define TREASURE_VERBOSE |
35 | |
35 | |
|
|
36 | #include <unordered_map> |
|
|
37 | |
36 | #include <global.h> |
38 | #include <global.h> |
37 | #include <treasure.h> |
39 | #include <treasure.h> |
38 | |
40 | |
39 | extern char *spell_mapping[]; |
41 | extern char *spell_mapping[]; |
40 | |
42 | |
41 | static treasurelist *first_treasurelist; |
43 | static treasurelist *first_treasurelist; |
42 | |
44 | |
43 | static void change_treasure (treasure *t, object *op); /* overrule default values */ |
45 | static void change_treasure (treasure *t, object *op); /* overrule default values */ |
44 | |
46 | |
45 | typedef std::tr1::unordered_map< |
47 | typedef std::unordered_map< |
46 | const char *, |
48 | const char *, |
47 | treasurelist *, |
49 | treasurelist *, |
48 | str_hash, |
50 | str_hash, |
49 | str_equal, |
51 | str_equal, |
50 | slice_allocator< std::pair<const char *const, treasurelist *> > |
52 | slice_allocator< std::pair<const char *const, treasurelist *> > |
… | |
… | |
919 | { |
921 | { |
920 | if (op->type == POTION) |
922 | if (op->type == POTION) |
921 | /* Handle healing and magic power potions */ |
923 | /* Handle healing and magic power potions */ |
922 | if (op->stats.sp && !op->randomitems) |
924 | if (op->stats.sp && !op->randomitems) |
923 | { |
925 | { |
924 | object *tmp = get_archetype (spell_mapping [op->stats.sp]); |
926 | object *tmp = archetype::get (spell_mapping [op->stats.sp]); |
925 | insert_ob_in_ob (tmp, op); |
927 | insert_ob_in_ob (tmp, op); |
926 | op->stats.sp = 0; |
928 | op->stats.sp = 0; |
927 | } |
929 | } |
928 | } |
930 | } |
929 | else if (!op->title) /* Only modify object if not special */ |
931 | else if (!op->title) /* Only modify object if not special */ |
… | |
… | |
947 | } |
949 | } |
948 | break; |
950 | break; |
949 | |
951 | |
950 | case POTION: |
952 | case POTION: |
951 | { |
953 | { |
952 | int too_many_tries = 0, is_special = 0; |
954 | int too_many_tries = 0; |
953 | |
955 | |
954 | /* Handle healing and magic power potions */ |
956 | /* Handle healing and magic power potions */ |
955 | if (op->stats.sp && !op->randomitems) |
957 | if (op->stats.sp && !op->randomitems) |
956 | { |
958 | { |
957 | object *tmp = get_archetype (spell_mapping[op->stats.sp]); |
959 | object *tmp = archetype::get (spell_mapping[op->stats.sp]); |
958 | insert_ob_in_ob (tmp, op); |
960 | insert_ob_in_ob (tmp, op); |
959 | op->stats.sp = 0; |
961 | op->stats.sp = 0; |
960 | } |
962 | } |
961 | |
963 | |
962 | while (!(is_special = special_potion (op)) && !op->inv) |
964 | while (!special_potion (op) && !op->inv) |
963 | { |
965 | { |
964 | generate_artifact (op, difficulty); |
966 | generate_artifact (op, difficulty); |
965 | if (too_many_tries++ > 10) |
967 | if (too_many_tries++ > 10) |
966 | break; |
968 | break; |
967 | } |
969 | } |