Crossfire Server, Trunk  1.75.0
QuestWriter.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2021 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 "QuestWriter.h"
14 
15 #define W(x, n) { if (quest->x) { stringbuffer_append_printf(buf, n "\n", quest->x); } }
16 
18  W(quest_code, "quest %s");
19  W(quest_title, "title %s");
20  if (quest->face) {
21  stringbuffer_append_printf(buf, "face %s\n", quest->face->name);
22  }
23  stringbuffer_append_multiline_block(buf, "description", quest->quest_description, NULL);
24  if (quest->parent) {
25  stringbuffer_append_printf(buf, "parent %s\n", quest->parent->quest_code);
26  }
27  W(quest_restart, "restart %d");
28  W(quest_is_system, "is_system %d");
29  stringbuffer_append_multiline_block(buf, "comment", quest->quest_comment, NULL);
30  for (const auto step : quest->steps) {
31  stringbuffer_append_printf(buf, "step %d\n", step->step);
32  if (step->is_completion_step) {
33  stringbuffer_append_string(buf, "finishes_quest\n");
34  }
35  stringbuffer_append_multiline_block(buf, "description", step->step_description, NULL);
36  if (!step->conditions.empty()) {
37  stringbuffer_append_string(buf, "setwhen\n");
38  char when[500];
39  for (const auto cond : step->conditions) {
40  quest_write_condition(when, sizeof(when), cond);
41  stringbuffer_append_printf(buf, "%s\n", when);
42  }
43  stringbuffer_append_string(buf, "end_setwhen\n");
44  }
45  stringbuffer_append_string(buf, "end_step\n");
46  }
47  stringbuffer_append_string(buf, "end_quest\n");
48  /*
49 
50  foreach(QuestStep* step, quest->steps())
51  {
52  if (step->setWhen().size() > 0)
53  {
54  stream << "setwhen\n";
55  foreach(QString when, step->setWhen())
56  {
57  stream << when << "\n";
58  }
59  stream << "end_setwhen\n";
60  }
61  stream << "end_step\n";
62 
63  }
64 
65  stream << "end_quest\n\n";*/
66 }
Face::name
sstring name
Face name, as used by archetypes and such.
Definition: face.h:19
W
#define W(x, n)
Definition: QuestWriter.cpp:15
quest_write_condition
void quest_write_condition(char *buf, size_t len, const quest_condition *cond)
Write a step condition to a buffer.
Definition: Quests.cpp:130
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
Definition: stringbuffer.cpp:138
QuestWriter.h
quest_definition::quest_description
sstring quest_description
Quest longer description.
Definition: quest.h:40
buf
StringBuffer * buf
Definition: readable.cpp:1565
quest_definition::quest_comment
sstring quest_comment
Quest comment, not visible to players.
Definition: quest.h:41
quest_definition::face
const Face * face
Face associated with this quest.
Definition: quest.h:43
quest_definition::quest_code
sstring quest_code
Quest internal code.
Definition: quest.h:38
quest_definition::parent
struct quest_definition * parent
Parent for this quest, NULL if it is a 'top-level' quest.
Definition: quest.h:47
step
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o step
Definition: INSTALL_WIN32.txt:20
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.cpp:95
StringBuffer
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.cpp:25
stringbuffer_append_multiline_block
void stringbuffer_append_multiline_block(StringBuffer *sb, const char *start, const char *content, const char *end)
Append the specified content in a multiline block, starting with "start" and ending with "end".
Definition: stringbuffer.cpp:196
QuestWriter::write
virtual void write(const quest_definition *quest, StringBuffer *buf)
Write the specified asset to the StringBuffer.
Definition: QuestWriter.cpp:17
quest_definition
Definition of an in-game quest.
Definition: quest.h:37
quest_definition::steps
std::vector< quest_step_definition * > steps
Quest steps.
Definition: quest.h:46