mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Fixed scholar skill icon in the scholar dialog
The icon was for one level higher than the actuall skill level, especially problematic for expert where right-clicking the icon woould cause a crash
This commit is contained in:
parent
569db9ed5d
commit
bfd57ab5b5
@ -2762,21 +2762,21 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
{
|
||||
const CGHeroInstance * h1 = getHero(fromHero);
|
||||
const CGHeroInstance * h2 = getHero(toHero);
|
||||
int h1_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR);
|
||||
int h2_scholarLevel = h2->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR);
|
||||
int h1_scholarSpellLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR);
|
||||
int h2_scholarSpellLevel = h2->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR);
|
||||
|
||||
if (h1_scholarLevel < h2_scholarLevel)
|
||||
if (h1_scholarSpellLevel < h2_scholarSpellLevel)
|
||||
{
|
||||
std::swap (h1,h2);//1st hero need to have higher scholar level for correct message
|
||||
std::swap(fromHero, toHero);
|
||||
}
|
||||
|
||||
int ScholarLevel = std::max(h1_scholarLevel, h2_scholarLevel);//heroes can trade up to this level
|
||||
if (!ScholarLevel || !h1->hasSpellbook() || !h2->hasSpellbook())
|
||||
int ScholarSpellLevel = std::max(h1_scholarSpellLevel, h2_scholarSpellLevel);//heroes can trade up to this level
|
||||
if (!ScholarSpellLevel || !h1->hasSpellbook() || !h2->hasSpellbook())
|
||||
return;//no scholar skill or no spellbook
|
||||
|
||||
int h1Lvl = std::min(ScholarLevel, h1->maxSpellLevel()),
|
||||
h2Lvl = std::min(ScholarLevel, h2->maxSpellLevel());//heroes can receive this levels
|
||||
int h1Lvl = std::min(ScholarSpellLevel, h1->maxSpellLevel()),
|
||||
h2Lvl = std::min(ScholarSpellLevel, h2->maxSpellLevel());//heroes can receive this levels
|
||||
|
||||
ChangeSpells cs1;
|
||||
cs1.learn = true;
|
||||
@ -2795,9 +2795,11 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
|
||||
if (!cs1.spells.empty() || !cs2.spells.empty())//create a message
|
||||
{
|
||||
int ScholarSkillLevel = std::max(h1->getSecSkillLevel(SecondarySkill::SCHOLAR),
|
||||
h2->getSecSkillLevel(SecondarySkill::SCHOLAR));
|
||||
InfoWindow iw;
|
||||
iw.player = h1->tempOwner;
|
||||
iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarLevel, 0));
|
||||
iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarSkillLevel, 0));
|
||||
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
|
||||
iw.text.addReplacement(h1->name);
|
||||
|
Loading…
Reference in New Issue
Block a user