Skip to content

Commit

Permalink
buffRemoval (#1464)
Browse files Browse the repository at this point in the history
Update BuffComponent.cpp
  • Loading branch information
EmosewaMC authored Feb 25, 2024
1 parent 721ea78 commit 1328850
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions dGame/dComponents/BuffComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,8 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity, bool ignoreRefCount) {
const auto& iter = m_Buffs.find(id);

if (iter == m_Buffs.end()) {
return;
}
// If the buff is already scheduled to be removed, don't do it again
if (iter == m_Buffs.end() || m_BuffsToRemove.contains(id)) return;

if (!ignoreRefCount && !iter->second.cancelOnRemoveBuff) {
iter->second.refCount--;
Expand All @@ -222,7 +221,7 @@ void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity

GameMessages::SendRemoveBuff(m_Parent, fromUnEquip, removeImmunity, id);

m_BuffsToRemove.push_back(id);
m_BuffsToRemove.insert(id);

RemoveBuffEffect(id);
}
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/BuffComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class BuffComponent final : public Component {
std::map<int32_t, Buff> m_Buffs;

// Buffs to remove at the end of the update frame.
std::vector<int32_t> m_BuffsToRemove;
std::set<int32_t> m_BuffsToRemove;

/**
* Parameters (=effects) for each buff
Expand Down

0 comments on commit 1328850

Please sign in to comment.