1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

fix for develop

This commit is contained in:
Laserlicht
2024-06-21 22:34:14 +02:00
parent 49cb985452
commit 11664b27b8
2 changed files with 21 additions and 4 deletions

View File

@@ -449,7 +449,16 @@ void QuickSpellPanel::create()
for(int i = 0; i < 10; i++) {
std::string spellIdentifier = persistentStorage["quickSpell"][std::to_string(i)].String();
SpellID id = SpellID::decode(spellIdentifier);
SpellID id;
try
{
id = SpellID::decode(spellIdentifier);
}
catch(const IdentifierResolutionException& e)
{
id = SpellID::NONE;
}
auto button = std::make_shared<CButton>(Point(2, 1 + 37 * i), AnimationPath::builtin("spellint"), CButton::tooltip(), [this, id, hero](){
if(id.hasValue() && id.toSpell()->canBeCast(owner.getBattle().get(), spells::Mode::HERO, hero))
@@ -529,7 +538,7 @@ QuickSpellPanelSelect::QuickSpellPanelSelect(QuickSpellPanel * Parent)
setEnabled(false);
std::vector<ConstTransitivePtr<CSpell>> spellList;
std::vector<std::shared_ptr<CSpell>> spellList;
for (auto const & s : VLC->spellh->objects)
if (s->isCombat() && !s->isSpecial() && !s->isCreatureAbility())
spellList.push_back(s);
@@ -545,7 +554,7 @@ QuickSpellPanelSelect::QuickSpellPanelSelect(QuickSpellPanel * Parent)
{
int y = i % 10;
int x = i / 10;
ConstTransitivePtr<CSpell> spell = spellList[i];
std::shared_ptr<CSpell> spell = spellList[i];
auto button = std::make_shared<CButton>(Point(2 + 50 * x, 1 + 37 * y), AnimationPath::builtin("spellint"), CButton::tooltip(), [this, spell](){
setEnabled(false);
GH.windows().totalRedraw();

View File

@@ -66,7 +66,15 @@ BattleWindow::BattleWindow(BattleInterface & Owner):
auto useSpellIfPossible = [this](int slot){
std::string spellIdentifier = persistentStorage["quickSpell"][std::to_string(slot)].String();
SpellID id = SpellID::decode(spellIdentifier);
SpellID id;
try
{
id = SpellID::decode(spellIdentifier);
}
catch(const IdentifierResolutionException& e)
{
return;
}
if(id.hasValue() && owner.getBattle()->battleGetMyHero() && id.toSpell()->canBeCast(owner.getBattle().get(), spells::Mode::HERO, owner.getBattle()->battleGetMyHero()))
{
owner.castThisSpell(id);