From a7a9f5d777f8d16e474fc108824aa35f038d60ce Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 19 Nov 2024 14:39:40 +0000 Subject: [PATCH] Fix possible crash on levelup when hero can only levelup banned skills --- lib/entities/hero/CHeroClass.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/entities/hero/CHeroClass.cpp b/lib/entities/hero/CHeroClass.cpp index 4a8d6d308..80e06cabf 100644 --- a/lib/entities/hero/CHeroClass.cpp +++ b/lib/entities/hero/CHeroClass.cpp @@ -30,7 +30,10 @@ SecondarySkill CHeroClass::chooseSecSkill(const std::set & possi { skills.push_back(possible); if (secSkillProbability.count(possible) != 0) - weights.push_back(secSkillProbability.at(possible)); + { + int weight = secSkillProbability.at(possible); + weights.push_back(std::max(1, weight)); + } else weights.push_back(1); // H3 behavior - banned skills have minimal (1) chance to be picked }