summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-09-26 04:11:41 +0200
committerHaru <haru@dotalux.com>2015-10-11 00:24:22 +0200
commit657e7f9c07bc1445ce785cd11772664a1848ea5a (patch)
treeb0b6ce19dfd5946fe6a0cf6c33eac78e357d4832 /src/map
parent70265291d62280c525adc317158e9f531e0147ff (diff)
downloadhercules-657e7f9c07bc1445ce785cd11772664a1848ea5a.tar.gz
hercules-657e7f9c07bc1445ce785cd11772664a1848ea5a.tar.bz2
hercules-657e7f9c07bc1445ce785cd11772664a1848ea5a.tar.xz
hercules-657e7f9c07bc1445ce785cd11772664a1848ea5a.zip
Cleanup of the HPluginData implementation (second part)
- Changed the hplugin_data_store's array into a VECTOR. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/HPMmap.c6
-rw-r--r--src/map/HPMmap.h2
-rw-r--r--src/map/battleground.c3
-rw-r--r--src/map/battleground.h3
-rw-r--r--src/map/guild.c6
-rw-r--r--src/map/instance.c3
-rw-r--r--src/map/instance.h4
-rw-r--r--src/map/itemdb.c3
-rw-r--r--src/map/itemdb.h4
-rw-r--r--src/map/map.c3
-rw-r--r--src/map/map.h4
-rw-r--r--src/map/mob.c3
-rw-r--r--src/map/mob.h8
-rw-r--r--src/map/npc.c3
-rw-r--r--src/map/npc.h3
-rw-r--r--src/map/party.c6
-rw-r--r--src/map/party.h4
-rw-r--r--src/map/pc.c6
-rw-r--r--src/map/pc.h7
-rw-r--r--src/map/unit.c9
20 files changed, 27 insertions, 63 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index ddffb5519..edbe74039 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -90,7 +90,7 @@ unsigned int atcommand_list_items = 0;
*
* @see HPM_interface::data_store_validate
*/
-bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **store)
+bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize)
{
switch (type) {
case HPDT_MSD:
@@ -104,9 +104,7 @@ bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data
case HPDT_ITEMDATA:
case HPDT_BGDATA:
case HPDT_AUTOTRADE_VEND:
- if (!*store) {
- *store = HPM->data_store_create();
- }
+ // Initialized by the caller.
return true;
default:
break;
diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h
index 10bdf0ba7..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_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **store);
+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 46d695272..be6b7a863 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -881,8 +881,7 @@ 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);
- HPM->data_store_destroy(bgd->hdata);
- bgd->hdata = NULL;
+ HPM->data_store_destroy(&bgd->hdata);
return 0;
}
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 0280407a2..dcf92d6d8 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -53,8 +53,7 @@ struct battleground_data {
// Logout Event
char logout_event[EVENT_NAME_LENGTH];
char die_event[EVENT_NAME_LENGTH];
- /* HPM Custom Struct */
- struct hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
struct bg_arena {
diff --git a/src/map/guild.c b/src/map/guild.c
index 2dca97502..f8798f821 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -1763,8 +1763,7 @@ int guild_broken(int guild_id,int flag)
if( g->instance )
aFree(g->instance);
- HPM->data_store_destroy(g->hdata);
- g->hdata = NULL;
+ HPM->data_store_destroy(&g->hdata);
idb_remove(guild->db,guild_id);
return 0;
@@ -2250,8 +2249,7 @@ void do_final_guild(void) {
aFree(g->instance);
g->instance = NULL;
}
- HPM->data_store_destroy(g->hdata);
- g->hdata = NULL;
+ HPM->data_store_destroy(&g->hdata);
}
dbi_destroy(iter);
diff --git a/src/map/instance.c b/src/map/instance.c
index 7213c43a1..0936a5ace 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -588,8 +588,7 @@ void instance_destroy(int instance_id) {
instance->list[instance_id].state = INSTANCE_FREE;
instance->list[instance_id].num_map = 0;
- HPM->data_store_destroy(instance->list[instance_id].hdata);
- instance->list[instance_id].hdata = NULL;
+ HPM->data_store_destroy(&instance->list[instance_id].hdata);
}
/*--------------------------------------
diff --git a/src/map/instance.h b/src/map/instance.h
index f879195ef..058cd2c3d 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -52,9 +52,7 @@ struct instance_data {
unsigned int original_progress_timeout;
struct point respawn; ///< reload spawn
-
- /** HPM Custom Struct */
- struct hplugin_data_store *hdata;
+ 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 c531a4d7a..ccfff2246 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2100,8 +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);
- HPM->data_store_destroy(self->hdata);
- self->hdata = NULL;
+ 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 de9770aab..64b800b87 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -489,9 +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 hplugin_data_store *hdata;
+ 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 0ed7072d2..b142ed1f3 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3239,8 +3239,7 @@ void do_final_maps(void) {
if( map->list[i].qi_data )
aFree(map->list[i].qi_data);
- HPM->data_store_destroy(map->list[i].hdata);
- map->list[i].hdata = NULL;
+ 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 c3e426bb6..961a45793 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -737,9 +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 hplugin_data_store *hdata;
+ 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 174d2e49f..01f585b6f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4708,8 +4708,7 @@ int do_init_mob(bool minimal) {
void mob_destroy_mob_db(int index)
{
struct mob_db *data = mob->db_data[index];
- HPM->data_store_destroy(data->hdata);
- data->hdata = NULL;
+ 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 1142502f4..bb26258c6 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -140,9 +140,7 @@ struct mob_db {
int maxskill;
struct mob_skill skill[MAX_MOBSKILL];
struct spawn_info spawn[10];
-
- /* HPM Custom Struct */
- struct hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
struct mob_data {
@@ -209,9 +207,7 @@ struct mob_data {
* MvP Tombstone NPC ID
**/
int tomb_nid;
-
- /* HPM Custom Struct */
- struct hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
diff --git a/src/map/npc.c b/src/map/npc.c
index 85de5301b..24b22beb3 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2321,8 +2321,7 @@ int npc_unload(struct npc_data* nd, bool single)
nd->ud = NULL;
}
- HPM->data_store_destroy(nd->hdata);
- nd->hdata = NULL;
+ HPM->data_store_destroy(&nd->hdata);
aFree(nd);
diff --git a/src/map/npc.h b/src/map/npc.h
index 06aee3f93..bf3d1494d 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -102,8 +102,7 @@ struct npc_data {
char killer_name[NAME_LENGTH];
} tomb;
} u;
- /* HPData Support for npc_data */
- struct hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
diff --git a/src/map/party.c b/src/map/party.c
index 4735dfc42..f7e7d431c 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -103,8 +103,7 @@ int party_db_final(DBKey key, DBData *data, va_list ap) {
if (p->instance)
aFree(p->instance);
- HPM->data_store_destroy(p->hdata);
- p->hdata = NULL;
+ HPM->data_store_destroy(&p->hdata);
}
return 0;
}
@@ -600,8 +599,7 @@ int party_broken(int party_id)
if( p->instance )
aFree(p->instance);
- HPM->data_store_destroy(p->hdata);
- p->hdata = NULL;
+ 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 960e6da08..df7c03f05 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -35,9 +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 hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
#define PB_NOTICE_LENGTH (36 + 1)
diff --git a/src/map/pc.c b/src/map/pc.c
index fee41deff..99f5b867e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -11332,8 +11332,7 @@ void pc_autotrade_populate(struct map_session_data *sd) {
pc->autotrade_update(sd,PAUC_START);
- HPM->data_store_destroy(data->hdata);
- data->hdata = NULL;
+ HPM->data_store_destroy(&data->hdata);
idb_remove(pc->at_db, sd->status.char_id);
}
@@ -11343,8 +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);
- HPM->data_store_destroy(at_v->hdata);
- at_v->hdata = NULL;
+ HPM->data_store_destroy(&at_v->hdata);
return 0;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index a74bc6c80..2c8b24acf 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -539,9 +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 hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
/* expiration_time timer id */
int expiration_tid;
@@ -756,8 +754,7 @@ struct autotrade_vending {
struct item list[MAX_VENDING];
struct s_vending vending[MAX_VENDING];
unsigned char vend_num;
- /* HPM Custom Struct */
- struct hplugin_data_store *hdata;
+ struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};
/*=====================================
diff --git a/src/map/unit.c b/src/map/unit.c
index 0f8a9d7e6..dcb5ec900 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2654,10 +2654,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
sd->quest_log = NULL;
sd->num_quests = sd->avail_quests = 0;
}
-
- HPM->data_store_destroy(sd->hdata);
- sd->hdata = NULL;
-
+ HPM->data_store_destroy(&sd->hdata);
break;
}
case BL_PET:
@@ -2768,9 +2765,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
if( md->tomb_nid )
mob->mvptomb_destroy(md);
- HPM->data_store_destroy(md->hdata);
- md->hdata = NULL;
-
+ HPM->data_store_destroy(&md->hdata);
break;
}
case BL_HOM: