From 78c7c6bf04a6c96d92524ae37ad165e65f599eb8 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Tue, 17 Sep 2013 16:56:04 -0300 Subject: HPM: npc_chat.c Interfaced Fully Integrated, closes #117 Also updated buildin_ functions to match latest script.c/.h macros. Signed-off-by: shennetsind --- src/map/npc.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 8 deletions(-) (limited to 'src/map/npc.h') diff --git a/src/map/npc.h b/src/map/npc.h index 0fc773dfc..6c1ca0972 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -98,10 +98,6 @@ enum actor_classes { //Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001) #define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > MAX_NPC_CLASS2_START && (id) < MAX_NPC_CLASS2_END ) ) -#ifdef PCRE_SUPPORT -void npc_chat_finalize(struct npc_data* nd); -#endif - //Script NPC events. enum npce_event { NPCE_LOGIN, @@ -131,10 +127,6 @@ struct npc_path_data { unsigned short references; }; -/* comes from npc_chat.c */ -int npc_chat_sub (struct block_list* bl, va_list ap); - - /* npc.c interface */ struct npc_interface { /* */ @@ -246,4 +238,56 @@ struct npc_interface *npc; void npc_defaults(void); + +/* comes from npc_chat.c */ +#ifdef PCRE_SUPPORT +#include "../../3rdparty/pcre/include/pcre.h" +/* Structure containing all info associated with a single pattern block */ +struct pcrematch_entry { + struct pcrematch_entry* next; + char* pattern; + pcre* pcre_; + pcre_extra* pcre_extra_; + char* label; +}; + +/* A set of patterns that can be activated and deactived with a single command */ +struct pcrematch_set { + struct pcrematch_set* prev; + struct pcrematch_set* next; + struct pcrematch_entry* head; + int setid; +}; + +/* + * Entire data structure hung off a NPC + * + * The reason I have done it this way (a void * in npc_data and then + * this) was to reduce the number of patches that needed to be applied + * to a ragnarok distribution to bring this code online. I + * also wanted people to be able to grab this one file to get updates + * without having to do a large number of changes. + */ +struct npc_parse { + struct pcrematch_set* active; + struct pcrematch_set* inactive; +}; + +struct npc_chat_interface { + int (*sub) (struct block_list* bl, va_list ap); + void (*finalize) (struct npc_data* nd); + void (*def_pattern) (struct npc_data* nd, int setid, const char* pattern, const char* label); + struct pcrematch_entry* (*create_pcrematch_entry) (struct pcrematch_set* set); + void (*delete_pcreset) (struct npc_data* nd, int setid); + void (*deactivate_pcreset) (struct npc_data* nd, int setid); + void (*activate_pcreset) (struct npc_data* nd, int setid); + struct pcrematch_set* (*lookup_pcreset) (struct npc_data* nd, int setid); + void (*finalize_pcrematch_entry) (struct pcrematch_entry* e); +}; + +struct npc_chat_interface *npc_chat; + +void npc_chat_defaults(void); +#endif + #endif /* _NPC_H_ */ -- cgit v1.2.3-70-g09d2