summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-11-12 22:14:18 -0500
committergumi <mekolat@users.noreply.github.com>2017-11-12 23:10:14 -0500
commit35b0508a652811a3872f13a6a161a01fee6f5d1d (patch)
tree54779cfbb457c11edf8aee47c4dc44738953e8ec
parentd0ea54965867c7f93da490b5f1a95f7ac4000bbb (diff)
downloadtmwa-35b0508a652811a3872f13a6a161a01fee6f5d1d.tar.gz
tmwa-35b0508a652811a3872f13a6a161a01fee6f5d1d.tar.bz2
tmwa-35b0508a652811a3872f13a6a161a01fee6f5d1d.tar.xz
tmwa-35b0508a652811a3872f13a6a161a01fee6f5d1d.zip
re-fix the puppet despawn bug
-rw-r--r--src/map/atcommand.cpp2
-rw-r--r--src/map/map.cpp8
-rw-r--r--src/map/npc.cpp8
3 files changed, 16 insertions, 2 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index a138b72..0b783a0 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -3610,6 +3610,8 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr<map_session_data> sd,
for (int i = 0; i < m_id->npc_num;)
{
nd = m_id->npc[i];
+ if (nd == nullptr) continue;
+
switch (nd->dir)
{
case DIR::S:
diff --git a/src/map/map.cpp b/src/map/map.cpp
index e7b0da8..3538a59 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -1009,9 +1009,12 @@ dumb_ptr<block_list> map_id2bl(BlockId id)
int map_addnpc(Borrowed<map_local> m, dumb_ptr<npc_data> nd)
{
int i;
- for (i = 0; i < m->npc_num && i < MAX_NPC_PER_MAP; i++)
- if (m->npc[i] == nullptr)
+ for (i = 0; i < m->npc_num && i < MAX_NPC_PER_MAP; i++) {
+ if (m->npc[i] == nullptr) {
+ PRINTF(">>>>>> reusing npc %i\n"_fmt, i);
break;
+ }
+ }
if (i == MAX_NPC_PER_MAP)
{
if (battle_config.error_log)
@@ -1020,6 +1023,7 @@ int map_addnpc(Borrowed<map_local> m, dumb_ptr<npc_data> nd)
}
if (i == m->npc_num)
{
+ PRINTF(">>>>>> using new npc %i\n"_fmt, i);
m->npc_num++;
}
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 2600117..32a5a54 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -675,6 +675,9 @@ int npc_touch_areanpc(dumb_ptr<map_session_data> sd, Borrowed<map_local> m, int
for (i = 0; i < m->npc_num; i++)
{
+ if (m->npc[i] == nullptr)
+ continue;
+
if (m->npc[i]->flag & 1)
continue;
@@ -1046,6 +1049,11 @@ void npc_free_internal(dumb_ptr<npc_data> nd_)
}
if (nd_->name)
npcs_by_name.put(nd_->name, nullptr);
+
+ if (nd_->bl_m != borrow(undefined_gat)) {
+ nd_->bl_m->npc[nd_->n] = nullptr;
+ }
+
nd_.delete_();
}