1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Merge pull request #4943 from IvanSavenko/levelup_fix

Fix possible crash on levelup when hero can only levelup banned skills
This commit is contained in:
Ivan Savenko 2024-11-20 14:38:43 +02:00 committed by GitHub
commit 03273ed324
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
}