From bb2e93a539c5cf82f0c64995ffe40aad486af9a2 Mon Sep 17 00:00:00 2001 From: jeefo Date: Tue, 25 Apr 2023 09:12:06 +0300 Subject: [PATCH] fix: potential division by zero --- inc/graph.h | 2 +- src/graph.cpp | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/inc/graph.h b/inc/graph.h index 25847d5..0b0f593 100644 --- a/inc/graph.h +++ b/inc/graph.h @@ -398,7 +398,7 @@ public: } int getHighestDamageForTeam (int team) const { - return m_highestDamage[team]; + return cr::max (1, m_highestDamage[team]); } void setHighestDamageForTeam (int team, int value) { diff --git a/src/graph.cpp b/src/graph.cpp index 4de8a9c..886ead8 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -30,10 +30,6 @@ void BotGraph::reset () { m_hasChanged = false; m_narrowChecked = false; - // reset highest recorded damage - for (int team = Team::Terrorist; team < kGameTeamNum; ++team) { - m_highestDamage[team] = 1; - } m_graphAuthor.clear (); m_graphModified.clear (); } @@ -1266,11 +1262,6 @@ void BotGraph::loadPractice () { return; } - // reset highest recorded damage - for (int team = Team::Terrorist; team < kGameTeamNum; ++team) { - m_highestDamage[team] = 1; - } - bool dataLoaded = loadStorage ("Practice", StorageOption::Practice, StorageVersion::Practice, m_practice, nullptr, nullptr); int count = length ();