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.114 by root, Tue Jan 3 11:25:31 2012 UTC vs.
Revision 1.125 by root, Sat Oct 8 21:54:05 2022 UTC

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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * 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 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * 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 10 * 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 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * 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 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25/* TREASURE_DEBUG does some checking on the treasurelists after loading. 26/* TREASURE_DEBUG does some checking on the treasurelists after loading.
26 * It is useful for finding bugs in the treasures file. Since it only 27 * It is useful for finding bugs in the treasures file. Since it only
34//#define TREASURE_VERBOSE 35//#define TREASURE_VERBOSE
35 36
36#include <global.h> 37#include <global.h>
37#include <treasure.h> 38#include <treasure.h>
38 39
40#include <flat_hash_map.hpp>
41
42// used only by treasure.C, does not handle null arch ptrs
43#define IS_ARCH(arch,name) ((arch)->archname == shstr_ ## name)
44
39extern char *spell_mapping[]; 45extern char *spell_mapping[];
40 46
41static treasurelist *first_treasurelist; 47static treasurelist *first_treasurelist;
42 48
43static void change_treasure (treasure *t, object *op); /* overrule default values */ 49static void change_treasure (treasure *t, object *op); /* overrule default values */
44 50
45typedef std::tr1::unordered_map< 51typedef ska::flat_hash_map
52 <
46 const char *, 53 const char *,
47 treasurelist *, 54 treasurelist *,
48 str_hash, 55 str_hash,
49 str_equal, 56 str_equal,
50 slice_allocator< std::pair<const char *const, treasurelist *> > 57 slice_allocator< std::pair<const char *const, treasurelist *> >
51> tl_map_t; 58 > tl_map_t;
52 59
53static tl_map_t tl_map; 60static tl_map_t tl_map;
54 61
55//TODO: class method 62//TODO: class method
56static void free_treasurestruct (treasure *t); // bleh desu 63static void free_treasurestruct (treasure *t); // bleh desu
73treasurelist::find (const char *name) 80treasurelist::find (const char *name)
74{ 81{
75 if (!name) 82 if (!name)
76 return 0; 83 return 0;
77 84
78 auto (i, tl_map.find (name)); 85 auto i = tl_map.find (name);
79 86
80 if (i == tl_map.end ()) 87 if (i == tl_map.end ())
81 return 0; 88 return 0;
82 89
83 return i->second; 90 return i->second;
214 { 221 {
215 for (treasure *t = tl->items; t; t = t->next) 222 for (treasure *t = tl->items; t; t = t->next)
216 { 223 {
217 if (t->next_yes || t->next_no) 224 if (t->next_yes || t->next_no)
218 { 225 {
219 LOG (llevError, "Treasure %s is one item, but on treasure %s\n", &tl->name, t->item ? &t->item->archname : &t->name); 226 LOG (llevError, "Treasure %s is one item, but on treasure %s%s\n",
227 &tl->name,
228 t->item ? "item " : "",
229 t->item ? &t->item->archname : &t->name);
220 LOG (llevError, " the next_yes or next_no field is set\n"); 230 LOG (llevError, " the next_yes or next_no field is set\n");
221 } 231 }
222 232
223 tl->total_chance += t->chance; 233 tl->total_chance += t->chance;
224 } 234 }
490 { 0, 0, 0, 3, 97}, // 29 500 { 0, 0, 0, 3, 97}, // 29
491 { 0, 0, 0, 0, 100}, // 30 501 { 0, 0, 0, 0, 100}, // 30
492 { 0, 0, 0, 0, 100}, // 31 502 { 0, 0, 0, 0, 100}, // 31
493}; 503};
494 504
495/* calculate the appropriate level for wands staves and scrolls. 505/* calculate the appropriate level for wands staves and scrolls.
496 * This code presumes that op has had its spell object created (in op->inv) 506 * This code presumes that op has had its spell object created (in op->inv)
497 * 507 *
498 * elmex Wed Aug 9 17:44:59 CEST 2006: 508 * elmex Wed Aug 9 17:44:59 CEST 2006:
499 * Removed multiplicator, too many high-level items were generated on low-difficulty maps. 509 * Removed multiplicator, too many high-level items were generated on low-difficulty maps.
500 */ 510 */
808 * order to set it up right. This produced magical bonuses, puts spells 818 * order to set it up right. This produced magical bonuses, puts spells
809 * into scrolls/books/wands, makes it unidentified, hides the value, etc. 819 * into scrolls/books/wands, makes it unidentified, hides the value, etc.
810 */ 820 */
811 821
812/* 4/28/96 added creator object from which op may now inherit properties based on 822/* 4/28/96 added creator object from which op may now inherit properties based on
813 * op->type. Right now, which stuff the creator passes on is object type 823 * op->type. Right now, which stuff the creator passes on is object type
814 * dependant. I know this is a spagetti manuever, but is there a cleaner 824 * dependant. I know this is a spagetti manuever, but is there a cleaner
815 * way to do this? b.t. */ 825 * way to do this? b.t. */
816 826
817/* 827/*
818 * ! (flags & GT_ENVIRONMENT): 828 * ! (flags & GT_ENVIRONMENT):
819 * Automatically calls fix_flesh_item(). 829 * Automatically calls fix_flesh_item().
947 } 957 }
948 break; 958 break;
949 959
950 case POTION: 960 case POTION:
951 { 961 {
952 int too_many_tries = 0, is_special = 0; 962 int too_many_tries = 0;
953 963
954 /* Handle healing and magic power potions */ 964 /* Handle healing and magic power potions */
955 if (op->stats.sp && !op->randomitems) 965 if (op->stats.sp && !op->randomitems)
956 { 966 {
957 object *tmp = archetype::get (spell_mapping[op->stats.sp]); 967 object *tmp = archetype::get (spell_mapping[op->stats.sp]);
958 insert_ob_in_ob (tmp, op); 968 insert_ob_in_ob (tmp, op);
959 op->stats.sp = 0; 969 op->stats.sp = 0;
960 } 970 }
961 971
962 while (!(is_special = special_potion (op)) && !op->inv) 972 while (!special_potion (op) && !op->inv)
963 { 973 {
964 generate_artifact (op, difficulty); 974 generate_artifact (op, difficulty);
965 if (too_many_tries++ > 10) 975 if (too_many_tries++ > 10)
966 break; 976 break;
967 } 977 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines