summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-10-25 09:32:22 -0200
committershennetsind <ind@henn.et>2013-10-25 09:32:22 -0200
commitbf27a9e0cf1bfe9be298c4191010ba6876457d64 (patch)
tree5a7e85a639423109b6e8cf935f2f4c8ddf1bb595 /src/map/map.c
parent94b7b25456aa8a9de1e0f2a147d58dba6e5976dd (diff)
downloadhercules-bf27a9e0cf1bfe9be298c4191010ba6876457d64.tar.gz
hercules-bf27a9e0cf1bfe9be298c4191010ba6876457d64.tar.bz2
hercules-bf27a9e0cf1bfe9be298c4191010ba6876457d64.tar.xz
hercules-bf27a9e0cf1bfe9be298c4191010ba6876457d64.zip
Quest Bubbles Update
- Introduced questinfo cache, memory & processing speed improvement - Fixed mini-map marker support Special Thanks to Haruna Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 749b9de81..412a266fc 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;
}
}
@@ -4958,6 +4968,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
*/
@@ -5824,7 +5866,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
**/