1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Revert @24efb9b4

This commit is contained in:
AlexVinS 2014-11-14 03:29:11 +03:00
parent 8979de7960
commit 7a429fc38b

View File

@ -703,7 +703,7 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
}); });
} }
const std::string targetType = json["targetType"].String(); auto targetType = json["targetType"].String();
if(targetType == "NO_TARGET") if(targetType == "NO_TARGET")
spell->targetType = CSpell::NO_TARGET; spell->targetType = CSpell::NO_TARGET;
@ -711,16 +711,18 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
spell->targetType = CSpell::CREATURE; spell->targetType = CSpell::CREATURE;
else if(targetType == "OBSTACLE") else if(targetType == "OBSTACLE")
spell->targetType = CSpell::OBSTACLE; spell->targetType = CSpell::OBSTACLE;
else
logGlobal->warnStream() << "Spell " << spell->name << ". Target type " << (targetType.empty() ? "empty" : "unknown ("+targetType+")") << ". Assumed NO_TARGET.";
spell->mainEffectAnim = json["anim"].Float(); spell->mainEffectAnim = json["anim"].Float();
for(const auto & counteredSpell: json["counters"].Struct()) for(const auto & counteredSpell: json["counters"].Struct())
if (counteredSpell.second.Bool()) if (counteredSpell.second.Bool())
{ {
VLC->modh->identifiers.requestIdentifier(json.meta, "spell", counteredSpell.first, [=](si32 id) JsonNode tmp(JsonNode::DATA_STRING);
{ tmp.meta = json.meta;
tmp.String() = counteredSpell.first;
VLC->modh->identifiers.requestIdentifier(tmp,[=](si32 id){
spell->counteredSpells.push_back(SpellID(id)); spell->counteredSpells.push_back(SpellID(id));
}); });
} }
@ -759,12 +761,12 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
else if(!implicitPositiveness) else if(!implicitPositiveness)
{ {
spell->positiveness = CSpell::NEUTRAL; //duplicates constructor but, just in case spell->positiveness = CSpell::NEUTRAL; //duplicates constructor but, just in case
logGlobal->warnStream() << "Spell " << spell->name << ": no positiveness specified, assumed NEUTRAL"; logGlobal->errorStream() << "No positiveness specified, assumed NEUTRAL";
} }
spell->isSpecial = flags["special"].Bool(); spell->isSpecial = flags["special"].Bool();
auto findBonus = [&](const std::string & name, std::vector<Bonus::BonusType> &vec) auto findBonus = [&](std::string name, std::vector<Bonus::BonusType> &vec)
{ {
auto it = bonusNameMap.find(name); auto it = bonusNameMap.find(name);
if(it == bonusNameMap.end()) if(it == bonusNameMap.end())
@ -777,7 +779,7 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
} }
}; };
auto readBonusStruct = [&](const std::string & name, std::vector<Bonus::BonusType> &vec) auto readBonusStruct = [&](std::string name, std::vector<Bonus::BonusType> &vec)
{ {
for(auto bonusData: json[name].Struct()) for(auto bonusData: json[name].Struct())
{ {
@ -794,19 +796,24 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
readBonusStruct("limit", spell->limiters); readBonusStruct("limit", spell->limiters);
readBonusStruct("absoluteLimit", spell->absoluteLimiters); readBonusStruct("absoluteLimit", spell->absoluteLimiters);
const JsonNode & graphicsNode = json["graphics"]; const JsonNode & graphicsNode = json["graphics"];
spell->iconImmune = graphicsNode["iconImmune"].String(); spell->iconImmune = graphicsNode["iconImmune"].String();
spell->iconBook = graphicsNode["iconBook"].String(); spell->iconBook = graphicsNode["iconBook"].String();
spell->iconEffect = graphicsNode["iconEffect"].String(); spell->iconEffect = graphicsNode["iconEffect"].String();
spell->iconScenarioBonus = graphicsNode["iconScenarioBonus"].String(); spell->iconScenarioBonus = graphicsNode["iconScenarioBonus"].String();
spell->iconScroll = graphicsNode["iconScroll"].String(); spell->iconScroll = graphicsNode["iconScroll"].String();
const JsonNode & soundsNode = json["sounds"]; const JsonNode & soundsNode = json["sounds"];
spell->castSound = soundsNode["cast"].String(); spell->castSound = soundsNode["cast"].String();
//load level attributes //load level attributes
const int levelsCount = GameConstants::SPELL_SCHOOL_LEVELS; const int levelsCount = GameConstants::SPELL_SCHOOL_LEVELS;
for(int levelIndex = 0; levelIndex < levelsCount; levelIndex++) for(int levelIndex = 0; levelIndex < levelsCount; levelIndex++)
@ -870,6 +877,7 @@ void CSpellHandler::beforeValidate(JsonNode & object)
inheritNode("basic"); inheritNode("basic");
inheritNode("advanced"); inheritNode("advanced");
inheritNode("expert"); inheritNode("expert");
} }