diff options
author | Asheraf <acheraf1998@gmail.com> | 2019-04-21 17:07:47 +0100 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2019-05-06 19:59:30 +0000 |
commit | abe4b83a81c437d404aadea723165d98c33d462d (patch) | |
tree | e6b5eaeda12876358d6a00636d20bc311502f8ad /src/map/npc.c | |
parent | 403939af8bdb08e33f9b0a6613fe2e5e00bbea04 (diff) | |
download | hercules-abe4b83a81c437d404aadea723165d98c33d462d.tar.gz hercules-abe4b83a81c437d404aadea723165d98c33d462d.tar.bz2 hercules-abe4b83a81c437d404aadea723165d98c33d462d.tar.xz hercules-abe4b83a81c437d404aadea723165d98c33d462d.zip |
Move questinfo data from map to npc_data
this will fix the issue where having multiple `questinfo()` blocks wont work properly
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; } |