From 50cbf2f3e956d6facafb6b607b8181101ad5de49 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Jul 2019 16:31:58 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 16 ++++++++++++++++ server/gameserver/human.h | 1 + 2 files changed, 17 insertions(+) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 91164c4..b033f74 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -482,6 +482,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) }, &xtimer_attacher.timer_list_ ); + ClearBuffList(); room->frame_event.AddDead(this); room->OnHumanDie(this); { @@ -1209,6 +1210,21 @@ void Human::RemoveBuffByEffectId(int buff_effect_id) } } +void Human::ClearBuffList() +{ + for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) { + if (buff_effect_[itr->meta->i->buff_effect()] == &(*itr)) { + buff_effect_[itr->meta->i->buff_effect()] = nullptr; + } + room->frame_event.RemoveBuff(this, itr->meta->i->buff_id()); + } + buff_list_.clear(); + buff_effect_ = {}; + buff_attr_abs_ = {}; + buff_attr_rate_ = {}; + RecalcBuffAttr(); +} + bool Human::HasBuffEffect(int buff_effect_id) { return GetBuffByEffectId(buff_effect_id) != nullptr; diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 2581983..ffd1a61 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -186,6 +186,7 @@ class Human : public Entity void AddBuff(MetaData::Buff* buff_meta); void RemoveBuffById(int buff_id); void RemoveBuffByEffectId(int buff_effect_id); + void ClearBuffList(); bool HasBuffEffect(int buff_effect_id); Buff* GetBuffByEffectId(int effect_id); void RecalcBuffAttr();