diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-04-29 16:33:55 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-04-29 16:33:55 +0000 |
commit | 180c7942243c1b1a4a1d01f8f630126b25252e95 (patch) | |
tree | d224c4617465cce047091332cdedd703bfd4f027 | |
parent | 12ca43bf1123acb96fdc2c8f3a0003d79774bd19 (diff) | |
download | hercules-180c7942243c1b1a4a1d01f8f630126b25252e95.tar.gz hercules-180c7942243c1b1a4a1d01f8f630126b25252e95.tar.bz2 hercules-180c7942243c1b1a4a1d01f8f630126b25252e95.tar.xz hercules-180c7942243c1b1a4a1d01f8f630126b25252e95.zip |
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
-rw-r--r-- | src/map/map.c | 20 | ||||
-rw-r--r-- | src/map/npc.c | 24 | ||||
-rw-r--r-- | src/map/npc.h | 1 |
3 files changed, 17 insertions, 28 deletions
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); |