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-2022 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 
22  stringbuffer_append_string(buf, "Allowed");
23  if (item->allowed.empty()) {
25  } else {
26  char sep = ' ';
27  for (const auto allowed : item->allowed) {
28  stringbuffer_append_printf(buf, "%c%s", sep, allowed);
29  sep = ',';
30  }
31  }
33 
34  if (item->chance) {
35  stringbuffer_append_printf(buf, "chance %d\n", item->chance);
36  }
37  if (item->difficulty) {
38  stringbuffer_append_printf(buf, "difficulty %d\n", item->difficulty);
39  }
40  if (item->item) {
41  stringbuffer_append_printf(buf, "Object %s\n", item->item->name);
42  auto name = item->item->name;
43  item->item->name = nullptr;
45  item->item->name = name;
47  if (item->item->anim_speed) {
48  stringbuffer_append_printf(buf, "anim_speed %ld\n", item->item->anim_speed);
49  }
50 
51  auto inv = item->item->inv;
52  while (inv) {
53  stringbuffer_append_printf(buf, "arch %s\n", inv->arch->name);
54  get_ob_diff(buf, inv, &inv->arch->clone);
56  inv = inv->below;
57  }
59  }
60 }
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.cpp:138
commongive.inv
inv
Definition: commongive.py:29
ArtifactWriter.h
buf
StringBuffer * buf
Definition: readable.cpp:1565
Utils.h
archetype::clone
object clone
Definition: object.h:485
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.cpp:95
StringBuffer
Definition: stringbuffer.cpp:25
item
Definition: item.py:1
get_ob_diff
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Definition: object.cpp:4982
empty_archetype
archetype * empty_archetype
Definition: init.cpp:119
ArtifactWriter::write
virtual void write(const artifact *item, StringBuffer *buf)
Definition: ArtifactWriter.cpp:21
artifact
Definition: artifact.h:14
give.name
name
Definition: give.py:27