Crossfire Server, Trunk  R20513
Functions
dialog.c File Reference

Structures and functions used for the dialog system. More...

#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "define.h"
#include "object.h"
#include "dialog.h"
Include dependency graph for dialog.c:

Go to the source code of this file.

Functions

void free_dialog_information (object *op)
 Frees obj::dialog_information. More...
 
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. More...
 
static int matches (const char *exp, const char *text)
 Does the text match the expression? More...
 
static void parse_dialog_information (object *op)
 Parse the dialog information for op, and fills in obj::dialog_information. More...
 

Detailed Description

Structures and functions used for the dialog system.

Definition in file dialog.c.

Function Documentation

void free_dialog_information ( object op)
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 209 of file dialog.c.

References struct_dialog_information::all_messages, struct_dialog_information::all_replies, obj::dialog_information, FLAG_DIALOG_PARSED, matches(), struct_dialog_reply::next, struct_dialog_message::next, parse_dialog_information(), and QUERY_FLAG.

Referenced by monster_do_talk_npc().

Here is the call graph for this function:

Here is the caller graph for this function:

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 79 of file dialog.c.

References re_cmp(), strdup(), and strtok_r.

Referenced by get_dialog_message(), and re_cmp_step().

Here is the call graph for this function:

Here is the caller graph for this function:

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 107 of file dialog.c.

References struct_dialog_information::all_messages, struct_dialog_information::all_replies, obj::dialog_information, FALSE, fatal(), FLAG_DIALOG_PARSED, llevDebug, LOG(), struct_dialog_message::match, struct_dialog_reply::message, struct_dialog_message::message, obj::msg, obj::name, struct_dialog_reply::next, struct_dialog_message::next, OUT_OF_MEMORY, QUERY_FLAG, struct_dialog_message::replies, struct_dialog_reply::reply, rt_question, rt_reply, SET_FLAG, strdup(), strtok_r, TRUE, and struct_dialog_reply::type.

Referenced by get_dialog_message().

Here is the call graph for this function:

Here is the caller graph for this function: