From 180c7942243c1b1a4a1d01f8f630126b25252e95 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 29 Apr 2012 16:33:55 +0000 Subject: Yet another performance improvement: Shut Down processing is now about to 7 times faster. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16006 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/map.c | 20 +++++++++++--------- src/map/npc.c | 24 +++++------------------- src/map/npc.h | 1 + 3 files changed, 17 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/map/map.c b/src/map/map.c index 0ce364c69..deb8548b0 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -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(); diff --git a/src/map/npc.c b/src/map/npc.c index 312c0b228..23eca70d4 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3509,30 +3509,16 @@ int npc_reload(void) { } return 0; } - +void do_clear_npc(void) { + db_clear(npcname_db); + db_clear(ev_db); +} /*========================================== * 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(); diff --git a/src/map/npc.h b/src/map/npc.h index da5f0a295..de25c09a3 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -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); -- cgit v1.2.3-70-g09d2