修复child_buff_隐患
This commit is contained in:
parent
5db58d028a
commit
a0c8d9cd9f
@ -37,6 +37,7 @@ class Buff
|
|||||||
float res_scale = 1;
|
float res_scale = 1;
|
||||||
long long res_scale_frameno = 0;
|
long long res_scale_frameno = 0;
|
||||||
std::shared_ptr<std::vector<float>> buff_vars;
|
std::shared_ptr<std::vector<float>> buff_vars;
|
||||||
|
std::shared_ptr<std::list<int>> child_buff_uniids;
|
||||||
|
|
||||||
Buff();
|
Buff();
|
||||||
virtual ~Buff();
|
virtual ~Buff();
|
||||||
|
@ -398,7 +398,18 @@ int Creature::AddBuff(Creature* caster,
|
|||||||
for (int child_buff_id : buff->meta->_child_buff_list) {
|
for (int child_buff_id : buff->meta->_child_buff_list) {
|
||||||
const mt::Buff* child_buff_meta = mt::Buff::GetById(child_buff_id);
|
const mt::Buff* child_buff_meta = mt::Buff::GetById(child_buff_id);
|
||||||
if (child_buff_meta) {
|
if (child_buff_meta) {
|
||||||
AddBuff(caster, child_buff_meta, buff_skill_meta, true, init_args, buff_vars);
|
int child_buff_uniid = AddBuff(caster,
|
||||||
|
child_buff_meta,
|
||||||
|
buff_skill_meta,
|
||||||
|
true,
|
||||||
|
init_args,
|
||||||
|
buff_vars);
|
||||||
|
if (child_buff_uniid) {
|
||||||
|
if (!buff->child_buff_uniids) {
|
||||||
|
buff->child_buff_uniids = std::make_shared<std::list<int>>();
|
||||||
|
}
|
||||||
|
buff->child_buff_uniids->push_back(child_buff_uniid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -537,7 +548,7 @@ void Creature::RemoveBuffById(int buff_id)
|
|||||||
void Creature::RemoveBuffByUniId(int buff_uniid)
|
void Creature::RemoveBuffByUniId(int buff_uniid)
|
||||||
{
|
{
|
||||||
int buff_id = 0;
|
int buff_id = 0;
|
||||||
std::vector<std::tuple<const mt::Buff*, Creature*>> removed_buffs;
|
std::vector<std::tuple<const mt::Buff*, Creature*, std::shared_ptr<std::list<int>>>> removed_buffs;
|
||||||
std::shared_ptr<Buff> buff;
|
std::shared_ptr<Buff> buff;
|
||||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||||
if ((*itr)->buff_uniid == buff_uniid) {
|
if ((*itr)->buff_uniid == buff_uniid) {
|
||||||
@ -553,7 +564,7 @@ void Creature::RemoveBuffByUniId(int buff_uniid)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
removed_buffs.push_back(std::make_tuple(buff->meta, buff->GetCaster().Get()));
|
removed_buffs.push_back(std::make_tuple(buff->meta, buff->GetCaster().Get(), buff->child_buff_uniids));
|
||||||
OnBuffRemove(*buff.get());
|
OnBuffRemove(*buff.get());
|
||||||
buff->UnInit();
|
buff->UnInit();
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
@ -578,10 +589,19 @@ void Creature::RemoveBuffByUniId(int buff_uniid)
|
|||||||
for (auto& tuple1 : removed_buffs) {
|
for (auto& tuple1 : removed_buffs) {
|
||||||
const mt::Buff* buff_meta = std::get<0>(tuple1);
|
const mt::Buff* buff_meta = std::get<0>(tuple1);
|
||||||
Creature* caster = std::get<1>(tuple1);
|
Creature* caster = std::get<1>(tuple1);
|
||||||
|
std::shared_ptr<std::list<int>> child_buff_uniids = std::get<2>(tuple1);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
if (child_buff_uniids) {
|
||||||
|
for (auto child_buff_uniid : *child_buff_uniids) {
|
||||||
|
RemoveBuffByUniId(child_buff_uniid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
for (int child_buff_id : buff_meta->_child_buff_list) {
|
for (int child_buff_id : buff_meta->_child_buff_list) {
|
||||||
RemoveBuffById(child_buff_id);
|
RemoveBuffById(child_buff_id);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!HasBuffEffect(buff_meta->buff_effect()) &&
|
if (!HasBuffEffect(buff_meta->buff_effect()) &&
|
||||||
!list_empty(&depend_effect_[buff_meta->buff_effect()])) {
|
!list_empty(&depend_effect_[buff_meta->buff_effect()])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user