diff options
author | shennetsind <ind@henn.et> | 2013-11-13 21:26:21 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-11-13 21:26:21 -0200 |
commit | 8fda38dcdabbb9d252b0e11fb07b2ad37f9e659f (patch) | |
tree | 4b08262c9ef18f9a2dd39d56ae2509320ab26e8c /src | |
parent | b4d197c667353f417069c406b85a696e3e2e5b6c (diff) | |
download | hercules-8fda38dcdabbb9d252b0e11fb07b2ad37f9e659f.tar.gz hercules-8fda38dcdabbb9d252b0e11fb07b2ad37f9e659f.tar.bz2 hercules-8fda38dcdabbb9d252b0e11fb07b2ad37f9e659f.tar.xz hercules-8fda38dcdabbb9d252b0e11fb07b2ad37f9e659f.zip |
HPM Custom Data Struct Makeover!
- Modified how the core handles it, making it easier to add new points.
- Modified how plugins call it, calls were made shorter, e.g. 'HPMi->getFromSession(session[fd],HPMi->pid,0)' => 'getFromSession(session[fd],0)' -- check src/common/HPMi.h #defines for all the options
- Added support for npc_data (getFromNPCD and so on) as requested in http://hercules.ws/board/topic/2923-hpm-custom-struct-npcs/
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r-- | src/common/HPM.c | 142 | ||||
-rw-r--r-- | src/common/HPM.h | 8 | ||||
-rw-r--r-- | src/common/HPMi.h | 31 | ||||
-rw-r--r-- | src/common/socket.c | 2 | ||||
-rw-r--r-- | src/map/HPMmap.c | 81 | ||||
-rw-r--r-- | src/map/HPMmap.h | 5 | ||||
-rw-r--r-- | src/map/map.c | 4 | ||||
-rw-r--r-- | src/map/npc.c | 11 | ||||
-rw-r--r-- | src/map/npc.h | 6 | ||||
-rw-r--r-- | src/map/unit.c | 2 | ||||
-rw-r--r-- | src/plugins/sample.c | 14 |
11 files changed, 178 insertions, 128 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c index 5d08821e6..81acb3415 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -207,9 +207,9 @@ struct hplugin *hplugin_load(const char* filename) { /* core */ plugin->hpi->addCPCommand = HPM->import_symbol("addCPCommand",plugin->idx); plugin->hpi->addPacket = HPM->import_symbol("addPacket",plugin->idx); - plugin->hpi->addToSession = HPM->import_symbol("addToSession",plugin->idx); - plugin->hpi->getFromSession = HPM->import_symbol("getFromSession",plugin->idx); - plugin->hpi->removeFromSession = HPM->import_symbol("removeFromSession",plugin->idx); + plugin->hpi->addToHPData = HPM->import_symbol("addToHPData",plugin->idx); + plugin->hpi->getFromHPData = HPM->import_symbol("getFromHPData",plugin->idx); + plugin->hpi->removeFromHPData = HPM->import_symbol("removeFromHPData",plugin->idx); plugin->hpi->AddHook = HPM->import_symbol("AddHook",plugin->idx); plugin->hpi->HookStop = HPM->import_symbol("HookStop",plugin->idx); plugin->hpi->HookStopped = HPM->import_symbol("HookStopped",plugin->idx); @@ -311,67 +311,129 @@ CPCMD(plugins) { } } } +void hplugins_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) { + /* record address */ + switch( type ) { + 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: + ret->HPDataSRCPtr = NULL; + ret->hdatac = NULL; + return; + } +} +void hplugins_addToHPData(enum HPluginDataTypes type, unsigned int pluginID, void *ptr, void *data, unsigned int index, bool autofree) { + struct HPluginData *HPData, **HPDataSRC; + struct HPDataOperationStorage action; + unsigned int i, max; + + HPM->grabHPData(&action,type,ptr); -void hplugins_addToSession(struct socket_data *sess, void *data, unsigned int id, unsigned int type, bool autofree) { - struct HPluginData *HPData; - unsigned int i; + if( action.hdatac == NULL ) { /* woo it failed! */ + ShowError("HPM:addToHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index); + return; + } + + /* flag */ + HPDataSRC = *(action.HPDataSRCPtr); + max = *(action.hdatac); - for(i = 0; i < sess->hdatac; i++) { - if( sess->hdata[i]->pluginID == id && sess->hdata[i]->type == type ) { - ShowError("HPM->addToSession:%s: error! attempting to insert duplicate struct of id %u and type %u\n",HPM->pid2name(id),id,type); + /* duplicate check */ + for(i = 0; i < max; i++) { + if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) { + ShowError("HPM:addToHPData:%s: error! attempting to insert duplicate struct of id %u and index %u\n",HPM->pid2name(pluginID),pluginID,index); return; } } - //HPluginData is always same size, probably better to use the ERS + /* HPluginData is always same size, probably better to use the ERS (with reasonable chunk size e.g. 10/25/50) */ CREATE(HPData, struct HPluginData, 1); - HPData->pluginID = id; - HPData->type = type; + /* input */ + HPData->pluginID = pluginID; + HPData->type = index; HPData->flag.free = autofree ? 1 : 0; HPData->data = data; - RECREATE(sess->hdata,struct HPluginData *,++sess->hdatac); - sess->hdata[sess->hdatac - 1] = HPData; + /* resize */ + *(action.hdatac) += 1; + RECREATE(*(action.HPDataSRCPtr),struct HPluginData *,*(action.hdatac)); + + /* RECREATE modified the addresss */ + HPDataSRC = *(action.HPDataSRCPtr); + HPDataSRC[*(action.hdatac) - 1] = HPData; } -void *hplugins_getFromSession(struct socket_data *sess, unsigned int id, unsigned int type) { - unsigned int i; + +void *hplugins_getFromHPData(enum HPluginDataTypes type, unsigned int pluginID, void *ptr, unsigned int index) { + struct HPDataOperationStorage action; + struct HPluginData **HPDataSRC; + unsigned int i, max; - for(i = 0; i < sess->hdatac; i++) { - if( sess->hdata[i]->pluginID == id && sess->hdata[i]->type == type ) { - break; - } + HPM->grabHPData(&action,type,ptr); + + if( action.hdatac == NULL ) { /* woo it failed! */ + ShowError("HPM:getFromHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index); + return NULL; } - if( i != sess->hdatac ) - return sess->hdata[i]->data; + /* flag */ + HPDataSRC = *(action.HPDataSRCPtr); + max = *(action.hdatac); + for(i = 0; i < max; i++) { + if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) + return HPDataSRC[i]->data; + } + return NULL; } -void hplugins_removeFromSession(struct socket_data *sess, unsigned int id, unsigned int type) { - unsigned int i; + +void hplugins_removeFromHPData(enum HPluginDataTypes type, unsigned int pluginID, void *ptr, unsigned int index) { + struct HPDataOperationStorage action; + struct HPluginData **HPDataSRC; + unsigned int i, max; + + HPM->grabHPData(&action,type,ptr); - for(i = 0; i < sess->hdatac; i++) { - if( sess->hdata[i]->pluginID == id && sess->hdata[i]->type == type ) { + if( action.hdatac == NULL ) { /* woo it failed! */ + ShowError("HPM:removeFromHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index); + return; + } + + /* flag */ + HPDataSRC = *(action.HPDataSRCPtr); + max = *(action.hdatac); + + for(i = 0; i < max; i++) { + if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) break; - } } - if( i != sess->hdatac ) { + if( i != max ) { unsigned int cursor; - - aFree(sess->hdata[i]->data); - aFree(sess->hdata[i]); - sess->hdata[i] = NULL; - for(i = 0, cursor = 0; i < sess->hdatac; i++) { - if( sess->hdata[i] == NULL ) + aFree(HPDataSRC[i]->data);/* when its removed we delete it regardless of autofree */ + aFree(HPDataSRC[i]); + HPDataSRC[i] = NULL; + + for(i = 0, cursor = 0; i < max; i++) { + if( HPDataSRC[i] == NULL ) continue; if( i != cursor ) - sess->hdata[cursor] = sess->hdata[i]; + HPDataSRC[cursor] = HPDataSRC[i]; cursor++; } - sess->hdatac = cursor; + *(action.hdatac) = cursor; } } @@ -547,9 +609,9 @@ void hplugins_share_defaults(void) { #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); - HPM->share(hplugins_addToSession,"addToSession"); - HPM->share(hplugins_getFromSession,"getFromSession"); - HPM->share(hplugins_removeFromSession,"removeFromSession"); + HPM->share(hplugins_addToHPData,"addToHPData"); + HPM->share(hplugins_getFromHPData,"getFromHPData"); + HPM->share(hplugins_removeFromHPData,"removeFromHPData"); HPM->share(HPM_AddHook,"AddHook"); HPM->share(HPM_HookStop,"HookStop"); HPM->share(HPM_HookStopped,"HookStopped"); @@ -698,4 +760,6 @@ void hpm_defaults(void) { HPM->arg_db_clear_sub = hpm_arg_db_clear_sub; HPM->parse_arg = hpm_parse_arg; HPM->arg_help = hpm_arg_help; + HPM->grabHPData = hplugins_grabHPData; + HPM->grabHPDataSub = NULL; } diff --git a/src/common/HPM.h b/src/common/HPM.h index e685b3068..9a6bda713 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -82,6 +82,11 @@ struct HPMArgData { bool has_param;/* because of the weird "--arg<space>param" instead of the "--arg=param" */ }; +struct HPDataOperationStorage { + void **HPDataSRCPtr; + unsigned int *hdatac; +}; + /* Hercules Plugin Manager Interface */ struct HPM_interface { /* vars */ @@ -125,6 +130,9 @@ struct HPM_interface { bool (*parse_arg) (const char *arg, int* index, char *argv[], bool param); void (*arg_help) (void); 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); } HPM_s; struct HPM_interface *HPM; diff --git a/src/common/HPMi.h b/src/common/HPMi.h index f071bf09e..940782dce 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -77,6 +77,12 @@ enum HPluginHookType { HOOK_TYPE_POST, }; +enum HPluginDataTypes { + HPDT_SESSION, + HPDT_MSD, + HPDT_NPCD, +}; + #define addHookPre(tname,hook) HPMi->AddHook(HOOK_TYPE_PRE,tname,hook,HPMi->pid) #define addHookPost(tname,hook) HPMi->AddHook(HOOK_TYPE_POST,tname,hook,HPMi->pid) /* need better names ;/ */ @@ -85,6 +91,19 @@ enum HPluginHookType { #define hookStopped() HPMi->HookStopped() #define addArg(name,param,func,help) HPMi->addArg(HPMi->pid,name,param,func,help) +/* HPData handy redirects */ +/* session[] */ +#define addToSession(ptr,data,index,autofree) HPMi->addToHPData(HPDT_SESSION,HPMi->pid,ptr,data,index,autofree) +#define getFromSession(ptr,index) HPMi->getFromHPData(HPDT_SESSION,HPMi->pid,ptr,index) +#define removeFromSession(ptr,index) HPMi->removeFromHPData(HPDT_SESSION,HPMi->pid,ptr,index) +/* map_session_data */ +#define addToMSD(ptr,data,index,autofree) HPMi->addToHPData(HPDT_MSD,HPMi->pid,ptr,data,index,autofree) +#define getFromMSD(ptr,index) HPMi->getFromHPData(HPDT_MSD,HPMi->pid,ptr,index) +#define removeFromMSD(ptr,index) HPMi->removeFromHPData(HPDT_MSD,HPMi->pid,ptr,index) +/* npc_data */ +#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) /* Hercules Plugin Mananger Include Interface */ HPExport struct HPMi_interface { @@ -95,14 +114,10 @@ HPExport struct HPMi_interface { bool (*addCommand) (char *name, bool (*func)(const int fd, struct map_session_data* sd, const char* command, const char* message,struct AtCommandInfo *info)); bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st)); void (*addCPCommand) (char *name, CParseFunc func); - /* map_session_data */ - void (*addToMSD) (struct map_session_data *sd, void *data, unsigned int id, unsigned int type, bool autofree); - void *(*getFromMSD) (struct map_session_data *sd, unsigned int id, unsigned int type); - void (*removeFromMSD) (struct map_session_data *sd, unsigned int id, unsigned int type); - /* session[] */ - void (*addToSession) (struct socket_data *sess, void *data, unsigned int id, unsigned int type, bool autofree); - void *(*getFromSession) (struct socket_data *sess, unsigned int id, unsigned int type); - void (*removeFromSession) (struct socket_data *sess, unsigned int id, unsigned int type); + /* HPM Custom Data */ + void (*addToHPData) (enum HPluginDataTypes type, unsigned int pluginID, void *ptr, void *data, unsigned int index, bool autofree); + void *(*getFromHPData) (enum HPluginDataTypes type, unsigned int pluginID, void *ptr, unsigned int index); + void (*removeFromHPData) (enum HPluginDataTypes type, unsigned int pluginID, void *ptr, unsigned int index); /* packet */ bool (*addPacket) (unsigned short cmd, unsigned short length, void (*receive)(int fd), unsigned int point, unsigned int pluginID); /* Hooking */ diff --git a/src/common/socket.c b/src/common/socket.c index c66153550..6e877d9be 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -613,8 +613,8 @@ static void delete_session(int fd) for(i = 0; i < session[fd]->hdatac; i++) { if( session[fd]->hdata[i]->flag.free ) { aFree(session[fd]->hdata[i]->data); - aFree(session[fd]->hdata[i]); } + aFree(session[fd]->hdata[i]); } if( session[fd]->hdata ) aFree(session[fd]->hdata); diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 8a69cba97..8d7c74ef2 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -46,76 +46,27 @@ struct HPM_atcommand_list { struct HPM_atcommand_list *atcommand_list = NULL; unsigned int atcommand_list_items = 0; -void HPM_map_addToMSD(struct map_session_data *sd, void *data, unsigned int id, unsigned int type, bool autofree) { - struct HPluginData *HPData; - unsigned int i; - - for(i = 0; i < sd->hdatac; i++) { - if( sd->hdata[i]->pluginID == id && sd->hdata[i]->type == type ) { - ShowError("HPMi->addToMSD:%s: error! attempting to insert duplicate struct of type %u on '%s'\n",HPM->pid2name(id),type,sd->status.name); - return; - } - } - - CREATE(HPData, struct HPluginData, 1); - - HPData->pluginID = id; - HPData->type = type; - HPData->flag.free = autofree ? 1 : 0; - HPData->data = data; - - RECREATE(sd->hdata,struct HPluginData *,++sd->hdatac); - sd->hdata[sd->hdatac - 1] = HPData; -} -void *HPM_map_getFromMSD(struct map_session_data *sd, unsigned int id, unsigned int type) { - unsigned int i; - - for(i = 0; i < sd->hdatac; i++) { - if( sd->hdata[i]->pluginID == id && sd->hdata[i]->type == type ) { +void HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) { + /* record address */ + switch( type ) { + case HPDT_MSD: + ret->HPDataSRCPtr = (void**)(&((struct map_session_data *)ptr)->hdata); + ret->hdatac = &((struct map_session_data *)ptr)->hdatac; break; - } - } - - if( i != sd->hdatac ) - return sd->hdata[i]->data; - - return NULL; -} -void HPM_map_removeFromMSD(struct map_session_data *sd, unsigned int id, unsigned int type) { - unsigned int i; - - for(i = 0; i < sd->hdatac; i++) { - if( sd->hdata[i]->pluginID == id && sd->hdata[i]->type == type ) { + case HPDT_NPCD: + ret->HPDataSRCPtr = (void**)(&((struct npc_data *)ptr)->hdata); + ret->hdatac = &((struct npc_data *)ptr)->hdatac; break; - } - } - - if( i != sd->hdatac ) { - unsigned int cursor; - - aFree(sd->hdata[i]->data); - aFree(sd->hdata[i]); - sd->hdata[i] = NULL; - - for(i = 0, cursor = 0; i < sd->hdatac; i++) { - if( sd->hdata[i] == NULL ) - continue; - if( i != cursor ) - sd->hdata[cursor] = sd->hdata[i]; - cursor++; - } - - sd->hdatac = cursor; + default: + ret->HPDataSRCPtr = NULL; + ret->hdatac = NULL; + return; } - } + void HPM_map_plugin_load_sub(struct hplugin *plugin) { - plugin->hpi->addCommand = HPM->import_symbol("addCommand",plugin->idx); - plugin->hpi->addScript = HPM->import_symbol("addScript",plugin->idx); - /* */ - plugin->hpi->addToMSD = HPM->import_symbol("addToMSD",plugin->idx); - plugin->hpi->getFromMSD = HPM->import_symbol("getFromMSD",plugin->idx); - plugin->hpi->removeFromMSD = HPM->import_symbol("removeFromMSD",plugin->idx); + plugin->hpi->addCommand = HPM->import_symbol("addCommand",plugin->idx); + plugin->hpi->addScript = HPM->import_symbol("addScript",plugin->idx); } bool HPM_map_add_atcommand(char *name, AtCommandFunc func) { diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h index 96515772b..f5fe70276 100644 --- a/src/map/HPMmap.h +++ b/src/map/HPMmap.h @@ -6,13 +6,12 @@ #include "../common/cbasetypes.h" #include "../map/atcommand.h" +#include "../common/HPM.h" struct hplugin; struct map_session_data; -void HPM_map_addToMSD(struct map_session_data *sd, void *data, unsigned int id, unsigned int type, bool autofree); -void *HPM_map_getFromMSD(struct map_session_data *sd, unsigned int id, unsigned int type); -void HPM_map_removeFromMSD(struct map_session_data *sd, unsigned int id, unsigned int type); +void HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); bool HPM_map_add_atcommand(char *name, AtCommandFunc func); void HPM_map_atcommands(void); diff --git a/src/map/map.c b/src/map/map.c index 3469a60ce..b846d6125 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5372,9 +5372,6 @@ void map_hp_symbols(void) { /* specific */ HPM->share(atcommand->create,"addCommand"); HPM->share(script->addScript,"addScript"); - HPM->share(HPM_map_addToMSD,"addToMSD"); - HPM->share(HPM_map_getFromMSD,"getFromMSD"); - HPM->share(HPM_map_removeFromMSD,"removeFromMSD"); /* vars */ HPM->share(map->list,"map->list"); } @@ -5436,6 +5433,7 @@ int do_init(int argc, char *argv[]) HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; + HPM->grabHPDataSub = HPM_map_grabHPData; HPM->config_read(); HPM->event(HPET_PRE_INIT); diff --git a/src/map/npc.c b/src/map/npc.c index 5ca96d587..effc36a4e 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1763,6 +1763,8 @@ void npc_unload_duplicates(struct npc_data* nd) { //Removes an npc from map and db. //Single is to free name (for duplicates). int npc_unload(struct npc_data* nd, bool single) { + unsigned int i; + nullpo_ret(nd); npc->remove_map(nd); @@ -1850,6 +1852,15 @@ int npc_unload(struct npc_data* nd, bool single) { nd->ud = NULL; } + for( i = 0; i < nd->hdatac; i++ ) { + if( nd->hdata[i]->flag.free ) { + aFree(nd->hdata[i]->data); + } + aFree(nd->hdata[i]); + } + if( nd->hdata ) + aFree(nd->hdata); + aFree(nd); return 0; diff --git a/src/map/npc.h b/src/map/npc.h index 10f3406b4..33be957fb 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -5,6 +5,8 @@ #ifndef _NPC_H_ #define _NPC_H_ +#include "../common/HPM.h" //struct HPluginData + #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data @@ -74,10 +76,12 @@ struct npc_data { char killer_name[NAME_LENGTH]; } tomb; } u; + /* HPData Support for npc_data */ + struct HPluginData **hdata; + unsigned int hdatac; }; - #define START_NPC_NUM 110000000 enum actor_classes { diff --git a/src/map/unit.c b/src/map/unit.c index eed9fe3be..04af6c117 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2397,8 +2397,8 @@ int unit_free(struct block_list *bl, clr_type clrtype) { for( k = 0; k < sd->hdatac; k++ ) { if( sd->hdata[k]->flag.free ) { aFree(sd->hdata[k]->data); - aFree(sd->hdata[k]); } + aFree(sd->hdata[k]); } if( sd->hdata ) aFree(sd->hdata); diff --git a/src/plugins/sample.c b/src/plugins/sample.c index d1a95c71d..cffd39992 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -48,7 +48,7 @@ void sample_packet0f3(int fd) { ShowInfo("sample_packet0f3: Hello World! received 0xf3 for '%s', redirecting!\n",sd->status.name); /* sample usage of appending data to a socket_data (session[]) entry */ - if( !(data = HPMi->getFromSession(session[fd],HPMi->pid,0)) ) { + if( !(data = getFromSession(session[fd],0)) ) { CREATE(data,struct sample_data_struct,1); data->lastMSGPosition.map = sd->status.last_point.map; @@ -57,17 +57,17 @@ void sample_packet0f3(int fd) { data->someNumber = rand()%777; ShowInfo("Created Appended session[] data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); - HPMi->addToSession(session[fd],data,HPMi->pid,0,true); + addToSession(session[fd],data,0,true); } else { ShowInfo("Existent Appended session[] data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); if( rand()%4 == 2 ) { ShowInfo("Removing Appended session[] data\n"); - HPMi->removeFromSession(session[fd],HPMi->pid,0); + removeFromSession(session[fd],0); } } /* sample usage of appending data to a map_session_data (sd) entry */ - if( !(data = HPMi->getFromMSD(sd,HPMi->pid,0)) ) { + if( !(data = getFromMSD(sd,0)) ) { CREATE(data,struct sample_data_struct,1); data->lastMSGPosition.map = sd->status.last_point.map; @@ -76,12 +76,12 @@ void sample_packet0f3(int fd) { data->someNumber = rand()%777; ShowInfo("Created Appended map_session_data data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); - HPMi->addToMSD(sd,data,HPMi->pid,0,true); + addToMSD(sd,data,0,true); } else { ShowInfo("Existent Appended map_session_data data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); if( rand()%4 == 2 ) { ShowInfo("Removing Appended map_session_data data\n"); - HPMi->removeFromMSD(sd,HPMi->pid,0); + removeFromMSD(sd,0); } } @@ -124,7 +124,7 @@ HPExport void plugin_init (void) { script = GET_SYMBOL("script"); clif = GET_SYMBOL("clif"); pc = GET_SYMBOL("pc"); - + /* session[] */ session = GET_SYMBOL("session"); |