diff options
author | shennetsind <shennetsind@users.noreply.github.com> | 2013-10-25 21:11:05 -0700 |
---|---|---|
committer | shennetsind <shennetsind@users.noreply.github.com> | 2013-10-25 21:11:05 -0700 |
commit | 1ab0017183e910271f4590beee37530fa3ce8ba0 (patch) | |
tree | 03ef8eb76a73d498e69e8c7e1160a1015a4c9653 /src/map/map.c | |
parent | 5f6f1d66834b8328496c1678f0ce4f90a001b3fb (diff) | |
parent | f7158456d9f6338b38b16f321c9a229fc6547bc0 (diff) | |
download | hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.tar.gz hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.tar.bz2 hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.tar.xz hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.zip |
Merge pull request #202 from kisuka/master
Quest Bubbles (Actually Works Finally)
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/map/map.c b/src/map/map.c index 133c63a1c..81bd732df 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3112,6 +3112,10 @@ void do_final_maps(void) { if( map->list[i].channel ) clif->chsys_delete(map->list[i].channel); + + if( map->list[i].qi_data ) + aFree(map->list[i].qi_data); + } map->zone_db_clear(); @@ -3177,6 +3181,12 @@ void map_flags_init(void) { map->list[i].misc_damage_rate = 100; map->list[i].short_damage_rate = 100; map->list[i].long_damage_rate = 100; + + if( map->list[i].qi_data ) + aFree(map->list[i].qi_data); + + map->list[i].qi_data = NULL; + map->list[i].qi_count = 0; } } @@ -4968,6 +4978,38 @@ int map_get_new_bonus_id (void) { return map->bonus_id++; } +void map_add_questinfo(int m, struct questinfo *qi) { + unsigned short i; + + /* duplicate, override */ + for(i = 0; i < map->list[m].qi_count; i++) { + if( map->list[m].qi_data[i].nd == qi->nd ) + break; + } + + if( i == map->list[m].qi_count ) + RECREATE(map->list[m].qi_data, struct questinfo, ++map->list[m].qi_count); + + memcpy(&map->list[m].qi_data[i], qi, sizeof(struct questinfo)); +} + +bool map_remove_questinfo(int m, struct npc_data *nd) { + unsigned short i; + + for(i = 0; i < map->list[m].qi_count; i++) { + struct questinfo *qi = &map->list[m].qi_data[i]; + if( qi->nd == nd ) { + memset(&map->list[m].qi_data[i], 0, sizeof(struct questinfo)); + if( i != --map->list[m].qi_count ) { + memmove(&map->list[m].qi_data[i],&map->list[m].qi_data[i+1],sizeof(struct questinfo)*(map->list[m].qi_count-i)); + } + return true; + } + } + + return false; +} + /** * @see DBApply */ @@ -5834,7 +5876,10 @@ void map_defaults(void) { map->delblcell = map_delblcell; map->get_new_bonus_id = map_get_new_bonus_id; - + + map->add_questinfo = map_add_questinfo; + map->remove_questinfo = map_remove_questinfo; + /** * mapit interface **/ |