- 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://svn.code.sf.net/p/rathena/svn/trunk@11943 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-12-18 15:45:48 +00:00
parent ace81763bc
commit ece12b6e42
7 changed files with 620 additions and 599 deletions

View File

@ -3,6 +3,9 @@ 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.
2007/12/18
* Corrected skill_db reading to properly trim the skill name/descs.
* Added a mobid_db in map.c to handle mob lookups faster. [Skotlex]
2007/12/17
* Added flag.server to indicate interserver sockets
- replaces the previous way (setting 'client_addr' to 0)

View File

@ -38,6 +38,9 @@
=======================
12/18
* Cleaned up a bit the format of skill_db.txt (that comma next to the skill
name looks ugly if you ask me)
12/14
* corrected Option_Xmas value in const.txt [Skotlex]
12/13

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -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*);

View File

@ -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;
}

View File

@ -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;
}