1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

Merge pull request #4891 from kdmcser/fix_research_spell_crash

fix spell research crash when no more spells can be researched
This commit is contained in:
Ivan Savenko 2024-11-13 20:50:24 +02:00 committed by GitHub
commit 46e492be01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -85,6 +85,7 @@
"vcmi.spellResearch.research" : "研究此法术",
"vcmi.spellResearch.skip" : "跳过此法术",
"vcmi.spellResearch.abort" : "中止",
"vcmi.spellResearch.noMoreSpells" : "没有更多的法术可供研究。",
"vcmi.mainMenu.serverConnecting" : "连接中...",
"vcmi.mainMenu.serverAddressEnter" : "使用地址:",
@ -705,6 +706,8 @@
"core.bonus.DISINTEGRATE.description": "死亡后不会留下尸体",
"core.bonus.INVINCIBLE.name": "无敌",
"core.bonus.INVINCIBLE.description": "不受任何效果影响",
"core.bonus.MECHANICAL.name": "机械",
"core.bonus.MECHANICAL.description": "免疫大多数效果,可修复",
"core.bonus.PRISM_HEX_ATTACK_BREATH.name": "棱光吐息",
"core.bonus.PRISM_HEX_ATTACK_BREATH.description": "攻击后向三方向扩散攻击"
}

View File

@ -85,6 +85,7 @@
"vcmi.spellResearch.research" : "Research this Spell",
"vcmi.spellResearch.skip" : "Skip this Spell",
"vcmi.spellResearch.abort" : "Abort",
"vcmi.spellResearch.noMoreSpells" : "There are no more spells available for research.",
"vcmi.mainMenu.serverConnecting" : "Connecting...",
"vcmi.mainMenu.serverAddressEnter" : "Enter address:",

View File

@ -2055,7 +2055,14 @@ void CMageGuildScreen::Scroll::clickPressed(const Point & cursorPosition)
auto cost = costBase * std::pow(town->spellResearchAcceptedCounter + 1, costExponent);
std::vector<std::shared_ptr<CComponent>> resComps;
auto newSpell = town->spells[level].at(town->spellsAtLevel(level, false));
int index = town->spellsAtLevel(level, false);
if (index >= town->spells[level].size())
{
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.spellResearch.noMoreSpells"));
return;
}
auto newSpell = town->spells[level].at(index);
resComps.push_back(std::make_shared<CComponent>(ComponentType::SPELL, spell->id));
resComps.push_back(std::make_shared<CComponent>(ComponentType::SPELL, newSpell));
resComps.back()->newLine = true;