From c2586b87e919da0f46f47df9660158b46a6141e8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Oct 2022 09:03:16 +0800 Subject: [PATCH] 1 --- server/gameserver/creature.cc | 40 +++++++++++++++++------------------ server/gameserver/creature.h | 2 +- third_party/a8engine | 2 +- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index e42737d0..4a890c60 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -682,28 +682,26 @@ int Creature::TryAddBuff(Creature* caster, int buff_id) return -1; } -void Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time) +std::weak_ptr Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time) { - MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id); - if (buff_meta) { - room->xtimer.AddDeadLineTimerAndAttach - ( - time / FRAME_RATE_MS, - a8::XParams() - .SetSender(this) - .SetParam1(caster->GetUniId()) - .SetParam2(buff_id), - [] (const a8::XParams& param) - { - Creature* c = (Creature*)param.sender.GetUserData(); - Entity* e = c->room->GetEntityByUniId(param.param1); - if (e->IsCreature(c->room) && !c->IsDead(c->room)) { - c->TryAddBuff((Creature*)e, param.param2); - } - }, - &xtimer_attacher.timer_list_ - ); - } + xtimer_list* timer = room->xtimer.AddDeadLineTimerAndAttach + ( + time / FRAME_RATE_MS, + a8::XParams() + .SetSender(this) + .SetParam1(caster->GetUniId()) + .SetParam2(buff_id), + [] (const a8::XParams& param) + { + Creature* c = (Creature*)param.sender.GetUserData(); + Entity* e = c->room->GetEntityByUniId(param.param1); + if (e->IsCreature(c->room) && !c->IsDead(c->room)) { + c->TryAddBuff((Creature*)e, param.param2); + } + }, + &xtimer_attacher.timer_list_ + ); + return room->xtimer.GetTimerPtr(timer); } int Creature::TryAddBuffWithTarget(Creature* caster, int buff_id) diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index ad363240..5e28151a 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -136,7 +136,7 @@ class Creature : public MoveableEntity bool no_check_immune = false); bool IsImmuneBuffEffect(int buff_effect); int MustBeAddBuff(Creature* caster, int buff_id); - void TryDelayAddBuff(Creature* caster, int buff_id, int time); + std::weak_ptr TryDelayAddBuff(Creature* caster, int buff_id, int time); int TryAddBuff(Creature* caster, int buff_id); int TryAddBuffWithTarget(Creature* caster, int buff_id); void RemoveBuffById(int buff_id); diff --git a/third_party/a8engine b/third_party/a8engine index feaf1958..cf4607dd 160000 --- a/third_party/a8engine +++ b/third_party/a8engine @@ -1 +1 @@ -Subproject commit feaf1958a808725df7a2b0ede65c2733965064cd +Subproject commit cf4607dd902bcca2ec8e849b51a1968ffb2dc0ca