25 #define QUESTFILE_NEXTQUEST 0 26 #define QUESTFILE_QUEST 1 27 #define QUESTFILE_QUESTDESC 2 28 #define QUESTFILE_STEP 3 29 #define QUESTFILE_STEPDESC 4 30 #define QUESTFILE_STEPCOND 5 31 #define QUESTFILE_COMMENT 6 47 if (strcmp(read,
"end_setwhen") == 0) {
64 LOG(
llevDebug,
"condition added for step %d of quest %s, looking for quest %s between steps %d and %d\n",
69 if (strcmp(read,
"end_description") == 0) {
89 if (strcmp(read,
"end_step") == 0) {
94 if (strcmp(read,
"finishes_quest") == 0) {
98 if (strcmp(read,
"description") == 0) {
103 if (strcmp(read,
"setwhen") == 0) {
107 LOG(
llevError,
"quests: invalid line %s in definition of quest %s in %s:%zu!\n",
113 if (strcmp(read,
"end_description") == 0) {
131 if (strcmp(read,
"end_comment") == 0) {
145 if (strcmp(read,
"end_quest") == 0) {
155 if (strcmp(read,
"description") == 0) {
161 if (strncmp(read,
"title ", 6) == 0) {
166 if (sscanf(read,
"step %d", &i)) {
169 quest->
steps.push_back(step);
174 if (sscanf(read,
"restart %d", &i)) {
178 if (strncmp(read,
"parent ", 7) == 0) {
183 if (strncmp(read,
"face ", 5) == 0) {
188 if (strncmp(read,
"comment", 7) == 0) {
194 if (sscanf(read,
"is_system %d", &i)) {
203 if (strncmp(read,
"quest ", 6) == 0) {
209 quest->face =
faces->
get(
"quest_generic.111");
214 if (strcmp(read,
"") == 0)
217 LOG(
llevError,
"quest: invalid file format for %s, I don't know what to do with the line %s\n", filename.c_str(), read);
221 LOG(
llevError,
"quest: quest definition file %s read in, ends with state %d\n", filename.c_str(), in);
int maxstep
The latest step that triggers the condition, to match, the stages must be between minstep and maxstep...
sstring step_description
Step description to show player.
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition of an in-game quest.
T * get(const Key &name)
Get a named asset.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
sstring quest_code
The quest that triggers the condition.
std::vector< quest_step_definition * > steps
Quest steps.
sstring quest_comment
Quest comment, not visible to players.
#define QUESTFILE_STEP
In a quest step.
sstring add_string(const char *str)
Share a string.
QuestLoader(Quests *quests, Faces *faces, AssetsTracker *tracker)
size_t bufferreader_current_line(BufferReader *br)
Return the index of the last line returned by bufferreader_next_line().
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
quest_definition * quest_create(const char *name)
#define QUESTFILE_COMMENT
In a quest comment.
int quest_condition_from_string(quest_condition *condition, const char *buffer)
Parse a single step condition.
One condition to automatically move to a quest step.
quest_condition * quest_create_condition(void)
Allocate a quest_condition, will call fatal() if out of memory.
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
bool quest_is_system
If set then the quest isn't counted or listed.
Base class to be informed of where an asset is defined.
quest_step_definition * quest_create_step(void)
Allocate a quest_step_definition, will call fatal() if out of memory.
sstring quest_code
Quest internal code.
std::vector< quest_condition * > conditions
The conditions that must be satisfied to trigger the step.
#define QUESTFILE_QUEST
In a quest definition.
sstring quest_title
Quest title for player.
#define QUESTFILE_QUESTDESC
In a quest description.
struct quest_definition * parent
Parent for this quest, NULL if it is a 'top-level' quest.
const Face * face
Face associated with this quest.
int minstep
The earliest step in the quest that triggers the condition, -1 means finished, 0 means not started...
int is_completion_step
Whether this step completes the quest (1) or not (0)
virtual void assetDefined(const archetype *asset, const std::string &filename)
Function called when an asset is defined in a file.
#define QUESTFILE_NEXTQUEST
Waiting for next quest definition.
#define QUESTFILE_STEPCOND
In a quest step conditions.
Only for debugging purposes.
int quest_restart
If non zero, can be restarted.
C function wrappers to interact with assets.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
virtual void load(BufferReader *reader, const std::string &filename) override
Load assets from the specified reader.
A buffer that will be expanded as content is added to it.
sstring quest_description
Quest longer description.
static struct_quest ** quests
All quests in the game.
#define QUESTFILE_STEPDESC
In a quest step description.
T * define(const Key &name, T *asset)
Define an asset, erasing an existing one.