mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
* Fixed enchantments (#1265). Their effects were not properly added when reading config. Battle interface will be little less likely to block itself after corrupted spell cast.
* Fail gracefully when the file from which game is started is in invalid version. * Bumped versions.
This commit is contained in:
@@ -248,14 +248,19 @@ CSpell::ETargetType CSpell::getTargetType() const
|
||||
|
||||
void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const
|
||||
{
|
||||
if (level < 0 || level>3)
|
||||
if (level < 0 || level >= GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
{
|
||||
logGlobal->errorStream() << __FUNCTION__ << " invalid school level " << level;
|
||||
return;
|
||||
}
|
||||
if (effects.empty())
|
||||
{
|
||||
logGlobal->errorStream() << __FUNCTION__ << " This spell has no bonus effects! " << name;
|
||||
logGlobal->errorStream() << __FUNCTION__ << " This spell (" + name + ") has no bonus effects! " << name;
|
||||
return;
|
||||
}
|
||||
if (effects.size() <= level)
|
||||
{
|
||||
logGlobal->errorStream() << __FUNCTION__ << " This spell (" + name + ") is missing entry for level " << level;
|
||||
return;
|
||||
}
|
||||
lst.reserve(lst.size() + effects[level].size());
|
||||
@@ -440,7 +445,8 @@ CSpellHandler::CSpellHandler()
|
||||
spells.push_back(spells[SpellID::ACID_BREATH_DEFENSE]); //clone Acid Breath attributes for Acid Breath damage effect
|
||||
|
||||
//loading of additional spell traits
|
||||
const JsonNode config(ResourceID("config/spell_info.json"));
|
||||
JsonNode config(ResourceID("config/spell_info.json"));
|
||||
config.setMeta("core");
|
||||
|
||||
BOOST_FOREACH(auto &spell, config["spells"].Struct())
|
||||
{
|
||||
@@ -493,7 +499,14 @@ CSpellHandler::CSpellHandler()
|
||||
auto v = v_node.convertTo<std::vector<int> >();
|
||||
auto a = a_node.convertTo<std::vector<int> >();
|
||||
|
||||
for (int i=0; i<s->effects.size() ; i++)
|
||||
if(v.size() && v.size() != GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
logGlobal->errorStream() << s->name << " should either have no values or exactly " << GameConstants::SPELL_SCHOOL_LEVELS;
|
||||
if(a.size() && a.size() != GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
logGlobal->errorStream() << s->name << " should either have no ainfos or exactly " << GameConstants::SPELL_SCHOOL_LEVELS;
|
||||
|
||||
s->effects.resize(GameConstants::SPELL_SCHOOL_LEVELS);
|
||||
|
||||
for (int i = 0; i < GameConstants::SPELL_SCHOOL_LEVELS; i++)
|
||||
{
|
||||
Bonus * b = JsonUtils::parseBonus(bonus_node);
|
||||
b->sid = s->id; //for all
|
||||
|
Reference in New Issue
Block a user