Crossfire Server, Trunk
ArchetypeWriter.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 "ArchetypeWriter.h"
14 
15 static void doWrite(const archetype *arch, StringBuffer *buf) {
16  stringbuffer_append_printf(buf, "Object %s\n", arch->name);
19  if (arch->clone.anim_speed) {
20  stringbuffer_append_printf(buf, "anim_speed %ld\n", arch->clone.anim_speed);
21  }
22  if (arch->clone.casting_time) {
23  stringbuffer_append_printf(buf, "casting_time %d\n", arch->clone.casting_time);
24  }
25  auto inv = arch->clone.inv;
26  while (inv) {
27  stringbuffer_append_printf(buf, "arch %s\n", inv->arch->name);
28  get_ob_diff(buf, inv, &inv->arch->clone);
30  inv = inv->below;
31  }
33  if (arch->more) {
35  doWrite(arch->more, buf);
36  }
37 }
38 
40  if (arch->head) {
41  return;
42  }
43  doWrite(arch, buf);
44 }
ArchetypeWriter.h
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
ArchetypeWriter::write
virtual void write(const archetype *arch, StringBuffer *buf)
Definition: ArchetypeWriter.cpp:39
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.cpp:138
commongive.inv
inv
Definition: commongive.py:29
buf
StringBuffer * buf
Definition: readable.cpp:1565
doWrite
static void doWrite(const archetype *arch, StringBuffer *buf)
Definition: ArchetypeWriter.cpp:15
archetype::clone
object clone
Definition: object.h:487
archetype
Definition: object.h:483
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.cpp:95
StringBuffer
Definition: stringbuffer.cpp:25
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