diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-05-26 21:49:36 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-05-26 21:49:36 +0000 |
commit | 5f5cd93f2da3377ce3b9ae45d4a15a944a723517 (patch) | |
tree | db90d3aa9e10b9b18aa5339b6c63f531ef8541fd | |
parent | e576f13c95750f3c2b8fc3e764ab2b80f76df8b9 (diff) | |
download | hercules-5f5cd93f2da3377ce3b9ae45d4a15a944a723517.tar.gz hercules-5f5cd93f2da3377ce3b9ae45d4a15a944a723517.tar.bz2 hercules-5f5cd93f2da3377ce3b9ae45d4a15a944a723517.tar.xz hercules-5f5cd93f2da3377ce3b9ae45d4a15a944a723517.zip |
Fixed bugreport:5658 Instance NPCs will now be cleared properly. Super-Special Thanks to Pig321
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16153 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | src/map/instance.c | 30 | ||||
-rw-r--r-- | src/map/npc.c | 2 |
2 files changed, 30 insertions, 2 deletions
diff --git a/src/map/instance.c b/src/map/instance.c index fcbc03e5e..44b735518 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -253,6 +253,34 @@ int instance_del_load(struct map_session_data* sd, va_list args) return 1; } +/* for npcs behave differently when being unloaded within a instance */ +int instance_cleanup_sub(struct block_list *bl, va_list ap) { + nullpo_ret(bl); + + switch(bl->type) { + case BL_PC: + map_quit((struct map_session_data *) bl); + break; + case BL_NPC: + npc_unload((struct npc_data *)bl,true); + break; + case BL_MOB: + unit_free(bl,CLR_OUTSIGHT); + break; + case BL_PET: + //There is no need for this, the pet is removed together with the player. [Skotlex] + break; + case BL_ITEM: + map_clearflooritem(bl->id); + break; + case BL_SKILL: + skill_delunit((struct skill_unit *) bl); + break; + } + + return 1; +} + /*-------------------------------------- * Removes a simple instance map *--------------------------------------*/ @@ -266,7 +294,7 @@ void instance_del_map(int m) } map_foreachpc(instance_del_load, m); - map_foreachinmap(cleanup_sub, m, BL_ALL); + map_foreachinmap(instance_cleanup_sub, m, BL_ALL); if( map[m].mob_delete_timer != INVALID_TIMER ) delete_timer(map[m].mob_delete_timer, map_removemobs_timer); diff --git a/src/map/npc.c b/src/map/npc.c index 4f08d28f5..9cfce37ac 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1739,7 +1739,7 @@ int npc_unload(struct npc_data* nd, bool single) { npc_remove_map(nd); map_deliddb(&nd->bl); if( single ) - strdb_remove(npcname_db, nd->exname); + strdb_remove(npcname_db, nd->exname); if (nd->chat_id) // remove npc chatroom object and kick users chat_deletenpcchat(nd); |