1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix potential crash on right-clicking object that gives secondary skills

such as Witch Hut when town is selected
This commit is contained in:
Ivan Savenko 2024-07-10 14:34:05 +00:00
parent d442da92f6
commit 22870c4764

View File

@ -106,7 +106,7 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps, const CG
{
auto skillID = entry.first;
int levelsGained = entry.second;
int currentLevel = h->getSecSkillLevel(skillID);
int currentLevel = h ? h->getSecSkillLevel(skillID) : 0;
int finalLevel = std::min(static_cast<int>(MasteryLevel::EXPERT), currentLevel + levelsGained);
comps.emplace_back(ComponentType::SEC_SKILL, entry.first, finalLevel);
}