1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Fix possible crash on levelup when hero can only levelup banned skills

This commit is contained in:
Ivan Savenko 2024-11-19 14:39:40 +00:00
parent f0a71c9e21
commit a7a9f5d777

View File

@ -30,7 +30,10 @@ SecondarySkill CHeroClass::chooseSecSkill(const std::set<SecondarySkill> & 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
}