Crossfire Server, Trunk  1.75.0
TreasureWriter.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "TreasureWriter.h"
14 
15 #define W(x, n) { if (item->x) { stringbuffer_append_printf(buf, "%s" n "\n", indentItems.c_str(), item->x); } }
16 
17 static void writeItem(const treasure *item, const std::string &indent, StringBuffer *buf) {
18  std::string indentItems(indent);
19  indentItems += "\t";
20  if (item->item) {
21  stringbuffer_append_printf(buf, "%sarch %s\n", indentItems.c_str(), item->item->name);
22  }
23  W(artifact, "artifact %s");
24  W(name, "list %s");
25  W(list_magic_value, "list_magic_value %d");
26  W(list_magic_adjustment, "list_magic_adjustment %d");
27  indentItems += "\t";
28  W(change_arch.name, "change_name %s");
29  W(change_arch.title, "change_title %s");
30  W(change_arch.slaying, "change_slaying %s");
31  if (item->chance != 100) {
32  stringbuffer_append_printf(buf, "%schance %d\n", indentItems.c_str(), item->chance);
33  }
34  W(nrof, "nrof %d");
35  W(magic, "magic %d");
36  if (item->next_yes) {
37  stringbuffer_append_printf(buf, "%syes\n", indentItems.c_str());
38  writeItem(item->next_yes, indentItems + "\t", buf);
39  }
40  if (item->next_no) {
41  stringbuffer_append_printf(buf, "%sno\n", indentItems.c_str());
42  writeItem(item->next_no, indentItems + "\t", buf);
43  }
44  if (item->next) {
46  writeItem(item->next, indent, buf);
47  } else {
48  stringbuffer_append_printf(buf, "%send\n", indent.c_str());
49  }
50 }
51 
53  if (list->total_chance == 0) {
54  stringbuffer_append_string(buf, "treasure ");
55  } else {
56  stringbuffer_append_string(buf, "treasureone ");
57  }
60  writeItem(list->items, std::string(), buf);
61 }
treasure::chance
uint8_t chance
Percent chance for this item.
Definition: treasure.h:73
writeItem
static void writeItem(const treasure *item, const std::string &indent, StringBuffer *buf)
Definition: TreasureWriter.cpp:17
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
Definition: stringbuffer.cpp:138
buf
StringBuffer * buf
Definition: readable.cpp:1565
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
treasurelist
treasurelist represents one logical group of items to be generated together.
Definition: treasure.h:85
W
#define W(x, n)
Definition: TreasureWriter.cpp:15
TreasureWriter::write
virtual void write(const treasurelist *list, StringBuffer *buf)
Write the specified asset to the StringBuffer.
Definition: TreasureWriter.cpp:52
treasure::item
struct archetype * item
Which item this link can be.
Definition: treasure.h:64
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.cpp:95
treasure::next
treasure * next
Next treasure-item in a linked list.
Definition: treasure.h:69
StringBuffer
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.cpp:25
treasure::next_yes
treasure * next_yes
If this item was generated, use this link instead of ->next.
Definition: treasure.h:70
treasure::next_no
treasure * next_no
If this item was not generated, then continue here.
Definition: treasure.h:71
archetype::name
sstring name
More definite name, like "generate_kobold".
Definition: object.h:484
TreasureWriter.h
treasure
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
artifact
This is one artifact, ie one special item.
Definition: artifact.h:14