summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/map/map.c32
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/status.c5
4 files changed, 37 insertions, 5 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 696d4a028..c1b8e81bf 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,8 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+2009/01/12
+ * Added regen_db to reduce hp/sp processing delays (bugreport:2256) [ultramage]
2009/01/05
* Fixed @mobsearch and @showmobs (bugreport:2481) [ultramage]
- now only search for mobs on the same map as the caller
diff --git a/src/map/map.c b/src/map/map.c
index 8c5e227db..a7374a309 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -99,6 +99,7 @@ static DBMap* bossid_db=NULL; // int id -> struct mob_data* (MVP db)
static DBMap* map_db=NULL; // unsigned int mapindex -> struct map_data*
static DBMap* nick_db=NULL; // int char_id -> struct charid2nick* (requested names of offline characters)
static DBMap* charid_db=NULL; // int char_id -> struct map_session_data*
+static DBMap* regen_db=NULL; // int id -> struct block_list* (status_natural_heal processing)
static int map_users=0;
static struct block_list *objects[MAX_FLOORITEM];
@@ -1547,6 +1548,9 @@ void map_addiddb(struct block_list *bl)
idb_put(bossid_db, bl->id, bl);
}
+ if( bl->type & BL_REGEN )
+ idb_put(regen_db, bl->id, bl);
+
idb_put(id_db,bl->id,bl);
}
@@ -1568,6 +1572,10 @@ void map_deliddb(struct block_list *bl)
idb_remove(mobid_db,bl->id);
idb_remove(bossid_db,bl->id);
}
+
+ if( bl->type & BL_REGEN )
+ idb_remove(regen_db,bl->id);
+
idb_remove(id_db,bl->id);
}
@@ -1866,6 +1874,28 @@ void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...)
}
/// Applies func to everything in the db.
+/// Stops iteratin gif func returns -1.
+void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...)
+{
+ DBIterator* iter;
+ struct block_list* bl;
+
+ iter = db_iterator(regen_db);
+ for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) )
+ {
+ va_list args;
+ int ret;
+
+ va_start(args, func);
+ ret = func(bl, args);
+ va_end(args);
+ if( ret == -1 )
+ break;// stop iterating
+ }
+ dbi_destroy(iter);
+}
+
+/// Applies func to everything in the db.
/// Stops iterating if func returns -1.
void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...)
{
@@ -3349,6 +3379,7 @@ void do_final(void)
nick_db->destroy(nick_db, nick_db_final);
charid_db->destroy(charid_db, NULL);
iwall_db->destroy(iwall_db, NULL);
+ regen_db->destroy(regen_db, NULL);
#ifndef TXT_ONLY
map_sql_close();
@@ -3519,6 +3550,7 @@ int do_init(int argc, char *argv[])
map_db = uidb_alloc(DB_OPT_BASE);
nick_db = idb_alloc(DB_OPT_BASE);
charid_db = idb_alloc(DB_OPT_BASE);
+ regen_db = idb_alloc(DB_OPT_BASE); // efficient status_natural_heal processing
iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls
diff --git a/src/map/map.h b/src/map/map.h
index 49b71b786..159b8da0d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -570,7 +570,8 @@ void map_addiddb(struct block_list *);
void map_deliddb(struct block_list *bl);
void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...);
void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...);
-void map_foreachnpc(int (*func)(struct npc_data* bl, va_list args), ...);
+void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...);
+void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...);
void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...);
struct map_session_data * map_nick2sd(const char*);
struct mob_data * map_getmob_boss(int m);
diff --git a/src/map/status.c b/src/map/status.c
index 9806a214a..189c70e68 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -7461,9 +7461,6 @@ static int status_natural_heal(struct block_list* bl, va_list args)
struct map_session_data *sd;
int val,rate,bonus = 0,flag;
- if (!(bl->type&BL_REGEN))
- return 0;
-
regen = status_get_regen_data(bl);
if (!regen) return 0;
status = status_get_status_data(bl);
@@ -7647,7 +7644,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr data)
{
natural_heal_diff_tick = DIFF_TICK(tick,natural_heal_prev_tick);
- map_foreachiddb(status_natural_heal);
+ map_foreachregen(status_natural_heal);
natural_heal_prev_tick = tick;
return 0;
}