1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

fixed crash when loading neutral faction; skills.json no longer requires index values

This commit is contained in:
Henning Koehler
2017-08-25 17:17:14 +12:00
parent 0357a4fe3b
commit c0740e3623
6 changed files with 41 additions and 7 deletions

View File

@@ -150,6 +150,34 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string &
return skill;
}
void CSkillHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
auto type_name = getTypeName();
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
if(object->id == SecondarySkill::DEFAULT) // new skill - no index identified
{
object->id = SecondarySkill(objects.size());
objects.push_back(object);
}
else
objects[object->id] = object;
registerObject(scope, type_name, name, object->id);
}
void CSkillHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
auto type_name = getTypeName();
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
assert(object->id == index);
objects[index] = object;
registerObject(scope,type_name, name, object->id);
}
void CSkillHandler::afterLoadFinalization()
{
CLogger * logger = CLogger::getLogger(CLoggerDomain(getTypeName()));