diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-18 15:45:48 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-18 15:45:48 +0000 |
commit | fc936e5ced9af544cde112c1abc7374526088890 (patch) | |
tree | 31fcd590c5be902417a8a23ac95ff4d92700f2d5 /src | |
parent | 4add6a5ba3b45cf97a3731a8a38577e7506bca30 (diff) | |
download | hercules-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')
-rw-r--r-- | src/map/map.c | 22 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/mob.c | 4 | ||||
-rw-r--r-- | src/map/skill.c | 4 |
4 files changed, 23 insertions, 8 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); diff --git a/src/map/map.h b/src/map/map.h index 847ca477d..7aa99d219 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1335,6 +1335,7 @@ void map_addiddb(struct block_list *); void map_deliddb(struct block_list *bl); struct map_session_data** map_getallusers(int *users); void map_foreachpc(int (*func)(DBKey,void*,va_list),...); +void map_foreachmob(int (*func)(DBKey,void*,va_list),...); int map_foreachiddb(int (*)(DBKey,void*,va_list),...); struct map_session_data * map_nick2sd(const char*); diff --git a/src/map/mob.c b/src/map/mob.c index c58ce5e17..efe19b507 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1383,7 +1383,7 @@ static int mob_ai_sub_lazy(DBKey key,void * data,va_list ap) nullpo_retr(0, md); - if(md->bl.type!=BL_MOB || md->bl.prev == NULL) + if(md->bl.prev == NULL) return 0; if (md->nd || (battle_config.mob_ai&0x20 && map[md->bl.m].users>0)) @@ -1443,7 +1443,7 @@ static int mob_ai_sub_lazy(DBKey key,void * data,va_list ap) *------------------------------------------*/ static int mob_ai_lazy(int tid,unsigned int tick,int id,int data) { - map_foreachiddb(mob_ai_sub_lazy,tick); + map_foreachmob(mob_ai_sub_lazy,tick); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index fd116f02e..6e9935e33 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -10821,8 +10821,8 @@ static bool skill_parse_row_skilldb(char* split[], int columns, int current) else skill_db[i].skill_type = 0; skill_split_atoi(split[14],skill_db[i].blewcount); - safestrncpy(skill_db[i].name, split[15], sizeof(skill_db[i].name)); - safestrncpy(skill_db[i].desc, split[16], sizeof(skill_db[i].desc)); + safestrncpy(skill_db[i].name, trim(split[15]), sizeof(skill_db[i].name)); + safestrncpy(skill_db[i].desc, trim(split[16]), sizeof(skill_db[i].desc)); return true; } |