summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2019-04-21 17:07:47 +0100
committerAsheraf <acheraf1998@gmail.com>2019-05-06 19:59:30 +0000
commitabe4b83a81c437d404aadea723165d98c33d462d (patch)
treee6b5eaeda12876358d6a00636d20bc311502f8ad /src/map/map.c
parent403939af8bdb08e33f9b0a6613fe2e5e00bbea04 (diff)
downloadhercules-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/map.c')
-rw-r--r--src/map/map.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 34d30db5b..71eab9286 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3645,7 +3645,7 @@ static void map_clean(int i)
if (map->list[i].channel != NULL)
channel->delete(map->list[i].channel);
- quest->questinfo_vector_clear(i);
+ VECTOR_CLEAR(map->list[i].qi_list);
HPM->data_store_destroy(&map->list[i].hdata);
}
static void do_final_maps(void)
@@ -3743,7 +3743,8 @@ static void map_flags_init(void)
map->list[i].short_damage_rate = 100;
map->list[i].long_damage_rate = 100;
- VECTOR_INIT(map->list[i].qi_data);
+ VECTOR_CLEAR(map->list[i].qi_list);
+ VECTOR_INIT(map->list[i].qi_list);
}
}
@@ -5979,28 +5980,30 @@ static int map_get_new_bonus_id(void)
return map->bonus_id++;
}
-static void map_add_questinfo(int m, struct questinfo *qi)
+static bool map_add_questinfo(int m, struct npc_data *nd)
{
- nullpo_retv(qi);
- Assert_retv(m >= 0 && m < map->count);
+ nullpo_retr(false, nd);
+ Assert_retr(false, m >= 0 && m < map->count);
+
+ if (&VECTOR_LAST(map->list[m].qi_list) == nd)
+ return false;
- VECTOR_ENSURE(map->list[m].qi_data, 1, 1);
- VECTOR_PUSH(map->list[m].qi_data, *qi);
+ VECTOR_ENSURE(map->list[m].qi_list, 1, 1);
+ VECTOR_PUSH(map->list[m].qi_list, *nd);
+ return true;
}
static bool map_remove_questinfo(int m, struct npc_data *nd)
{
- unsigned short i;
nullpo_retr(false, nd);
Assert_retr(false, m >= 0 && m < map->count);
- for (i = 0; i < VECTOR_LENGTH(map->list[m].qi_data); i++) {
- struct questinfo *qi_data = &VECTOR_INDEX(map->list[m].qi_data, i);
- if (qi_data->nd == nd) {
- VECTOR_ERASE(map->list[m].qi_data, i);
- return true;
- }
+ int i;
+ ARR_FIND(0, VECTOR_LENGTH(map->list[m].qi_list), i, &VECTOR_INDEX(map->list[m].qi_list, i) == nd);
+ if (i != VECTOR_LENGTH(map->list[m].qi_list)) {
+ VECTOR_ERASE(map->list[m].qi_list, i);
+ return true;
}
return false;
}