Crossfire Server, Trunk
dialog.cpp File Reference
#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "define.h"
#include "object.h"
#include "dialog.h"
+ Include dependency graph for dialog.cpp:

Go to the source code of this file.

Functions

void dialog_preparse (object *op)
 
void free_dialog_information (object *op)
 
int get_dialog_message (object *op, const char *text, struct_dialog_message **message, struct_dialog_reply **reply)
 
static bool is_cfdialog (const char *msg)
 
static int matches (const char *exp, const char *text)
 
static void parse_dialog_information (object *op)
 

Variables

const char * NPC_DIALOG_ARCH = "npc_dialog"
 

Detailed Description

Structures and functions used for the dialog system.

Definition in file dialog.cpp.

Function Documentation

◆ dialog_preparse()

void dialog_preparse ( object op)

Definition at line 110 of file dialog.cpp.

References BITMASK_VALID, create_archetype(), is_cfdialog(), NPC_DIALOG_ARCH, object_find_by_arch_name(), object_insert_in_ob(), give::op, and Ice::tmp.

Referenced by monster_talk_to_npc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_dialog_information()

void free_dialog_information ( object op)

Frees obj::dialog_information.

Parameters
opwhat to clean for.

Definition at line 34 of file dialog.cpp.

References CLEAR_FLAG, replace::current, FLAG_DIALOG_PARSED, struct_dialog_reply::message, struct_dialog_reply::next, give::next, give::op, QUERY_FLAG, and struct_dialog_reply::reply.

Referenced by copy_message(), object_clear(), object_copy_no_speed(), and object_free().

+ Here is the caller graph for this function:

◆ get_dialog_message()

int get_dialog_message ( object op,
const char *  text,
struct_dialog_message **  message,
struct_dialog_reply **  reply 
)

Tries to find a message matching the said text.

Parameters
opwho is being talked to.
textwhat is being said.
[out]messagewhat op should say. Won't be NULL if return is 1.
[out]replytext the one talking should say based on the text. Can be NULL.
Returns
0 if no match, 1 if a message did match the text.
Todo:
smarter match, try to find exact before joker (*) one.

Definition at line 233 of file dialog.cpp.

References FLAG_DIALOG_PARSED, matches(), diamondslots::message, give::op, parse_dialog_information(), QUERY_FLAG, say::reply, and guild_entry::text.

Referenced by monster_do_talk_npc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_cfdialog()

static bool is_cfdialog ( const char *  msg)
static

Return true if the given message is detected as CFDialog JSON.

Definition at line 106 of file dialog.cpp.

References navar-midane_pickup::msg.

Referenced by dialog_preparse(), and parse_dialog_information().

+ Here is the caller graph for this function:

◆ matches()

static int matches ( const char *  exp,
const char *  text 
)
static

Does the text match the expression?

Parameters
expexpression to try to match.
textwhat to test.
Returns
1 if match, 0 else.
Todo:
better * handling (incorrect now, will match even if trailing chars)

Definition at line 81 of file dialog.cpp.

References push::match, navar-midane_pickup::msg, re_cmp(), and guild_entry::text.

Referenced by command_find(), get_dialog_message(), and re_cmp_step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_dialog_information()

static void parse_dialog_information ( object op)
static

Parse the dialog information for op, and fills in obj::dialog_information. Can be called safely multiple times (will just ignore the other calls).

Parameters
opobject to parse the obj::msg field.

Definition at line 127 of file dialog.cpp.

References replace::current, FALSE, fatal(), FLAG_DIALOG_PARSED, is_cfdialog(), llevDebug, LOG(), diamondslots::message, navar-midane_pickup::msg, give::op, OUT_OF_MEMORY, QUERY_FLAG, say::reply, rt_question, rt_reply, SET_FLAG, Ice::tmp, and TRUE.

Referenced by get_dialog_message().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ NPC_DIALOG_ARCH

const char* NPC_DIALOG_ARCH = "npc_dialog"

Definition at line 28 of file dialog.cpp.

Referenced by annotate_ob(), and dialog_preparse().