Crossfire Server, Trunk
FaceWriter.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 "FaceWriter.h"
14 
15 void FaceWriter::write(const Face *face, StringBuffer *buf) {
16  /* No need to write faces with no specific information */
17  if (face->visibility == 0 && face->magicmap == 0) {
18  if (face->smoothface) {
19  stringbuffer_append_printf(buf, "smoothface %s %s\n", face->name, face->smoothface->name);
20  }
21  return;
22  }
23  stringbuffer_append_printf(buf, "face %s\n", face->name);
24  if (face->visibility) {
25  stringbuffer_append_printf(buf, "visibility %d\n", face->visibility);
26  }
27  if (face->magicmap & FACE_FLOOR) {
28  stringbuffer_append_string(buf, "is_floor 1\n");
29  }
30  if (face->magicmap & (~FACE_FLOOR)) {
31  stringbuffer_append_printf(buf, "magicmap %s\n", get_colorname(face->magicmap & (~FACE_FLOOR)));
32  }
33  if (face->smoothface) {
34  stringbuffer_append_printf(buf, "smoothface %s\n", face->smoothface->name);
35  }
37 }
Face::name
sstring name
Definition: face.h:19
Face
Definition: face.h:14
Face::smoothface
Face * smoothface
Definition: face.h:18
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.cpp:138
get_colorname
const char * get_colorname(uint8_t index)
Definition: image.cpp:86
FaceWriter.h
buf
StringBuffer * buf
Definition: readable.cpp:1565
FACE_FLOOR
#define FACE_FLOOR
Definition: newclient.h:292
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.cpp:95
StringBuffer
Definition: stringbuffer.cpp:25
Face::visibility
uint8_t visibility
Definition: face.h:16
Face::magicmap
uint8_t magicmap
Definition: face.h:17
FaceWriter::write
virtual void write(const Face *face, StringBuffer *buf)
Definition: FaceWriter.cpp:15