summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/HPMmap.c12
-rw-r--r--src/map/itemdb.c17
-rw-r--r--src/map/itemdb.h5
-rw-r--r--src/map/mob.c27
-rw-r--r--src/map/mob.h9
-rw-r--r--src/map/unit.c10
6 files changed, 74 insertions, 6 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index a0701ae45..f1cdec538 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -101,6 +101,18 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
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;
default:
return false;
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 545ce9ba0..cd4465468 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -16,6 +16,7 @@
#include "mob.h" // MAX_MOB_DB
#include "pc.h" // W_MUSICAL, W_WHIP
#include "script.h" // item script processing
+#include "../common/HPM.h"
#include "../common/conf.h"
#include "../common/malloc.h"
#include "../common/nullpo.h"
@@ -1501,6 +1502,11 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
return item->nameid;
}
+void itemdb_readdb_additional_fields(int itemid, config_setting_t *it, int n, const char *source)
+{
+ // do nothing. plugins can do own work
+}
+
/**
* Processes one itemdb entry from the sql backend, loading and inserting it
* into the item database.
@@ -1936,6 +1942,7 @@ int itemdb_readdb_libconfig(const char *filename) {
if( !nameid )
continue;
+ itemdb->readdb_additional_fields(nameid, it, i - 1, filename);
count++;
if( duplicate[nameid] ) {
@@ -2069,6 +2076,7 @@ bool itemdb_is_item_usable(struct item_data *item)
/// Destroys the item_data.
void destroy_item_data(struct item_data* self, int free_self)
{
+ int v;
if( self == NULL )
return;
// free scripts
@@ -2080,6 +2088,14 @@ void destroy_item_data(struct item_data* self, int free_self)
script->free_code(self->unequip_script);
if( self->combos )
aFree(self->combos);
+ for (v = 0; v < self->hdatac; v++ ) {
+ if (self->hdata[v]->flag.free ) {
+ aFree(self->hdata[v]->data);
+ }
+ aFree(self->hdata[v]);
+ }
+ if (self->hdata)
+ aFree(self->hdata);
#if defined(DEBUG)
// trash item
memset(self, 0xDD, sizeof(struct item_data));
@@ -2335,6 +2351,7 @@ void itemdb_defaults(void) {
itemdb->read_combos = itemdb_read_combos;
itemdb->gendercheck = itemdb_gendercheck;
itemdb->validate_entry = itemdb_validate_entry;
+ itemdb->readdb_additional_fields = itemdb_readdb_additional_fields;
itemdb->readdb_sql_sub = itemdb_readdb_sql_sub;
itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub;
itemdb->readdb_libconfig = itemdb_readdb_libconfig;
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 23339790e..9a72c64ac 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -434,6 +434,10 @@ 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 item_combo {
@@ -600,6 +604,7 @@ struct itemdb_interface {
void (*read_combos) ();
int (*gendercheck) (struct item_data *id);
int (*validate_entry) (struct item_data *entry, int n, const char *source);
+ void (*readdb_additional_fields) (int itemid, config_setting_t *it, int n, const char *source);
int (*readdb_sql_sub) (Sql *handle, int n, const char *source);
int (*readdb_libconfig_sub) (config_setting_t *it, int n, const char *source);
int (*readdb_libconfig) (const char *filename);
diff --git a/src/map/mob.c b/src/map/mob.c
index 6171ddb75..8fe3e3cef 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -34,6 +34,7 @@
#include "script.h"
#include "skill.h"
#include "status.h"
+#include "../common/HPM.h"
#include "../common/cbasetypes.h"
#include "../common/db.h"
#include "../common/ers.h"
@@ -3550,8 +3551,7 @@ int mob_clone_delete(struct mob_data *md)
const int class_ = md->class_;
if (class_ >= MOB_CLONE_START && class_ < MOB_CLONE_END
&& mob->db_data[class_]!=NULL) {
- aFree(mob->db_data[class_]);
- mob->db_data[class_]=NULL;
+ mob->destroy_mob_db(class_);
//Clear references to the db
md->db = mob->dummy;
md->vd = NULL;
@@ -3574,8 +3574,7 @@ int mob_makedummymobdb(int class_)
return 1; //Using the mob->dummy data already. [Skotlex]
if (class_ > 0 && class_ <= MAX_MOB_DB) {
//Remove the mob data so that it uses the dummy data instead.
- aFree(mob->db_data[class_]);
- mob->db_data[class_] = NULL;
+ mob->destroy_mob_db(class_);
}
return 0;
}
@@ -4701,6 +4700,22 @@ int do_init_mob(bool minimal) {
return 0;
}
+void mob_destroy_mob_db(int index)
+{
+ struct mob_db *data = mob->db_data[index];
+ int v;
+ for (v = 0; v < data->hdatac; v++ ) {
+ if (data->hdata[v]->flag.free ) {
+ aFree(data->hdata[v]->data);
+ }
+ aFree(data->hdata[v]);
+ }
+ if (data->hdata)
+ aFree(data->hdata);
+ aFree(data);
+ mob->db_data[index] = NULL;
+}
+
/*==========================================
* Clean memory usage.
*------------------------------------------*/
@@ -4716,8 +4731,7 @@ int do_final_mob(void)
{
if (mob->db_data[i] != NULL)
{
- aFree(mob->db_data[i]);
- mob->db_data[i] = NULL;
+ mob->destroy_mob_db(i);
}
}
for (i = 0; i <= MAX_MOB_CHAT; i++)
@@ -4852,4 +4866,5 @@ void mob_defaults(void) {
mob->readdb_itemratio = mob_readdb_itemratio;
mob->load = mob_load;
mob->clear_spawninfo = mob_clear_spawninfo;
+ mob->destroy_mob_db = mob_destroy_mob_db;
}
diff --git a/src/map/mob.h b/src/map/mob.h
index f79b33804..9aac2c664 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -126,6 +126,10 @@ 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 mob_data {
@@ -197,6 +201,10 @@ struct mob_data {
* MvP Tombstone NPC ID
**/
int tomb_nid;
+
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
@@ -369,6 +377,7 @@ struct mob_interface {
bool (*readdb_itemratio) (char *str[], int columns, int current);
void (*load) (bool minimal);
void (*clear_spawninfo) ();
+ void (*destroy_mob_db) (int index);
};
struct mob_interface *mob;
diff --git a/src/map/unit.c b/src/map/unit.c
index 0924e6cf2..e23eb42ac 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2720,6 +2720,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
}
case BL_MOB:
{
+ unsigned int k;
struct mob_data *md = (struct mob_data*)bl;
if( md->spawn_timer != INVALID_TIMER )
{
@@ -2774,6 +2775,15 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
mob->clone_delete(md);
if( md->tomb_nid )
mob->mvptomb_destroy(md);
+
+ for (k = 0; k < md->hdatac; k++) {
+ if( md->hdata[k]->flag.free ) {
+ aFree(md->hdata[k]->data);
+ }
+ aFree(md->hdata[k]);
+ }
+ if (md->hdata)
+ aFree(md->hdata);
break;
}
case BL_HOM: