mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- fixed crash on missing icons
- proper ID resolution for secondary skills to avoid #1258
This commit is contained in:
parent
c9bbf7dfd5
commit
e71bace8e3
@ -934,6 +934,8 @@ bool CAnimation::loadFrame(CDefFile * file, size_t frame, size_t group)
|
||||
|
||||
//try to get image from def
|
||||
if (source[group][frame].getType() == JsonNode::DATA_NULL)
|
||||
{
|
||||
if (file)
|
||||
{
|
||||
auto frameList = file->getEntries();
|
||||
|
||||
@ -943,14 +945,14 @@ bool CAnimation::loadFrame(CDefFile * file, size_t frame, size_t group)
|
||||
images[group][frame] = new CompImage(file, frame, group);
|
||||
else
|
||||
images[group][frame] = new SDLImage(file, frame, group);
|
||||
return true;
|
||||
}
|
||||
else // missing image
|
||||
{
|
||||
}
|
||||
// still here? image is missing
|
||||
|
||||
printError(frame, group, "LoadFrame");
|
||||
images[group][frame] = new SDLImage("DEFAULT", compressed);
|
||||
}
|
||||
|
||||
}
|
||||
else //load from separate file
|
||||
{
|
||||
std::string filename = source[group][frame].Struct().find("file")->second.String();
|
||||
|
@ -272,11 +272,21 @@ void CHeroHandler::loadHeroSkills(CHero * hero, const JsonNode & node)
|
||||
{
|
||||
BOOST_FOREACH(const JsonNode &set, node["skills"].Vector())
|
||||
{
|
||||
SecondarySkill skillID = SecondarySkill(
|
||||
boost::range::find(NSecondarySkill::names, set["skill"].String()) - boost::begin(NSecondarySkill::names));
|
||||
int skillLevel = boost::range::find(NSecondarySkill::levels, set["level"].String()) - boost::begin(NSecondarySkill::levels);
|
||||
if (skillLevel < SecSkillLevel::LEVELS_SIZE)
|
||||
{
|
||||
size_t currentIndex = hero->secSkillsInit.size();
|
||||
hero->secSkillsInit.push_back(std::make_pair(-1, skillLevel));
|
||||
|
||||
hero->secSkillsInit.push_back(std::make_pair(skillID, skillLevel));
|
||||
VLC->modh->identifiers.requestIdentifier("skill." + set["skill"].String(), [=](si32 id)
|
||||
{
|
||||
hero->secSkillsInit[currentIndex].first = SecondarySkill(id);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
logGlobal->errorStream() << "Unknown skill level: " <<set["level"].String();
|
||||
}
|
||||
}
|
||||
|
||||
// spellbook is considered present if hero have "spellbook" entry even when this is an empty set (0 spells)
|
||||
|
@ -257,9 +257,11 @@ public:
|
||||
PATHFINDING = 0, ARCHERY, LOGISTICS, SCOUTING, DIPLOMACY, NAVIGATION, LEADERSHIP, WISDOM, MYSTICISM,
|
||||
LUCK, BALLISTICS, EAGLE_EYE, NECROMANCY, ESTATES, FIRE_MAGIC, AIR_MAGIC, WATER_MAGIC, EARTH_MAGIC,
|
||||
SCHOLAR, TACTICS, ARTILLERY, LEARNING, OFFENCE, ARMORER, INTELLIGENCE, SORCERY, RESISTANCE,
|
||||
FIRST_AID
|
||||
FIRST_AID, SKILL_SIZE
|
||||
};
|
||||
|
||||
static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills");
|
||||
|
||||
SecondarySkill(ESecondarySkill _num = WRONG) : num(_num)
|
||||
{}
|
||||
|
||||
@ -601,7 +603,8 @@ namespace SecSkillLevel
|
||||
NONE,
|
||||
BASIC,
|
||||
ADVANCED,
|
||||
EXPERT
|
||||
EXPERT,
|
||||
LEVELS_SIZE
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user