Crossfire Server, Trunk
ArtifactWriter.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 "ArtifactWriter.h"
14 
15 #include "string.h"
16 #include "Utils.h"
17 
18 #include <string>
19 #include <vector>
20 
21 static void writeItem(const artifactstruct *item, StringBuffer *buf) {
22  stringbuffer_append_string(buf, "Allowed");
23  if (!item->allowed) {
25  } else {
26  Utils::writeLinkedChar(item->allowed, buf);
27  }
29 
30  if (item->chance) {
31  stringbuffer_append_printf(buf, "chance %d\n", item->chance);
32  }
33  if (item->difficulty) {
34  stringbuffer_append_printf(buf, "difficulty %d\n", item->difficulty);
35  }
36  if (item->item) {
37  stringbuffer_append_printf(buf, "Object %s\n", item->item->name);
38  auto name = item->item->name;
39  item->item->name = nullptr;
41  item->item->name = name;
43  if (item->item->anim_speed) {
44  stringbuffer_append_printf(buf, "anim_speed %ld\n", item->item->anim_speed);
45  }
46 
47  auto inv = item->item->inv;
48  while (inv) {
49  stringbuffer_append_printf(buf, "arch %s\n", inv->arch->name);
50  get_ob_diff(buf, inv, &inv->arch->clone);
52  inv = inv->below;
53  }
55  }
56 }
57 
59  auto item = list->items;
60  while (item) {
61  writeItem(item, buf);
62  item = item->next;
63  }
64 }
empty_archetype
EXTERN archetype * empty_archetype
Definition: global.h:142
writeItem
static void writeItem(const artifactstruct *item, StringBuffer *buf)
Definition: ArtifactWriter.cpp:21
get_ob_diff
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Definition: object.c:4952
guildoracle.list
list
Definition: guildoracle.py:87
commongive.inv
inv
Definition: commongive.py:28
ArtifactWriter.h
Utils.h
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.c:95
artifactliststruct
Definition: artifact.h:26
ArtifactWriter::write
virtual void write(const artifactlist *list, StringBuffer *buf)
Definition: ArtifactWriter.cpp:58
artifactstruct
Definition: artifact.h:14
StringBuffer
Definition: stringbuffer.c:25
archt::clone
object clone
Definition: object.h:472
item
Definition: item.py:1
buf
StringBuffer * buf
Definition: readable.c:1606
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.c:104
give.name
name
Definition: give.py:27
Utils::writeLinkedChar
static void writeLinkedChar(const linked_char *list, StringBuffer *buf)
Definition: Utils.cpp:22