diff options
Diffstat (limited to 'src/map/HPMmap.c')
-rw-r--r-- | src/map/HPMmap.c | 81 |
1 files changed, 16 insertions, 65 deletions
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) { |