summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-11 16:11:43 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-11 16:11:43 +0300
commit6c0f05b05e9bf09f40df3e3fe7f768f7435abcec (patch)
tree6973517e1821f128b36955fc258419131b98f7fc /src/map
parentd70d9d4d19f0deae2a2aceb047872611d5047ae0 (diff)
parent845139091f0305d264800491ce25152856c20374 (diff)
downloadhercules-6c0f05b05e9bf09f40df3e3fe7f768f7435abcec.tar.gz
hercules-6c0f05b05e9bf09f40df3e3fe7f768f7435abcec.tar.bz2
hercules-6c0f05b05e9bf09f40df3e3fe7f768f7435abcec.tar.xz
hercules-6c0f05b05e9bf09f40df3e3fe7f768f7435abcec.zip
Merge pull request #760 from HerculesWS/738-vectors
Change several variable-size array to VECTOR (common, char)
Diffstat (limited to 'src/map')
-rw-r--r--src/map/HPMmap.c52
-rw-r--r--src/map/HPMmap.h2
-rw-r--r--src/map/battleground.c14
-rw-r--r--src/map/battleground.h6
-rw-r--r--src/map/chrif.c22
-rw-r--r--src/map/clif.c12
-rw-r--r--src/map/guild.c23
-rw-r--r--src/map/instance.c14
-rw-r--r--src/map/instance.h7
-rw-r--r--src/map/itemdb.c12
-rw-r--r--src/map/itemdb.h6
-rw-r--r--src/map/map.c11
-rw-r--r--src/map/map.h6
-rw-r--r--src/map/mob.c11
-rw-r--r--src/map/mob.h13
-rw-r--r--src/map/npc.c11
-rw-r--r--src/map/npc.h6
-rw-r--r--src/map/party.c23
-rw-r--r--src/map/party.h7
-rw-r--r--src/map/path.c2
-rw-r--r--src/map/pc.c20
-rw-r--r--src/map/pc.h9
-rw-r--r--src/map/unit.c24
23 files changed, 67 insertions, 246 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index ac78e8c84..edbe74039 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -85,57 +85,31 @@ struct HPM_atcommand_list {
struct HPM_atcommand_list *atcommand_list = NULL;
unsigned int atcommand_list_items = 0;
-bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
- /* record address */
- switch( type ) {
+/**
+ * HPM plugin data store validator sub-handler (map-server)
+ *
+ * @see HPM_interface::data_store_validate
+ */
+bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize)
+{
+ switch (type) {
case HPDT_MSD:
- ret->HPDataSRCPtr = (void**)(&((struct map_session_data *)ptr)->hdata);
- ret->hdatac = &((struct map_session_data *)ptr)->hdatac;
- break;
case HPDT_NPCD:
- ret->HPDataSRCPtr = (void**)(&((struct npc_data *)ptr)->hdata);
- ret->hdatac = &((struct npc_data *)ptr)->hdatac;
- break;
case HPDT_MAP:
- ret->HPDataSRCPtr = (void**)(&((struct map_data *)ptr)->hdata);
- ret->hdatac = &((struct map_data *)ptr)->hdatac;
- break;
case HPDT_PARTY:
- ret->HPDataSRCPtr = (void**)(&((struct party_data *)ptr)->hdata);
- ret->hdatac = &((struct party_data *)ptr)->hdatac;
- break;
case HPDT_GUILD:
- ret->HPDataSRCPtr = (void**)(&((struct guild *)ptr)->hdata);
- ret->hdatac = &((struct guild *)ptr)->hdatac;
- break;
case HPDT_INSTANCE:
- ret->HPDataSRCPtr = (void**)(&((struct instance_data *)ptr)->hdata);
- ret->hdatac = &((struct instance_data *)ptr)->hdatac;
- break;
case HPDT_MOBDB:
- ret->HPDataSRCPtr = (void**)(&((struct mob_db *)ptr)->hdata);
- ret->hdatac = &((struct mob_db *)ptr)->hdatac;
- break;
case HPDT_MOBDATA:
- ret->HPDataSRCPtr = (void**)(&((struct mob_data *)ptr)->hdata);
- ret->hdatac = &((struct mob_data *)ptr)->hdatac;
- break;
case HPDT_ITEMDATA:
- ret->HPDataSRCPtr = (void**)(&((struct item_data *)ptr)->hdata);
- ret->hdatac = &((struct item_data *)ptr)->hdatac;
- break;
case HPDT_BGDATA:
- ret->HPDataSRCPtr = (void**)(&((struct battleground_data *)ptr)->hdata);
- ret->hdatac = &((struct battleground_data *)ptr)->hdatac;
- break;
case HPDT_AUTOTRADE_VEND:
- ret->HPDataSRCPtr = (void**)(&((struct autotrade_vending *)ptr)->hdata);
- ret->hdatac = &((struct autotrade_vending *)ptr)->hdatac;
- break;
+ // Initialized by the caller.
+ return true;
default:
- return false;
+ break;
}
- return true;
+ return false;
}
void HPM_map_plugin_load_sub(struct hplugin *plugin) {
@@ -188,7 +162,7 @@ void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned in
void HPM_map_do_init(void) {
HPM->load_sub = HPM_map_plugin_load_sub;
- HPM->grabHPDataSub = HPM_map_grabHPData;
+ HPM->data_store_validate_sub = HPM_map_data_store_validate;
HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
HPM_shared_symbols(SERVER_TYPE_MAP);
}
diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h
index 00a8f43c3..b1957b139 100644
--- a/src/map/HPMmap.h
+++ b/src/map/HPMmap.h
@@ -15,7 +15,7 @@
struct hplugin;
struct map_session_data;
-bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
+bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize);
bool HPM_map_add_atcommand(char *name, AtCommandFunc func);
void HPM_map_atcommands(void);
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 5df05d301..be6b7a863 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -880,17 +880,9 @@ void do_init_battleground(bool minimal) {
*/
int bg_team_db_final(DBKey key, DBData *data, va_list ap) {
struct battleground_data* bgd = DB->data2ptr(data);
- int i;
- nullpo_ret(bgd);
- for(i = 0; i < bgd->hdatac; i++ ) {
- if( bgd->hdata[i]->flag.free ) {
- aFree(bgd->hdata[i]->data);
- }
- aFree(bgd->hdata[i]);
- }
- if( bgd->hdata )
- aFree(bgd->hdata);
-
+
+ HPM->data_store_destroy(&bgd->hdata);
+
return 0;
}
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 094037f43..dcf92d6d8 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -10,7 +10,7 @@
#include "common/db.h"
#include "common/mmo.h" // struct party
-struct HPluginData;
+struct hplugin_data_store;
struct block_list;
struct map_session_data;
@@ -53,9 +53,7 @@ struct battleground_data {
// Logout Event
char logout_event[EVENT_NAME_LENGTH];
char die_event[EVENT_NAME_LENGTH];
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
struct bg_arena {
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 1e376e3bc..a27038ff7 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1351,7 +1351,7 @@ void chrif_skillid2idx(int fd) {
*
*------------------------------------------*/
int chrif_parse(int fd) {
- int packet_len, cmd, r;
+ int packet_len, cmd;
// only process data from the char-server
if ( fd != chrif->fd ) {
@@ -1375,22 +1375,22 @@ int chrif_parse(int fd) {
}
}
- while ( RFIFOREST(fd) >= 2 ) {
-
- if( HPM->packetsc[hpChrif_Parse] ) {
- if( (r = HPM->parse_packets(fd,hpChrif_Parse)) ) {
- if( r == 1 ) continue;
- if( r == 2 ) return 0;
- }
+ while (RFIFOREST(fd) >= 2) {
+ if (VECTOR_LENGTH(HPM->packets[hpChrif_Parse]) > 0) {
+ int result = HPM->parse_packets(fd,hpChrif_Parse);
+ if (result == 1)
+ continue;
+ if (result == 2)
+ return 0;
}
cmd = RFIFOW(fd,0);
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) {
- r = intif->parse(fd); // Passed on to the intif
+ int result = intif->parse(fd); // Passed on to the intif
- if (r == 1) continue; // Treated in intif
- if (r == 2) return 0; // Didn't have enough data (len==-1)
+ if (result == 1) continue; // Treated in intif
+ if (result == 2) return 0; // Didn't have enough data (len==-1)
ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
sockt->eof(fd);
diff --git a/src/map/clif.c b/src/map/clif.c
index 59c8a7197..9c7d327e6 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -18578,12 +18578,12 @@ int clif_parse(int fd) {
if (RFIFOREST(fd) < 2)
return 0;
- if( HPM->packetsc[hpClif_Parse] ) {
- int r;
- if( (r = HPM->parse_packets(fd,hpClif_Parse)) ) {
- if( r == 1 ) continue;
- if( r == 2 ) return 0;
- }
+ if (VECTOR_LENGTH(HPM->packets[hpClif_Parse]) > 0) {
+ int result = HPM->parse_packets(fd,hpClif_Parse);
+ if (result == 1)
+ continue;
+ if (result == 2)
+ return 0;
}
if( sd )
diff --git a/src/map/guild.c b/src/map/guild.c
index 7a187b625..f8798f821 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -1763,16 +1763,7 @@ int guild_broken(int guild_id,int flag)
if( g->instance )
aFree(g->instance);
- if( g->hdata )
- {
- for( i = 0; i < g->hdatac; i++ ) {
- if( g->hdata[i]->flag.free ) {
- aFree(g->hdata[i]->data);
- }
- aFree(g->hdata[i]);
- }
- aFree(g->hdata);
- }
+ HPM->data_store_destroy(&g->hdata);
idb_remove(guild->db,guild_id);
return 0;
@@ -2250,7 +2241,6 @@ void do_init_guild(bool minimal) {
void do_final_guild(void) {
DBIterator *iter = db_iterator(guild->db);
struct guild *g;
- int i;
for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) {
if( g->channel != NULL )
@@ -2259,16 +2249,7 @@ void do_final_guild(void) {
aFree(g->instance);
g->instance = NULL;
}
- if( g->hdata )
- {
- for( i = 0; i < g->hdatac; i++ ) {
- if( g->hdata[i]->flag.free ) {
- aFree(g->hdata[i]->data);
- }
- aFree(g->hdata[i]);
- }
- aFree(g->hdata);
- }
+ HPM->data_store_destroy(&g->hdata);
}
dbi_destroy(iter);
diff --git a/src/map/instance.c b/src/map/instance.c
index 300247fe7..0936a5ace 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -588,19 +588,7 @@ void instance_destroy(int instance_id) {
instance->list[instance_id].state = INSTANCE_FREE;
instance->list[instance_id].num_map = 0;
- if (instance->list[instance_id].hdata)
- {
- for( j = 0; j < instance->list[instance_id].hdatac; j++ ) {
- if( instance->list[instance_id].hdata[j]->flag.free ) {
- aFree(instance->list[instance_id].hdata[j]->data);
- }
- aFree(instance->list[instance_id].hdata[j]);
- }
- aFree(instance->list[instance_id].hdata);
- }
-
- instance->list[instance_id].hdata = NULL;
- instance->list[instance_id].hdatac = 0;
+ HPM->data_store_destroy(&instance->list[instance_id].hdata);
}
/*--------------------------------------
diff --git a/src/map/instance.h b/src/map/instance.h
index 589e1a511..058cd2c3d 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -9,7 +9,7 @@
#include "common/hercules.h"
#include "common/mmo.h" // struct point
-struct HPluginData;
+struct hplugin_data_store;
struct block_list;
struct map_session_data;
@@ -52,10 +52,7 @@ struct instance_data {
unsigned int original_progress_timeout;
struct point respawn; ///< reload spawn
-
- /** HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
struct instance_interface {
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index ccedee72a..ccfff2246 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2100,17 +2100,7 @@ void destroy_item_data(struct item_data* self, int free_self)
script->free_code(self->unequip_script);
if( self->combos )
aFree(self->combos);
- if (self->hdata)
- {
- int i;
- for (i = 0; i < self->hdatac; i++ ) {
- if (self->hdata[i]->flag.free ) {
- aFree(self->hdata[i]->data);
- }
- aFree(self->hdata[i]);
- }
- aFree(self->hdata);
- }
+ HPM->data_store_destroy(&self->hdata);
#if defined(DEBUG)
// trash item
memset(self, 0xDD, sizeof(struct item_data));
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index a3edd451e..64b800b87 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -13,6 +13,7 @@
#include "common/sql.h"
struct script_code;
+struct hplugin_data_store;
/**
* Defines
@@ -488,10 +489,7 @@ struct item_data {
/* TODO add a pointer to some sort of (struct extra) and gather all the not-common vals into it to save memory */
struct item_group *group;
struct item_package *package;
-
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
#define itemdb_name(n) (itemdb->search(n)->name)
diff --git a/src/map/map.c b/src/map/map.c
index e01a25366..b142ed1f3 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3239,16 +3239,7 @@ void do_final_maps(void) {
if( map->list[i].qi_data )
aFree(map->list[i].qi_data);
- if( map->list[i].hdata )
- {
- for( v = 0; v < map->list[i].hdatac; v++ ) {
- if( map->list[i].hdata[v]->flag.free ) {
- aFree(map->list[i].hdata[v]->data);
- }
- aFree(map->list[i].hdata[v]);
- }
- aFree(map->list[i].hdata);
- }
+ HPM->data_store_destroy(&map->list[i].hdata);
}
map->zone_db_clear();
diff --git a/src/map/map.h b/src/map/map.h
index 3ac39e54f..961a45793 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -19,6 +19,7 @@
struct mob_data;
struct npc_data;
struct channel_data;
+struct hplugin_data_store;
enum E_MAPSERVER_ST {
MAPSERVER_ST_RUNNING = CORE_ST_LAST,
@@ -736,10 +737,7 @@ struct map_data {
/* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
unsigned short hpmeter_visible;
-
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
/// Stores information about a remote map (for multi-mapserver setups).
diff --git a/src/map/mob.c b/src/map/mob.c
index 2fe9fe8fb..01f585b6f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4708,16 +4708,7 @@ int do_init_mob(bool minimal) {
void mob_destroy_mob_db(int index)
{
struct mob_db *data = mob->db_data[index];
- if (data->hdata) {
- int i;
- for (i = 0; i < data->hdatac; i++) {
- if (data->hdata[i]->flag.free ) {
- aFree(data->hdata[i]->data);
- }
- aFree(data->hdata[i]);
- }
- aFree(data->hdata);
- }
+ HPM->data_store_destroy(&data->hdata);
aFree(data);
mob->db_data[index] = NULL;
}
diff --git a/src/map/mob.h b/src/map/mob.h
index 4b8a054b5..bb26258c6 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -11,6 +11,8 @@
#include "common/hercules.h"
#include "common/mmo.h" // struct item
+struct hplugin_data_store;
+
#define MAX_RANDOMMONSTER 5
// Change this to increase the table size in your mob_db to accommodate a larger mob database.
@@ -138,10 +140,7 @@ struct mob_db {
int maxskill;
struct mob_skill skill[MAX_MOBSKILL];
struct spawn_info spawn[10];
-
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
struct mob_data {
@@ -208,14 +207,10 @@ struct mob_data {
* MvP Tombstone NPC ID
**/
int tomb_nid;
-
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
-
enum {
MST_TARGET = 0,
MST_RANDOM, //Random Target!
diff --git a/src/map/npc.c b/src/map/npc.c
index a0c14a058..24b22beb3 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2321,16 +2321,7 @@ int npc_unload(struct npc_data* nd, bool single)
nd->ud = NULL;
}
- if (nd->hdata) {
- unsigned int i;
- for (i = 0; i < nd->hdatac; i++) {
- if (nd->hdata[i]->flag.free) {
- aFree(nd->hdata[i]->data);
- }
- aFree(nd->hdata[i]);
- }
- aFree(nd->hdata);
- }
+ HPM->data_store_destroy(&nd->hdata);
aFree(nd);
diff --git a/src/map/npc.h b/src/map/npc.h
index 14b89d128..bf3d1494d 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -11,7 +11,7 @@
#include "common/hercules.h"
#include "common/db.h"
-struct HPluginData;
+struct hplugin_data_store;
struct view_data;
enum npc_parse_options {
@@ -102,9 +102,7 @@ struct npc_data {
char killer_name[NAME_LENGTH];
} tomb;
} u;
- /* HPData Support for npc_data */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
diff --git a/src/map/party.c b/src/map/party.c
index db285a4b4..f7e7d431c 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -103,16 +103,7 @@ int party_db_final(DBKey key, DBData *data, va_list ap) {
if (p->instance)
aFree(p->instance);
- if (p->hdata) {
- int i;
- for (i = 0; i < p->hdatac; i++) {
- if (p->hdata[i]->flag.free) {
- aFree(p->hdata[i]->data);
- }
- aFree(p->hdata[i]);
- }
- aFree(p->hdata);
- }
+ HPM->data_store_destroy(&p->hdata);
}
return 0;
}
@@ -608,16 +599,8 @@ int party_broken(int party_id)
if( p->instance )
aFree(p->instance);
- if( p->hdata )
- {
- for( j = 0; j < p->hdatac; j++ ) {
- if( p->hdata[j]->flag.free ) {
- aFree(p->hdata[j]->data);
- }
- aFree(p->hdata[j]);
- }
- aFree(p->hdata);
- }
+ HPM->data_store_destroy(&p->hdata);
+
idb_remove(party->db,party_id);
return 0;
}
diff --git a/src/map/party.h b/src/map/party.h
index c7893add2..df7c03f05 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -15,7 +15,7 @@
#define PARTY_BOOKING_JOBS 6
#define PARTY_BOOKING_RESULTS 10
-struct HPluginData;
+struct hplugin_data_store;
struct party_member_data {
struct map_session_data *sd;
@@ -35,10 +35,7 @@ struct party_data {
unsigned snovice :1; ///< There's a Super Novice
unsigned tk : 1; ///< There's a taekwon
} state;
-
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
#define PB_NOTICE_LENGTH (36 + 1)
diff --git a/src/map/path.c b/src/map/path.c
index a482fc473..29701d445 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -45,7 +45,7 @@ struct path_node {
};
/// Binary heap of path nodes
-BHEAP_STRUCT_DECL(node_heap, struct path_node*);
+BHEAP_STRUCT_DECL(node_heap, struct path_node *);
/// Comparator for binary heap of path nodes (minimum cost at top)
#define NODE_MINTOPCMP(i,j) ((i)->f_cost - (j)->f_cost)
diff --git a/src/map/pc.c b/src/map/pc.c
index dc7014701..99f5b867e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -11332,14 +11332,7 @@ void pc_autotrade_populate(struct map_session_data *sd) {
pc->autotrade_update(sd,PAUC_START);
- for(i = 0; i < data->hdatac; i++ ) {
- if( data->hdata[i]->flag.free ) {
- aFree(data->hdata[i]->data);
- }
- aFree(data->hdata[i]);
- }
- if( data->hdata )
- aFree(data->hdata);
+ HPM->data_store_destroy(&data->hdata);
idb_remove(pc->at_db, sd->status.char_id);
}
@@ -11349,16 +11342,7 @@ void pc_autotrade_populate(struct map_session_data *sd) {
*/
int pc_autotrade_final(DBKey key, DBData *data, va_list ap) {
struct autotrade_vending* at_v = DB->data2ptr(data);
- int i;
- for(i = 0; i < at_v->hdatac; i++ ) {
- if( at_v->hdata[i]->flag.free ) {
- aFree(at_v->hdata[i]->data);
- }
- aFree(at_v->hdata[i]);
- }
- if( at_v->hdata )
- aFree(at_v->hdata);
-
+ HPM->data_store_destroy(&at_v->hdata);
return 0;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index e6e95978d..2c8b24acf 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -539,10 +539,7 @@ END_ZEROED_BLOCK;
unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd); ///< parse_cmd_func used by this player
unsigned char delayed_damage;//ref. counter bugreport:7307 [Ind/Hercules]
-
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
/* expiration_time timer id */
int expiration_tid;
@@ -757,9 +754,7 @@ struct autotrade_vending {
struct item list[MAX_VENDING];
struct s_vending vending[MAX_VENDING];
unsigned char vend_num;
- /* HPM Custom Struct */
- struct HPluginData **hdata;
- unsigned int hdatac;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
/*=====================================
diff --git a/src/map/unit.c b/src/map/unit.c
index 04a8befc2..dcb5ec900 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2654,17 +2654,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
sd->quest_log = NULL;
sd->num_quests = sd->avail_quests = 0;
}
-
- if (sd->hdata) {
- unsigned int k;
- 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);
- }
+ HPM->data_store_destroy(&sd->hdata);
break;
}
case BL_PET:
@@ -2775,17 +2765,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
if( md->tomb_nid )
mob->mvptomb_destroy(md);
- if (md->hdata)
- {
- unsigned int k;
- for (k = 0; k < md->hdatac; k++) {
- if( md->hdata[k]->flag.free ) {
- aFree(md->hdata[k]->data);
- }
- aFree(md->hdata[k]);
- }
- aFree(md->hdata);
- }
+ HPM->data_store_destroy(&md->hdata);
break;
}
case BL_HOM: