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
21
void
ArtifactWriter::write
(
const
artifact
*
item
,
StringBuffer
*
buf
) {
22
stringbuffer_append_string
(
buf
,
"Allowed"
);
23
if
(
item
->allowed.empty()) {
24
stringbuffer_append_string
(
buf
,
" all"
);
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
}
32
stringbuffer_append_string
(
buf
,
"\n"
);
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
;
44
get_ob_diff
(
buf
,
item
->item, &
empty_archetype
->
clone
);
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);
55
stringbuffer_append_string
(
buf
,
"end\n"
);
56
inv
=
inv
->below;
57
}
58
stringbuffer_append_string
(
buf
,
"end\n"
);
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:487
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:4986
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
crossfire-crossfire-server
common
assets
ArtifactWriter.cpp
Generated by
1.8.17