summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-18 15:45:48 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-18 15:45:48 +0000
commitfc936e5ced9af544cde112c1abc7374526088890 (patch)
tree31fcd590c5be902417a8a23ac95ff4d92700f2d5 /src/map/map.c
parent4add6a5ba3b45cf97a3731a8a38577e7506bca30 (diff)
downloadhercules-fc936e5ced9af544cde112c1abc7374526088890.tar.gz
hercules-fc936e5ced9af544cde112c1abc7374526088890.tar.bz2
hercules-fc936e5ced9af544cde112c1abc7374526088890.tar.xz
hercules-fc936e5ced9af544cde112c1abc7374526088890.zip
- Cleaned up a bit the format of skill_db.txt (that comma next to the skill name looks ugly if you ask me)
- Corrected skill_db reading to properly trim the skill name/descs. - Added a mobid_db in map.c to handle mob lookups faster. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11943 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 43b17daec..26a8931e6 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -96,6 +96,7 @@ char *MSG_CONF_NAME;
// 極力 staticでロ?カルに?める
static DBMap* id_db=NULL; // int id -> struct block_list*
static DBMap* pc_db=NULL; // int id -> struct map_session_data*
+static DBMap* mobid_db=NULL; // int id -> struct mob_data*
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*
@@ -1643,7 +1644,9 @@ void map_addiddb(struct block_list *bl)
TBL_PC* sd = (TBL_PC*)bl;
idb_put(pc_db,sd->bl.id,sd);
idb_put(charid_db,sd->status.char_id,sd);
- }
+ } else if (bl->type == BL_MOB)
+ idb_put(mobid_db,bl->id,bl);
+
idb_put(id_db,bl->id,bl);
}
@@ -1659,7 +1662,8 @@ void map_deliddb(struct block_list *bl)
TBL_PC* sd = (TBL_PC*)bl;
idb_remove(pc_db,sd->bl.id);
idb_remove(charid_db,sd->status.char_id);
- }
+ } else if (bl->type == BL_MOB)
+ idb_remove(mobid_db,bl->id);
idb_remove(id_db,bl->id);
}
@@ -1764,9 +1768,9 @@ struct map_session_data * map_id2sd(int id)
}
struct mob_data * map_id2md(int id)
-{// just a id2bl lookup because there's no mob_db
+{
if (id <= 0) return NULL;
- return (struct mob_data*)map_id2bl(id);
+ return (struct mob_data*)idb_get(mobid_db,id);
}
struct npc_data * map_id2nd(int id)
@@ -1909,6 +1913,14 @@ void map_foreachpc(int (*func)(DBKey,void*,va_list),...)
va_end(ap);
}
+void map_foreachmob(int (*func)(DBKey,void*,va_list),...)
+{
+ va_list ap;
+ va_start(ap,func);
+ mobid_db->vforeach(mobid_db,func,ap);
+ va_end(ap);
+}
+
/*==========================================
* id_db?の全てにfuncを?行
*------------------------------------------*/
@@ -3113,6 +3125,7 @@ void do_final(void)
id_db->destroy(id_db, NULL);
pc_db->destroy(pc_db, NULL);
+ mobid_db->destroy(mobid_db, NULL);
nick_db->destroy(nick_db, nick_db_final);
charid_db->destroy(charid_db, NULL);
@@ -3291,6 +3304,7 @@ int do_init(int argc, char *argv[])
id_db = idb_alloc(DB_OPT_BASE);
pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map_id2sd() use. [Skotlex]
+ mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex]
map_db = uidb_alloc(DB_OPT_BASE);
nick_db = idb_alloc(DB_OPT_BASE);
charid_db = idb_alloc(DB_OPT_BASE);