summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-28 18:09:13 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-28 18:09:13 +0300
commit8cf325640e316aff125deeff3d2880bb342d00c9 (patch)
tree2f5aabe104fcba2a36022a098a839ff04f6c2b36 /src
parentf68e125478e7b74fdc7e9c272449ae0c5c227d1c (diff)
downloadplugin-8cf325640e316aff125deeff3d2880bb342d00c9.tar.gz
plugin-8cf325640e316aff125deeff3d2880bb342d00c9.tar.bz2
plugin-8cf325640e316aff125deeff3d2880bb342d00c9.tar.xz
plugin-8cf325640e316aff125deeff3d2880bb342d00c9.zip
Fix memory leak if npc change class.s20160630
Diffstat (limited to 'src')
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/status.c11
-rw-r--r--src/emap/status.h2
3 files changed, 14 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index a355e2b..0882db6 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -252,6 +252,7 @@ HPExport void plugin_init (void)
addHookPre(script, load_parameters, escript_load_parameters_pre);
addHookPre(script, hardcoded_constants, escript_hardcoded_constants_pre);
addHookPre(status, calc_pc_additional, estatus_calc_pc_additional_pre);
+ addHookPre(status, set_viewdata, estatus_set_viewdata_pre);
addHookPost(clif, addcards, eclif_addcards_post);
addHookPost(clif, addcards2, eclif_addcards2_post);
diff --git a/src/emap/status.c b/src/emap/status.c
index 1b27a0f..13592b5 100644
--- a/src/emap/status.c
+++ b/src/emap/status.c
@@ -39,6 +39,17 @@ void status_init(void)
class_move_speed[f] = 150;
}
+void estatus_set_viewdata_pre(struct block_list **blPtr,
+ int *classPtr_ __attribute__ ((unused)))
+{
+ struct block_list *bl = *blPtr;
+ if (bl->type != BL_NPC)
+ return;
+ TBL_NPC *const npc = (TBL_NPC*)bl;
+ aFree(npc->vd);
+ npc->vd = NULL;
+}
+
void estatus_set_viewdata_post(struct block_list *bl,
int class_ __attribute__ ((unused)))
{
diff --git a/src/emap/status.h b/src/emap/status.h
index fce6c83..62bbec7 100644
--- a/src/emap/status.h
+++ b/src/emap/status.h
@@ -5,6 +5,8 @@
#define EVOL_MAP_STATUS
void status_init(void);
+void estatus_set_viewdata_pre(struct block_list **blPtr,
+ int *classPtr_ __attribute__ ((unused)));
void estatus_set_viewdata_post(struct block_list *bl,
int class_);
void estatus_read_job_db_sub_post(int idx,