mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Fixed Bonus parser crashing at unspecified value. Assigning empty objects is also not good solution.
This commit is contained in:
@@ -3236,7 +3236,7 @@ TSubgoal CGoal::whatToDoToAchieve()
|
|||||||
int primaryPath, secondaryPath;
|
int primaryPath, secondaryPath;
|
||||||
auto h = otherHeroes.back();
|
auto h = otherHeroes.back();
|
||||||
cb->setSelection(hero.h);
|
cb->setSelection(hero.h);
|
||||||
primaryPath = cb->getPathInfo(h->pos)->turns;
|
primaryPath = cb->getPathInfo(h->pos)->turns; //FIXME: investigate crash at this line
|
||||||
cb->setSelection(h);
|
cb->setSelection(h);
|
||||||
secondaryPath = cb->getPathInfo(hero->pos)->turns;
|
secondaryPath = cb->getPathInfo(hero->pos)->turns;
|
||||||
|
|
||||||
|
@@ -942,6 +942,8 @@ const T & parseByMap(const std::map<std::string, T> & map, const JsonNode * val,
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return T();
|
||||||
};
|
};
|
||||||
|
|
||||||
Bonus * ParseBonus (const JsonNode &ability)
|
Bonus * ParseBonus (const JsonNode &ability)
|
||||||
@@ -967,7 +969,9 @@ Bonus * ParseBonus (const JsonNode &ability)
|
|||||||
if (!value->isNull())
|
if (!value->isNull())
|
||||||
b->val = value->Float();
|
b->val = value->Float();
|
||||||
|
|
||||||
b->valType = parseByMap(bonusValueMap, &ability["valueType"], "value type ");
|
value = &ability["valueType"];
|
||||||
|
if (!value->isNull())
|
||||||
|
b->valType = parseByMap(bonusValueMap, value, "value type ");
|
||||||
|
|
||||||
value = &ability["additionalInfo"];
|
value = &ability["additionalInfo"];
|
||||||
if (!value->isNull())
|
if (!value->isNull())
|
||||||
@@ -985,11 +989,15 @@ Bonus * ParseBonus (const JsonNode &ability)
|
|||||||
if (!value->isNull())
|
if (!value->isNull())
|
||||||
b->description = value->String();
|
b->description = value->String();
|
||||||
|
|
||||||
b->effectRange = parseByMap(bonusLimitEffect, &ability["effectRange"], "effect range ");
|
value = &ability["effectRange"];
|
||||||
|
if (!value->isNull())
|
||||||
b->duration = parseByMap(bonusDurationMap, &ability["duration"], "duration type ");
|
b->valType = parseByMap(bonusValueMap, value, "effect range ");
|
||||||
|
value = &ability["duration"];
|
||||||
b->source = parseByMap(bonusSourceMap, &ability["source"], "source type ");
|
if (!value->isNull())
|
||||||
|
b->valType = parseByMap(bonusValueMap, value, "duration type ");
|
||||||
|
value = &ability["source"];
|
||||||
|
if (!value->isNull())
|
||||||
|
b->valType = parseByMap(bonusValueMap, value, "source type ");
|
||||||
|
|
||||||
// value = &ability["limiter"];
|
// value = &ability["limiter"];
|
||||||
// if (!value->isNull())
|
// if (!value->isNull())
|
||||||
|
Reference in New Issue
Block a user