24 : m_treasures(treasures), m_archetypes(archetypes), m_tracker(tracker) {
54 if (sscanf(cp,
"arch %s", variable)) {
60 }
else if (strncmp(cp,
"artifact ", 9) == 0) {
67 }
else if (sscanf(cp,
"list_magic_value %d", &value)) {
69 }
else if (sscanf(cp,
"list_magic_adjustment %d", &value)) {
71 }
else if (sscanf(cp,
"list %s", variable)) {
77 }
else if (sscanf(cp,
"change_name %s", variable))
79 else if (sscanf(cp,
"change_title %s", variable))
81 else if (sscanf(cp,
"change_slaying %s", variable))
83 else if (sscanf(cp,
"chance %d", &value))
84 t->
chance = (uint8_t)value;
85 else if (sscanf(cp,
"nrof %d", &value))
86 t->
nrof = (uint16_t)value;
87 else if (sscanf(cp,
"magic %d", &value))
88 t->
magic = (uint8_t)value;
89 else if (!strcmp(cp,
"yes"))
91 else if (!strcmp(cp,
"no"))
93 else if (!strcmp(cp,
"end"))
95 else if (!strcmp(cp,
"more")) {
116 if (*buf ==
'#' || *buf ==
'\0')
119 if (sscanf(buf,
"treasureone %s", name) || sscanf(buf,
"treasure %s", name)) {
128 if (!strncmp(buf,
"treasureone", 11)) {
129 for (t = tl->
items; t != NULL; t = t->
next) {
132 LOG(
llevError,
" the next_yes or next_no field is set\n");
T * get(const Key &name)
Get a named asset.
const char * name
If != NULL, copy this over the original arch name.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
sstring name
If non null, name of list to use instead.
sstring add_string(const char *str)
Share a string.
int8_t list_magic_adjustment
Adjust difficulty when generating the list pointed by name, ignored if list_magic_value is non zero...
All archetypes in the game.
size_t bufferreader_current_line(BufferReader *br)
Return the index of the last line returned by bufferreader_next_line().
treasure * loadTreasure(BufferReader *reader, const std::string &filename)
Reads one treasure, including the 'yes', 'no' and 'more' options.
Global type definitions and header inclusions.
TreasureLoader(Treasures *treasures, Archetypes *archetypes, AssetsTracker *tracker)
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
AssetsTracker * m_tracker
sstring name
More definite name, like "generate_kobold".
size_t nroftreasures
Number of treasure items, for malloc info.
uint8_t chance
Percent chance for this item.
Base class to be informed of where an asset is defined.
const char * title
If != NULL, copy this over the original arch title.
int16_t total_chance
If non-zero, only 1 item on this list should be generated.
Archetypes * m_archetypes
treasure * next_no
If this item was not generated, then continue here.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
#define MAX_BUF
Used for all kinds of things.
Compatibility implementations of useful nonstandard types and functions.
treasurelist represents one logical group of items to be generated together.
treasure * next_yes
If this item was generated, use this link instead of ->next.
virtual void assetDefined(const archetype *asset, const std::string &filename)
Function called when an asset is defined in a file.
sstring artifact
If not null, the name of the artifact to apply to item.
virtual void load(BufferReader *reader, const std::string &filename) override
Load all treasures from a buffer.
treasure * next
Next treasure-item in a linked list.
struct _change_arch change_arch
Override default arch values if set in treasure list.
sstring name
Usually monster-name/combination.
treasure * items
Items in this list, linked.
uint8_t list_magic_value
Set difficulty when generating the list pointed by name.
uint16_t nrof
Random 1 to nrof items are generated.
treasure * get_empty_treasure(void)
Allocate and return the pointer to an empty treasure structure.
treasure is one element in a linked list, which together consist of a complete treasure-list.
const char * slaying
If != NULL, copy this over the original arch slaying.
uint8_t magic
Max magic bonus to item If the entry is a list transition, 'magic' contains the difficulty required t...
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
struct archetype * item
Which item this link can be.
T * define(const Key &name, T *asset)
Define an asset, erasing an existing one.