From 3c73a02748ca50a32005a5b73933a582cd87b80f Mon Sep 17 00:00:00 2001 From: ultramage Date: Thu, 16 Aug 2007 14:14:11 +0000 Subject: * Fixed npc chatrooms not being deleted on npc unload/reload (crash) * Modified chat code a bit for more clarity - replaced double-indirection on 'owner' with a normal pointer - separated some common functionality to 'chat_createchat()' git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11023 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/npc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/map/npc.c') diff --git a/src/map/npc.c b/src/map/npc.c index f991f14d1..2b3de118f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -22,6 +22,7 @@ #include "skill.h" #include "unit.h" #include "npc.h" +#include "chat.h" #include #include @@ -1511,11 +1512,9 @@ int npc_unload(struct npc_data* nd) npc_remove_map(nd); map_deliddb(&nd->bl); - if (nd->chat_id) { - struct chat_data *cd = (struct chat_data*)map_id2bl(nd->chat_id); - if (cd) aFree (cd); - cd = NULL; - } + if (nd->chat_id) // remove npc chatroom object and kick users + chat_deletenpcchat(nd); + if (nd->bl.subtype == SCRIPT) { ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related. if (nd->u.scr.timerid != -1) { -- cgit v1.2.3-60-g2f50