1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Removed mods compatibility code from 0.95

This commit is contained in:
Ivan Savenko 2014-06-23 20:10:08 +03:00
parent 06d17f709d
commit 7c52db923a
2 changed files with 24 additions and 76 deletions

View File

@ -110,8 +110,6 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
heroClass->name = node["name"].String();
heroClass->affinity = vstd::find_pos(affinityStr, node["affinity"].String());
if (heroClass->affinity >= 2) //FIXME: MODS COMPATIBILITY
heroClass->affinity = 0;
for(const std::string & pSkill : PrimarySkill::names)
{
@ -125,15 +123,11 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
heroClass->secSkillProbability.push_back(node["secondarySkills"][secSkill].Float());
}
//FIXME: MODS COMPATIBILITY
if (!node["commander"].isNull())
VLC->modh->identifiers.requestIdentifier ("creature", node["commander"],
[=](si32 commanderID)
{
VLC->modh->identifiers.requestIdentifier ("creature", node["commander"],
[=](si32 commanderID)
{
heroClass->commander = VLC->creh->creatures[commanderID];
});
}
heroClass->commander = VLC->creh->creatures[commanderID];
});
heroClass->defaultTavernChance = node["defaultTavern"].Float();
for(auto & tavern : node["tavern"].Struct())

View File

@ -272,24 +272,12 @@ void CTownHandler::loadBuildingRequirements(CTown &town, CBuilding & building, c
{
if (source.isNull())
return;
if (source.Vector()[0].getType() == JsonNode::DATA_FLOAT)
{
// MODS COMPATIBILITY
CBuilding::TRequired::OperatorAll required;
for(const JsonNode &building : source.Vector())
required.expressions.push_back(BuildingID(building.Float()));
building.requirements = CBuilding::TRequired(required);
}
else
{
BuildingRequirementsHelper hlp;
hlp.building = &building;
hlp.faction = town.faction;
hlp.json = source;
requirementsToLoad.push_back(hlp);
}
BuildingRequirementsHelper hlp;
hlp.building = &building;
hlp.faction = town.faction;
hlp.json = source;
requirementsToLoad.push_back(hlp);
}
void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const JsonNode & source)
@ -340,23 +328,17 @@ void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const
if (!source["upgrades"].isNull())
{
//MODS COMPATIBILITY
if (source["upgrades"].getType() == JsonNode::DATA_FLOAT)
ret->upgrade = BuildingID(source["upgrades"].Float());
else
// building id and upgrades can't be the same
if(stringID == source["upgrades"].String())
{
// building id and upgrades can't be the same
if(stringID == source["upgrades"].String())
{
throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") %
stringID % town.faction->name));
}
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["upgrades"], [=](si32 identifier)
{
ret->upgrade = BuildingID(identifier);
});
throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") %
stringID % town.faction->name));
}
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["upgrades"], [=](si32 identifier)
{
ret->upgrade = BuildingID(identifier);
});
}
else
ret->upgrade = BuildingID::NONE;
@ -380,7 +362,6 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
{
auto ret = new CStructure;
//Note: MODS COMPATIBILITY CODE
ret->building = nullptr;
ret->buildable = nullptr;
@ -398,17 +379,10 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
}
else
{
if (source["builds"].getType() == JsonNode::DATA_FLOAT)
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
{
ret->buildable = town.buildings[BuildingID(source["builds"].Float())];
}
else
{
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
{
ret->buildable = town.buildings[BuildingID(identifier)];
});
}
ret->buildable = town.buildings[BuildingID(identifier)];
});
}
ret->identifier = stringID;
@ -456,16 +430,10 @@ void CTownHandler::loadTownHall(CTown &town, const JsonNode & source)
auto & dst = dstBox[k];
auto & src = srcBox[k];
//MODS COMPATIBILITY
if (src.getType() == JsonNode::DATA_FLOAT)
dst = BuildingID(src.Float());
else
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, src, [&](si32 identifier)
{
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, src, [&](si32 identifier)
{
dst = BuildingID(identifier);
});
}
dst = BuildingID(identifier);
});
}
}
}
@ -672,20 +640,6 @@ CFaction * CTownHandler::loadFromJson(const JsonNode &source, std::string identi
faction->name = source["name"].String();
faction->identifier = identifier;
//FIXME: MODS COMPATIBILITY
if (!source["commander"].isNull())
{
VLC->modh->identifiers.requestIdentifier ("creature", source["commander"],
[=](si32 commanderID)
{
for (auto ptr : VLC->heroh->classes.heroClasses)
{
if (ptr->commander == nullptr && ptr->faction == faction->index)
ptr->commander = VLC->creh->creatures[commanderID];
}
});
}
faction->creatureBg120 = source["creatureBackground"]["120px"].String();
faction->creatureBg130 = source["creatureBackground"]["130px"].String();