From 8ed1576d9748cbdd2552707c470d1563e63ffe64 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 24 May 2024 15:46:04 +0800 Subject: [PATCH] 1 --- server/gameserver/buff/callfunc.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/server/gameserver/buff/callfunc.cc b/server/gameserver/buff/callfunc.cc index 074cf8d8..5f56a690 100644 --- a/server/gameserver/buff/callfunc.cc +++ b/server/gameserver/buff/callfunc.cc @@ -1938,20 +1938,23 @@ void CallFuncBuff::BulletDmgCalcProc() int attr_id = meta->GetBuffParam3(this); float attr_val = meta->GetBuffParam4(this); float cond = meta->GetBuffParam5(this); - AttrHandle attr_handle; + auto context = A8_MAKE_ANON_STRUCT_SHARED + ( + AttrHandle attr_handle; + ); auto clear_func = - [this, target_type, &attr_handle] (Creature* c) + [this, target_type, context] (Creature* c) { if (target_type == 0) { - owner->GetAbility()->RemoveAttr(attr_handle); + owner->GetAbility()->RemoveAttr(context->attr_handle); } else if (target_type == 1) { - c->GetAbility()->RemoveAttr(attr_handle); + c->GetAbility()->RemoveAttr(context->attr_handle); } }; auto start_handle = owner->GetTrigger()->AddListener ( kBulletDmgStartEvent, - [this, &attr_handle, target_type, attr_id, attr_val, cond, clear_func] + [this, context, target_type, attr_id, attr_val, cond, clear_func] (const a8::Args& args) mutable { Creature* target = args.Get(0); @@ -1962,9 +1965,9 @@ void CallFuncBuff::BulletDmgCalcProc() bool match = target->GetHP() / target->GetMaxHP() < cond; if (match) { if (target_type == 0) { - attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val); + context->attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val); } else if (target_type == 1) { - attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val); + context->attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val); } } }