summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c1
-rw-r--r--src/map/npc.c21
-rw-r--r--src/map/npc.h1
3 files changed, 23 insertions, 0 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d0bf422e0..836f40f40 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -6234,6 +6234,7 @@ int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
}
if ((nd = npc_name2id(NPCname)) != NULL) {
+ npc_unload_duplicates(nd);
npc_unload(nd);
clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
} else {
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);
diff --git a/src/map/npc.h b/src/map/npc.h
index 94de8064a..2ea4f7eb7 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -77,6 +77,7 @@ void npc_timerevent_quit(struct map_session_data *sd);
int npc_gettimerevent_tick(struct npc_data *nd);
int npc_settimerevent_tick(struct npc_data *nd,int newtimer);
int npc_remove_map(struct npc_data *nd);
+void npc_unload_duplicates (struct npc_data *nd);
int npc_unload(struct npc_data *nd);
int npc_reload(void);
int npc_script_event(TBL_PC* sd, int type);