Skip to content

Commit

Permalink
crash and log fix (#1382)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC authored Jan 3, 2024
1 parent bb79528 commit a84ca1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dCommon/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Writer::~Writer() {
}

void Writer::Log(const char* time, const char* message) {
if (!m_Outfile) return;
if (!m_Outfile || !m_Enabled) return;

fputs(time, m_Outfile);
fputs(message, m_Outfile);
Expand Down
12 changes: 9 additions & 3 deletions dGame/dComponents/BuffComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,16 @@ void BuffComponent::Update(float deltaTime) {

if (buff.second.time <= 0.0f) {
RemoveBuff(buff.first);

break;
}
}

if (m_BuffsToRemove.empty()) return;

for (const auto& buff : m_BuffsToRemove) {
m_Buffs.erase(buff);
}

m_BuffsToRemove.clear();
}

const std::string& GetFxName(const std::string& buffname) {
Expand Down Expand Up @@ -216,7 +222,7 @@ void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity

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

m_Buffs.erase(iter);
m_BuffsToRemove.push_back(id);

RemoveBuffEffect(id);
}
Expand Down
3 changes: 3 additions & 0 deletions dGame/dComponents/BuffComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class BuffComponent : 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;

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

0 comments on commit a84ca1f

Please sign in to comment.