diff options
author | Haru <haru@dotalux.com> | 2019-06-01 14:22:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-01 14:22:19 +0200 |
commit | c8202e1cd9eb64d07fa921d117a13eef3938a4db (patch) | |
tree | e57701639ffb1e518431dc0e0a10860aa7c642d6 /src/map/npc.c | |
parent | d7042459c9f9797a80dadce57297b5d16e8931c4 (diff) | |
parent | a321a26f2f9867c8c0e4b5503e4ad2275801122e (diff) | |
download | hercules-c8202e1cd9eb64d07fa921d117a13eef3938a4db.tar.gz hercules-c8202e1cd9eb64d07fa921d117a13eef3938a4db.tar.bz2 hercules-c8202e1cd9eb64d07fa921d117a13eef3938a4db.tar.xz hercules-c8202e1cd9eb64d07fa921d117a13eef3938a4db.zip |
Merge pull request #2433 from Asheraf/questinfomemfix
Move questinfo data from map to npc_data
Diffstat (limited to 'src/map/npc.c')
-rw-r--r-- | src/map/npc.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 4b79a9fed..77087d6cb 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -36,6 +36,7 @@ #include "map/mob.h" #include "map/pc.h" #include "map/pet.h" +#include "map/quest.h" #include "map/script.h" #include "map/skill.h" #include "map/status.h" @@ -2638,8 +2639,9 @@ static int npc_unload(struct npc_data *nd, bool single) nd->path = NULL; } - if( single && nd->bl.m != -1 ) - map->remove_questinfo(nd->bl.m,nd); + if (single && nd->bl.m != -1) + map->remove_questinfo(nd->bl.m, nd); + npc->questinfo_clear(nd); if (nd->src_id == 0 && ( nd->subtype == SHOP || nd->subtype == CASHSHOP)) { //src check for duplicate shops [Orcao] @@ -2978,6 +2980,7 @@ static struct npc_data *npc_create_npc(enum npc_subtype subtype, int m, int x, i nd->class_ = class_; nd->speed = 200; nd->vd = npc_viewdb[0]; // Copy INVISIBLE_CLASS view data. Actual view data is set by npc->add_to_location() later. + VECTOR_INIT(nd->qi_data); return nd; } @@ -5331,6 +5334,18 @@ static void npc_debug_warps(void) npc->debug_warps_sub(map->list[m].npc[i]); } +static void npc_questinfo_clear(struct npc_data *nd) +{ + nullpo_retv(nd); + + for (int i = 0; i < VECTOR_LENGTH(nd->qi_data); i++) { + struct questinfo *qi = &VECTOR_INDEX(nd->qi_data, i); + VECTOR_CLEAR(qi->items); + VECTOR_CLEAR(qi->quest_requirement); + } + VECTOR_CLEAR(nd->qi_data); +} + /*========================================== * npc initialization *------------------------------------------*/ @@ -5551,4 +5566,5 @@ void npc_defaults(void) npc->barter_delfromsql_sub = npc_barter_delfromsql_sub; npc->db_checkid = npc_db_checkid; npc->refresh = npc_refresh; + npc->questinfo_clear = npc_questinfo_clear; } |