summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-01-12 14:26:33 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-01-12 14:26:33 +0000
commit10031f64176391ff687bb67c9ac888db47b7493b (patch)
tree93997f3b4aae5df64a7270c5c4ffb16cdf86d8dd /src
parent2b352fbed94714c290c86a7b801892ae1bae46df (diff)
downloadhercules-10031f64176391ff687bb67c9ac888db47b7493b.tar.gz
hercules-10031f64176391ff687bb67c9ac888db47b7493b.tar.bz2
hercules-10031f64176391ff687bb67c9ac888db47b7493b.tar.xz
hercules-10031f64176391ff687bb67c9ac888db47b7493b.zip
Added regen_db to reduce hp/sp processing delays (bugreport:2256).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13443 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/map.c32
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/status.c5
3 files changed, 35 insertions, 5 deletions
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;
}