Crossfire Server, Trunk
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 }
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)
Definition: Quests.cpp:130
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.cpp:138
QuestWriter.h
buf
StringBuffer * buf
Definition: readable.cpp:1565
quest
Definition: quest.py:1
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.cpp:95
StringBuffer
Definition: stringbuffer.cpp:25
stringbuffer_append_multiline_block
void stringbuffer_append_multiline_block(StringBuffer *sb, const char *start, const char *content, const char *end)
Definition: stringbuffer.cpp:196
QuestWriter::write
virtual void write(const quest_definition *quest, StringBuffer *buf)
Definition: QuestWriter.cpp:17
quest_definition
Definition: quest.h:37