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.119 by root, Sun Jan 29 02:47:04 2017 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 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines