mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Removed mods compatibility code from 0.95
This commit is contained in:
@@ -110,8 +110,6 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
|
|||||||
|
|
||||||
heroClass->name = node["name"].String();
|
heroClass->name = node["name"].String();
|
||||||
heroClass->affinity = vstd::find_pos(affinityStr, node["affinity"].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)
|
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());
|
heroClass->secSkillProbability.push_back(node["secondarySkills"][secSkill].Float());
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: MODS COMPATIBILITY
|
VLC->modh->identifiers.requestIdentifier ("creature", node["commander"],
|
||||||
if (!node["commander"].isNull())
|
[=](si32 commanderID)
|
||||||
{
|
{
|
||||||
VLC->modh->identifiers.requestIdentifier ("creature", node["commander"],
|
heroClass->commander = VLC->creh->creatures[commanderID];
|
||||||
[=](si32 commanderID)
|
});
|
||||||
{
|
|
||||||
heroClass->commander = VLC->creh->creatures[commanderID];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
heroClass->defaultTavernChance = node["defaultTavern"].Float();
|
heroClass->defaultTavernChance = node["defaultTavern"].Float();
|
||||||
for(auto & tavern : node["tavern"].Struct())
|
for(auto & tavern : node["tavern"].Struct())
|
||||||
|
|||||||
@@ -272,24 +272,12 @@ void CTownHandler::loadBuildingRequirements(CTown &town, CBuilding & building, c
|
|||||||
{
|
{
|
||||||
if (source.isNull())
|
if (source.isNull())
|
||||||
return;
|
return;
|
||||||
if (source.Vector()[0].getType() == JsonNode::DATA_FLOAT)
|
|
||||||
{
|
|
||||||
// MODS COMPATIBILITY
|
|
||||||
CBuilding::TRequired::OperatorAll required;
|
|
||||||
|
|
||||||
for(const JsonNode &building : source.Vector())
|
BuildingRequirementsHelper hlp;
|
||||||
required.expressions.push_back(BuildingID(building.Float()));
|
hlp.building = &building;
|
||||||
|
hlp.faction = town.faction;
|
||||||
building.requirements = CBuilding::TRequired(required);
|
hlp.json = source;
|
||||||
}
|
requirementsToLoad.push_back(hlp);
|
||||||
else
|
|
||||||
{
|
|
||||||
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)
|
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())
|
if (!source["upgrades"].isNull())
|
||||||
{
|
{
|
||||||
//MODS COMPATIBILITY
|
// building id and upgrades can't be the same
|
||||||
if (source["upgrades"].getType() == JsonNode::DATA_FLOAT)
|
if(stringID == source["upgrades"].String())
|
||||||
ret->upgrade = BuildingID(source["upgrades"].Float());
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// building id and upgrades can't be the same
|
throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") %
|
||||||
if(stringID == source["upgrades"].String())
|
stringID % town.faction->name));
|
||||||
{
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["upgrades"], [=](si32 identifier)
|
||||||
|
{
|
||||||
|
ret->upgrade = BuildingID(identifier);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret->upgrade = BuildingID::NONE;
|
ret->upgrade = BuildingID::NONE;
|
||||||
@@ -380,7 +362,6 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
|
|||||||
{
|
{
|
||||||
auto ret = new CStructure;
|
auto ret = new CStructure;
|
||||||
|
|
||||||
//Note: MODS COMPATIBILITY CODE
|
|
||||||
ret->building = nullptr;
|
ret->building = nullptr;
|
||||||
ret->buildable = nullptr;
|
ret->buildable = nullptr;
|
||||||
|
|
||||||
@@ -398,17 +379,10 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
|
|||||||
}
|
}
|
||||||
else
|
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())];
|
ret->buildable = town.buildings[BuildingID(identifier)];
|
||||||
}
|
});
|
||||||
else
|
|
||||||
{
|
|
||||||
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
|
|
||||||
{
|
|
||||||
ret->buildable = town.buildings[BuildingID(identifier)];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret->identifier = stringID;
|
ret->identifier = stringID;
|
||||||
@@ -456,16 +430,10 @@ void CTownHandler::loadTownHall(CTown &town, const JsonNode & source)
|
|||||||
auto & dst = dstBox[k];
|
auto & dst = dstBox[k];
|
||||||
auto & src = srcBox[k];
|
auto & src = srcBox[k];
|
||||||
|
|
||||||
//MODS COMPATIBILITY
|
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, src, [&](si32 identifier)
|
||||||
if (src.getType() == JsonNode::DATA_FLOAT)
|
|
||||||
dst = BuildingID(src.Float());
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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->name = source["name"].String();
|
||||||
faction->identifier = identifier;
|
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->creatureBg120 = source["creatureBackground"]["120px"].String();
|
||||||
faction->creatureBg130 = source["creatureBackground"]["130px"].String();
|
faction->creatureBg130 = source["creatureBackground"]["130px"].String();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user