diff options
author | Haruna <haru@dotalux.com> | 2014-12-20 23:42:37 +0100 |
---|---|---|
committer | Haruna <haru@dotalux.com> | 2014-12-20 23:42:37 +0100 |
commit | 1134e030744e67bca61f52dc97075f33932f7a38 (patch) | |
tree | 3c5f077c6537f7e165039d3bf68d8052253b7dc2 /src/map/mob.c | |
parent | c4456ddbebccaca51ab040c60e3c586ed2cc0a10 (diff) | |
parent | 2c6fd58d633e4139a6f0f3b4bb0262e64fc957e2 (diff) | |
download | hercules-1134e030744e67bca61f52dc97075f33932f7a38.tar.gz hercules-1134e030744e67bca61f52dc97075f33932f7a38.tar.bz2 hercules-1134e030744e67bca61f52dc97075f33932f7a38.tar.xz hercules-1134e030744e67bca61f52dc97075f33932f7a38.zip |
Merge pull request #416 from 4144/plugext
Extend plugins support in item_data, mob_db, mob_data
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 27 |
1 files changed, 21 insertions, 6 deletions
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; } |