52 nextrep = currep->
next;
63 nextrep = currep->
next;
81 static int matches(
const char *exp,
const char *text) {
82 char *pipe, *save = NULL, *msg;
90 pipe = strtok_r(msg,
"|", &save);
96 pipe = strtok_r(NULL,
"|", &save);
107 return msg[0] ==
'{';
130 char *current, *save = NULL, *msg, *cp;
147 msg = strdup(op->
msg);
148 current = strtok_r(msg,
"\n", &save);
151 if (strncmp(current,
"@match ", 7) == 0) {
160 last->
next = message;
165 message->
match = strdup(current+7);
166 }
else if ((strncmp(current,
"@reply ", 7) == 0 && (len = 7)) || (strncmp(current,
"@question ", 10) == 0 && (len = 10))) {
170 cp = strchr(current+len,
' ');
173 reply->
reply = strdup(current+len);
176 reply->
reply = strdup(current+len);
178 LOG(
llevDebug,
"Warning: @reply/@question without message for %s!\n", op->
name);
191 }
else if ((strncmp(current,
"@identify", 9) == 0 && (len = 9))) {
195 }
else if (message) {
198 tmplen += strlen(current)+2;
201 tmp =
static_cast<char *
>(realloc(tmp, tmplen*
sizeof(
char)));
206 strncat(tmp, current, tmplen-strlen(tmp)-1);
207 strncat(tmp,
"\n", tmplen-strlen(tmp)-1);
209 current = strtok_r(NULL,
"\n", &save);
238 if (
matches((*message)->match, text)) {
246 if (strcmp((*reply)->reply, text) == 0)
void free_dialog_information(object *op)
Frees obj::dialog_information.
struct_dialog_information * dialog_information
Parsed dialog information for this object.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
char * message
What the player will actually say for this reply.
Global type definitions and header inclusions.
object * object_find_by_arch_name(const object *who, const char *name)
Find object in inventory by archetype name.
struct struct_dialog_message * next
Next message, NULL if last.
One reply a NPC can expect.
#define BITMASK_VALID
Bit indicating if the event bitmask is valid or not.
char * match
What the player should say, can be a regexp.
const char * NPC_DIALOG_ARCH
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
#define QUERY_FLAG(xyz, p)
bool identifies
Identify the speaker when this message is matched.
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.
sstring msg
If this is a book/sign/magic mouth/etc.
char * reply
Reply expected from the player.
static void parse_dialog_information(object *op)
Parse the dialog information for op, and fills in obj::dialog_information.
uint64_t event_bitmask
Bitmask of events this object has a handler for, see events.h.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
const char * re_cmp(const char *, const char *)
re-cmp - get regular expression match.
Object structure, the core of Crossfire.
sstring name
The name of the object, obviously...
Only for debugging purposes.
static bool is_cfdialog(const char *msg)
Return true if the given message is detected as CFDialog JSON.
One message a NPC can react to.
void dialog_preparse(object *op)
#define CLEAR_FLAG(xyz, p)
struct struct_dialog_reply * replies
Replies this message has.
char * message
What the NPC will say.
static int matches(const char *exp, const char *text)
Does the text match the expression?
#define FLAG_DIALOG_PARSED
Was the object::msg field parsed? Temporary flag not saved.
struct struct_dialog_reply * next
Next reply, NULL for last.
reply_type type
Type of message.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Core defines: object types, flags, etc.