Crossfire Server  1.75.0
MessageWriter.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 "MessageWriter.h"
14 
16  if (message->identifier[0] == '\n') {
17  stringbuffer_append_string(buf, "MSG\n");
18  } else {
19  stringbuffer_append_printf(buf, "MSG %s\n", message->identifier);
20  }
21  if (message->title) {
22  stringbuffer_append_printf(buf, "TITLE %s\n", message->title);
23  }
24  if (message->chance) {
25  stringbuffer_append_printf(buf, "CHANCE %d\n", message->chance);
26  }
27  if (message->quest_code) {
28  stringbuffer_append_printf(buf, "QUEST %s\n", message->quest_code);
29  }
30  if (message->face) {
31  stringbuffer_append_printf(buf, "FACE %s\n", message->face->name);
32  }
33  if (message->message) {
34  stringbuffer_append_string(buf, "TEXT\n");
35  stringbuffer_append_string(buf, message->message);
36  }
37  stringbuffer_append_string(buf, "ENDMSG\n");
38 }
sstring title
The message&#39;s title, only used for knowledge.
Definition: book.h:48
sstring identifier
Message identifier, can be NULL.
Definition: book.h:47
const Face * face
Face the message displays at in the knowledge dialog, NULL if no face defined.
Definition: book.h:51
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
virtual void write(const GeneralMessage *message, StringBuffer *buf)
Write the specified asset to the StringBuffer.
int chance
Relative chance of the message appearing randomly.
Definition: book.h:45
sstring quest_code
Optional quest code and state this message will start.
Definition: book.h:50
StringBuffer * buf
Definition: readable.cpp:1563
One general message, from the lib/messages file.
Definition: book.h:44
A buffer that will be expanded as content is added to it.
sstring name
Face name, as used by archetypes and such.
Definition: face.h:19
sstring message
The message&#39;s body.
Definition: book.h:49