From acc992ac2838f6380ebf2b2f8a514e86c2b750d9 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 19 Jan 2014 02:58:36 -0200 Subject: HPM Custom Data Struct Expansion: map/instance/party/guild As requested by the community in http://hercules.ws/board/topic/3832-hpm-custom-data-struct-for-instance-data-guild-data-and-party-data/ Signed-off-by: shennetsind --- src/common/HPM.c | 16 +++++++++------- src/common/HPM.h | 2 +- src/common/HPMi.h | 20 ++++++++++++++++++++ src/common/mmo.h | 12 +++++++++--- 4 files changed, 39 insertions(+), 11 deletions(-) (limited to 'src/common') diff --git a/src/common/HPM.c b/src/common/HPM.c index cb70ddcd7..1edf24901 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -316,19 +316,21 @@ CPCMD(plugins) { void hplugins_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) { /* record address */ switch( type ) { + /* core-handled */ case HPDT_SESSION: ret->HPDataSRCPtr = (void**)(&((struct socket_data *)ptr)->hdata); ret->hdatac = &((struct socket_data *)ptr)->hdatac; break; /* goes to sub */ - case HPDT_MSD: - case HPDT_NPCD: - if( HPM->grabHPDataSub ) - HPM->grabHPDataSub(ret,type,ptr); - else - ShowError("HPM:grabHPData failed, type %d needs sub-handler!\n",type); - break; default: + if( HPM->grabHPDataSub ) { + if( HPM->grabHPDataSub(ret,type,ptr) ) + return; + else { + ShowError("HPM:HPM:grabHPData failed, unknown type %d!\n",type); + } + } else + ShowError("HPM:grabHPData failed, type %d needs sub-handler!\n",type); ret->HPDataSRCPtr = NULL; ret->hdatac = NULL; return; diff --git a/src/common/HPM.h b/src/common/HPM.h index 1f2ba4648..393f8f819 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -143,7 +143,7 @@ struct HPM_interface { int (*arg_db_clear_sub) (DBKey key, DBData *data, va_list args); void (*grabHPData) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); /* for server-specific HPData e.g. map_session_data */ - void (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); + bool (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); /* for custom config parsing */ bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point); } HPM_s; diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 78a3a9ab5..fdb6ccf52 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -82,6 +82,10 @@ enum HPluginDataTypes { HPDT_SESSION, HPDT_MSD, HPDT_NPCD, + HPDT_MAP, + HPDT_INSTANCE, + HPDT_GUILD, + HPDT_PARTY, }; /* used in macros and conf storage */ @@ -111,6 +115,22 @@ enum HPluginConfType { #define addToNPCD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_NPCD,HPMi->pid,(ptr),(data),(index),(autofree))) #define getFromNPCD(ptr,index) (HPMi->getFromHPData(HPDT_NPCD,HPMi->pid,(ptr),(index))) #define removeFromNPCD(ptr,index) (HPMi->removeFromHPData(HPDT_NPCD,HPMi->pid,(ptr),(index))) +/* map_data */ +#define addToMAPD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_MAP,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromMAPD(ptr,index) (HPMi->getFromHPData(HPDT_MAP,HPMi->pid,(ptr),(index))) +#define removeFromMAPD(ptr,index) (HPMi->removeFromHPData(HPDT_MAP,HPMi->pid,(ptr),(index))) +/* party_data */ +#define addToPAD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_PARTY,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromPAD(ptr,index) (HPMi->getFromHPData(HPDT_PARTY,HPMi->pid,(ptr),(index))) +#define removeFromPAD(ptr,index) (HPMi->removeFromHPData(HPDT_PARTY,HPMi->pid,(ptr),(index))) +/* guild */ +#define addToGLD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_GUILD,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromGLD(ptr,index) (HPMi->getFromHPData(HPDT_GUILD,HPMi->pid,(ptr),(index))) +#define removeFromGLD(ptr,index) (HPMi->removeFromHPData(HPDT_GUILD,HPMi->pid,(ptr),(index))) +/* instance_data */ +#define addToINSTD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromINSTD(ptr,index) (HPMi->getFromHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(index))) +#define removeFromINSTD(ptr,index) (HPMi->removeFromHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(index))) /* HPMi->addCommand */ #define addAtcommand(cname,funcname) \ diff --git a/src/common/mmo.h b/src/common/mmo.h index 7350de443..670c2f7f7 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -178,6 +178,8 @@ #define EL_CLASS_BASE 2114 #define EL_CLASS_MAX (EL_CLASS_BASE+MAX_ELEMENTAL_CLASS-1) +struct HPluginData; + enum item_types { IT_HEALING = 0, IT_UNKNOWN, //1 @@ -498,7 +500,7 @@ struct party { unsigned char count; //Count of online characters. unsigned exp : 1, item : 2; //&1: Party-Share (round-robin), &2: pickup style: shared. - struct party_member member[MAX_PARTY]; + struct party_member member[MAX_PARTY]; }; struct map_session_data; @@ -553,13 +555,17 @@ struct guild { struct guild_expulsion expulsion[MAX_GUILDEXPULSION]; struct guild_skill skill[MAX_GUILDSKILL]; - /* TODO: still used for something?|: */ - unsigned short save_flag; // for TXT saving + /* used on char.c to state what kind of data is being saved/processed */ + unsigned short save_flag; short *instance; unsigned short instances; struct hChSysCh *channel; + + /* HPM Custom Struct */ + struct HPluginData **hdata; + unsigned int hdatac; }; struct guild_castle { -- cgit v1.2.3-60-g2f50