Yet another performance improvement: Shut Down processing is now about to 7 times faster.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@16006 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
shennetsind 2012-04-29 16:33:55 +00:00
parent 444142de89
commit 622ce6fd0f
3 changed files with 17 additions and 28 deletions

View File

@ -3533,7 +3533,7 @@ int cleanup_sub(struct block_list *bl, va_list ap)
map_quit((struct map_session_data *) bl);
break;
case BL_NPC:
npc_unload((struct npc_data *)bl,true);
npc_unload((struct npc_data *)bl,false);
break;
case BL_MOB:
unit_free(bl,CLR_OUTSIGHT);
@ -3571,21 +3571,23 @@ void do_final(void)
ShowStatus("Terminating...\n");
//Ladies and babies first.
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
map_quit(sd);
mapit_free(iter);
/* prepares npcs for a faster shutdown process */
do_clear_npc();
// remove all objects on maps
for (i = 0; i < map_num; i++)
{
for (i = 0; i < map_num; i++) {
ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map_num, map[i].name);
if (map[i].m >= 0)
map_foreachinmap(cleanup_sub, i, BL_ALL);
}
ShowStatus("Cleaned up %d maps."CL_CLL"\n", map_num);
//Scan any remaining players (between maps?) to kick them out. [Skotlex]
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
map_quit(sd);
mapit_free(iter);
id_db->foreach(id_db,cleanup_db_sub);
chrif_char_reset_offline();
chrif_flush_fifo();

View File

@ -3509,30 +3509,16 @@ int npc_reload(void) {
}
return 0;
}
void do_clear_npc(void) {
db_clear(npcname_db);
db_clear(ev_db);
}
/*==========================================
* <EFBFBD>I¹
*------------------------------------------*/
int do_final_npc(void)
{
int i;
struct block_list *bl;
db_clear(npcname_db);
db_clear(ev_db);
for (i = START_NPC_NUM; i < npc_id; i++){
if ((bl = map_id2bl(i))){
if (bl->type == BL_NPC)
npc_unload((struct npc_data *)bl, false);
else if (bl->type&(BL_MOB|BL_PET|BL_HOM|BL_MER))
unit_free(bl, CLR_OUTSIGHT);
}
}
int do_final_npc(void) {
ev_db->destroy(ev_db, NULL);
//There is no free function for npcname_db because at this point there shouldn't be any npcs left!
//So if there is anything remaining, let the memory manager catch it and report it.
npcname_db->destroy(npcname_db, NULL);
ers_destroy(timer_event_ers);
npc_clearsrcfile();

View File

@ -135,6 +135,7 @@ int npc_get_new_npc_id(void);
void npc_addsrcfile(const char* name);
void npc_delsrcfile(const char* name);
void npc_parsesrcfile(const char* filepath);
void do_clear_npc(void);
int do_final_npc(void);
int do_init_npc(void);
void npc_event_do_oninit(void);