summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-16 14:14:11 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-16 14:14:11 +0000
commit3c73a02748ca50a32005a5b73933a582cd87b80f (patch)
tree9c35effdea7e3bf0a2a944957b7c2e489ba68f34 /src/map/npc.c
parentccc18ecfe671803c6d6b9b6dd790c45cdf28c9ac (diff)
downloadhercules-3c73a02748ca50a32005a5b73933a582cd87b80f.tar.gz
hercules-3c73a02748ca50a32005a5b73933a582cd87b80f.tar.bz2
hercules-3c73a02748ca50a32005a5b73933a582cd87b80f.tar.xz
hercules-3c73a02748ca50a32005a5b73933a582cd87b80f.zip
* 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
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c9
1 files changed, 4 insertions, 5 deletions
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 <stdio.h>
#include <stdlib.h>
@@ -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) {