This commit is contained in:
aozhiwei 2023-01-04 13:00:55 +08:00
parent 250c19a1b1
commit a443e3ea92
3 changed files with 13 additions and 4 deletions

View File

@ -31,7 +31,7 @@ Buff::Buff()
Buff::~Buff() Buff::~Buff()
{ {
int i = 0;
} }
void Buff::Init() void Buff::Init()

View File

@ -219,10 +219,16 @@ int Creature::AddBuff(Creature* caster,
buff->remover_timer = room->xtimer.SetTimeoutWpEx buff->remover_timer = room->xtimer.SetTimeoutWpEx
( (
buff_meta->duration_time() * SERVER_FRAME_RATE, buff_meta->duration_time() * SERVER_FRAME_RATE,
[buff] (int event, const a8::Args* args) [buff_wp = (std::weak_ptr<Buff>)buff] (int event, const a8::Args* args)
{ {
if (a8::TIMER_EXEC_EVENT == event) { if (a8::TIMER_EXEC_EVENT == event) {
buff->owner->RemoveBuffByUniId(buff->buff_uniid); if (!buff_wp.expired()) {
Buff* buff = nullptr;
{
buff = buff_wp.lock().get();
}
buff->owner->RemoveBuffByUniId(buff->buff_uniid);
}
} }
}, },
&buff->xtimer_attacher); &buff->xtimer_attacher);
@ -408,6 +414,9 @@ void Creature::RemoveBuffByUniId(int buff_uniid)
OnBuffRemove(*buff.get()); OnBuffRemove(*buff.get());
buff->UnInit(); buff->UnInit();
buff_list_.erase(itr); buff_list_.erase(itr);
if (buff.use_count() > 1) {
abort();
}
break; break;
} }
} }

2
third_party/a8 vendored

@ -1 +1 @@
Subproject commit dfc2c950b9ff2fd0c839034b4f173b3b22fc329e Subproject commit c72553f5429074e2c74316f81e660236fc4c2fd8