summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-08-25 19:57:45 +0200
committerHaru <haru@dotalux.com>2019-08-26 01:45:36 +0200
commitf0b91a79a0f8031d3cd6289ceafead93817bc4a7 (patch)
tree8ee750d89c7c0f3695a1660afa89ce975c2f4c79
parent29e6bbef1b7d4c2434cc6bc8e7a0226227ec6281 (diff)
downloadhercules-f0b91a79a0f8031d3cd6289ceafead93817bc4a7.tar.gz
hercules-f0b91a79a0f8031d3cd6289ceafead93817bc4a7.tar.bz2
hercules-f0b91a79a0f8031d3cd6289ceafead93817bc4a7.tar.xz
hercules-f0b91a79a0f8031d3cd6289ceafead93817bc4a7.zip
Prevent players from getting stuck when an MVP respawns while talking to its tombstone
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--src/map/mob.c8
-rw-r--r--src/map/npc.c6
-rw-r--r--src/map/pc.h1
3 files changed, 13 insertions, 2 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index bad3f7eb8..e04d6944e 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -239,6 +239,14 @@ static void mvptomb_destroy(struct mob_data *md)
m = nd->bl.m;
+ struct s_mapiterator *iter = mapit_geteachpc();
+ for (struct map_session_data *sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) {
+ if (sd->npc_id == nd->bl.id) {
+ sd->state.npc_unloaded = 1;
+ }
+ }
+ mapit->free(iter);
+
clif->clearunit_area(&nd->bl,CLR_OUTSIGHT);
map->delblock(&nd->bl);
diff --git a/src/map/npc.c b/src/map/npc.c
index c3dff5870..1e9e13b42 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1349,8 +1349,10 @@ static int npc_scriptcont(struct map_session_data *sd, int id, bool closing)
return 1;
}
- if(id != npc->fake_nd->bl.id) { // Not item script
- if ((npc->checknear(sd,target)) == NULL){
+ if (id != npc->fake_nd->bl.id) { // Not item script
+ if (sd->state.npc_unloaded != 0) {
+ sd->state.npc_unloaded = 0;
+ } else if ((npc->checknear(sd,target)) == NULL) {
ShowWarning("npc_scriptcont: failed npc->checknear test.\n");
return 1;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 8df02a891..82abbccf0 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -238,6 +238,7 @@ struct map_session_data {
unsigned int loggingout : 1;
unsigned int warp_clean : 1;
unsigned int refine_ui : 1;
+ unsigned int npc_unloaded : 1; ///< The player is talking with an unloaded NPCs (respawned tombstones)
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;