summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-10-05 14:37:06 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-10-05 14:37:06 +0000
commit63efe8b1c659a3b1491321bbfbd0d1731daf8e74 (patch)
tree426cec7f0841c0c28dae3d9ee6ddac07ba3effa1 /src/map/npc.c
parentaf15657c15e2f506a379d8a7babd4200c770e135 (diff)
downloadhercules-63efe8b1c659a3b1491321bbfbd0d1731daf8e74.tar.gz
hercules-63efe8b1c659a3b1491321bbfbd0d1731daf8e74.tar.bz2
hercules-63efe8b1c659a3b1491321bbfbd0d1731daf8e74.tar.xz
hercules-63efe8b1c659a3b1491321bbfbd0d1731daf8e74.zip
- Added function npc_unload_duplicates(), it unloads all npcs that are a duplicate of the passed one. For use with @unloadnpc to prevent crashes when you unload the npc that has duplicates.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8939 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 1954b5d7f..7724a2b8a 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1417,6 +1417,27 @@ static int npc_unload_ev(DBKey key,void *data,va_list ap) {
return 0;
}
+static int npc_unload_dup_sub(DBKey key,void * data,va_list app)
+{
+ struct npc_data *nd = (struct npc_data *)data;
+ va_list ap;
+ int src_id;
+
+ if(nd->bl.type!=BL_NPC || nd->bl.subtype != SCRIPT)
+ return 0;
+
+ ap = va_arg(app, va_list);
+ src_id=va_arg(ap,int);
+ if (nd->u.scr.src_id == src_id)
+ npc_unload(nd);
+ return 0;
+}
+//Removes all npcs that are duplicates of the passed one. [Skotlex]
+void npc_unload_duplicates (struct npc_data *nd)
+{
+ map_foreachiddb(npc_unload_dup_sub,nd->bl.id);
+}
+
int npc_unload (struct npc_data *nd)
{
nullpo_ret(nd);