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.118 by root, Fri Nov 18 04:44:13 2016 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,2013,2014,2015,2016 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
31 32
32/* TREASURE_VERBOSE enables copious output concerning artifact generation */ 33/* TREASURE_VERBOSE enables copious output concerning artifact generation */
33 34
34//#define TREASURE_VERBOSE 35//#define TREASURE_VERBOSE
35 36
36#include <unordered_map>
37
38#include <global.h> 37#include <global.h>
39#include <treasure.h> 38#include <treasure.h>
40 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
41extern char *spell_mapping[]; 45extern char *spell_mapping[];
42 46
43static treasurelist *first_treasurelist; 47static treasurelist *first_treasurelist;
44 48
45static void change_treasure (treasure *t, object *op); /* overrule default values */ 49static void change_treasure (treasure *t, object *op); /* overrule default values */
46 50
47typedef std::unordered_map< 51typedef ska::flat_hash_map
52 <
48 const char *, 53 const char *,
49 treasurelist *, 54 treasurelist *,
50 str_hash, 55 str_hash,
51 str_equal, 56 str_equal,
52 slice_allocator< std::pair<const char *const, treasurelist *> > 57 slice_allocator< std::pair<const char *const, treasurelist *> >
53> tl_map_t; 58 > tl_map_t;
54 59
55static tl_map_t tl_map; 60static tl_map_t tl_map;
56 61
57//TODO: class method 62//TODO: class method
58static void free_treasurestruct (treasure *t); // bleh desu 63static void free_treasurestruct (treasure *t); // bleh desu
75treasurelist::find (const char *name) 80treasurelist::find (const char *name)
76{ 81{
77 if (!name) 82 if (!name)
78 return 0; 83 return 0;
79 84
80 auto (i, tl_map.find (name)); 85 auto i = tl_map.find (name);
81 86
82 if (i == tl_map.end ()) 87 if (i == tl_map.end ())
83 return 0; 88 return 0;
84 89
85 return i->second; 90 return i->second;
216 { 221 {
217 for (treasure *t = tl->items; t; t = t->next) 222 for (treasure *t = tl->items; t; t = t->next)
218 { 223 {
219 if (t->next_yes || t->next_no) 224 if (t->next_yes || t->next_no)
220 { 225 {
221 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);
222 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");
223 } 231 }
224 232
225 tl->total_chance += t->chance; 233 tl->total_chance += t->chance;
226 } 234 }
492 { 0, 0, 0, 3, 97}, // 29 500 { 0, 0, 0, 3, 97}, // 29
493 { 0, 0, 0, 0, 100}, // 30 501 { 0, 0, 0, 0, 100}, // 30
494 { 0, 0, 0, 0, 100}, // 31 502 { 0, 0, 0, 0, 100}, // 31
495}; 503};
496 504
497/* calculate the appropriate level for wands staves and scrolls. 505/* calculate the appropriate level for wands staves and scrolls.
498 * 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)
499 * 507 *
500 * elmex Wed Aug 9 17:44:59 CEST 2006: 508 * elmex Wed Aug 9 17:44:59 CEST 2006:
501 * 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.
502 */ 510 */
810 * 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
811 * into scrolls/books/wands, makes it unidentified, hides the value, etc. 819 * into scrolls/books/wands, makes it unidentified, hides the value, etc.
812 */ 820 */
813 821
814/* 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
815 * 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
816 * 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
817 * way to do this? b.t. */ 825 * way to do this? b.t. */
818 826
819/* 827/*
820 * ! (flags & GT_ENVIRONMENT): 828 * ! (flags & GT_ENVIRONMENT):
821 * Automatically calls fix_flesh_item(). 829 * Automatically calls fix_flesh_item().

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines