mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Firts working version that launches original maps
This commit is contained in:
parent
11e1bb44a2
commit
c9c4603f75
@ -74,10 +74,10 @@ TerrainTypeHandler::TerrainTypeHandler()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto rockTerrainType = terr.second["rockTerrain"].String();
|
auto rockTerrainName = terr.second["rockTerrain"].String();
|
||||||
resolveLater.push_back([this, rockTerrainType, info]()
|
resolveLater.push_back([this, rockTerrainName, info]()
|
||||||
{
|
{
|
||||||
info->rockTerrain = getInfoByName(rockTerrainType)->id;
|
info->rockTerrain = getInfoByName(rockTerrainName)->id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +159,7 @@ TerrainTypeHandler::TerrainTypeHandler()
|
|||||||
id = objects.size();
|
id = objects.size();
|
||||||
objects.push_back(info);
|
objects.push_back(info);
|
||||||
}
|
}
|
||||||
|
info->id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +169,8 @@ TerrainTypeHandler::TerrainTypeHandler()
|
|||||||
assert(objects(i));
|
assert(objects(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add ids to resolve
|
recreateTerrainMaps();
|
||||||
|
|
||||||
for (auto& functor : resolveLater)
|
for (auto& functor : resolveLater)
|
||||||
{
|
{
|
||||||
functor();
|
functor();
|
||||||
@ -216,7 +218,7 @@ TerrainType::operator std::string() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
TerrainType::TerrainType(const std::string& _name):
|
TerrainType::TerrainType(const std::string& _name):
|
||||||
name(name),
|
name(_name),
|
||||||
id(Terrain::WRONG),
|
id(Terrain::WRONG),
|
||||||
rockTerrain(Terrain::ROCK),
|
rockTerrain(Terrain::ROCK),
|
||||||
moveCost(100),
|
moveCost(100),
|
||||||
|
@ -193,10 +193,10 @@ void LibClasses::init(bool onlyEssential)
|
|||||||
|
|
||||||
createHandler(bth, "Bonus type", pomtime);
|
createHandler(bth, "Bonus type", pomtime);
|
||||||
|
|
||||||
createHandler(generaltexth, "General text", pomtime);
|
|
||||||
|
|
||||||
createHandler(terrainTypeHandler, "Terrain", pomtime);
|
createHandler(terrainTypeHandler, "Terrain", pomtime);
|
||||||
|
|
||||||
|
createHandler(generaltexth, "General text", pomtime);
|
||||||
|
|
||||||
createHandler(heroh, "Hero", pomtime);
|
createHandler(heroh, "Hero", pomtime);
|
||||||
|
|
||||||
createHandler(arth, "Artifact", pomtime);
|
createHandler(arth, "Artifact", pomtime);
|
||||||
|
@ -484,15 +484,22 @@ void AObjectTypeHandler::init(const JsonNode & input, boost::optional<std::strin
|
|||||||
|
|
||||||
for (auto entry : input["templates"].Struct())
|
for (auto entry : input["templates"].Struct())
|
||||||
{
|
{
|
||||||
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
try
|
||||||
JsonUtils::inherit(entry.second, base);
|
{
|
||||||
|
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
||||||
|
JsonUtils::inherit(entry.second, base);
|
||||||
|
|
||||||
auto tmpl = new ObjectTemplate;
|
auto tmpl = new ObjectTemplate;
|
||||||
tmpl->id = Obj(type);
|
tmpl->id = Obj(type);
|
||||||
tmpl->subid = subtype;
|
tmpl->subid = subtype;
|
||||||
tmpl->stringID = entry.first; // FIXME: create "fullID" - type.object.template?
|
tmpl->stringID = entry.first; // FIXME: create "fullID" - type.object.template?
|
||||||
tmpl->readJson(entry.second);
|
tmpl->readJson(entry.second);
|
||||||
templates.push_back(std::shared_ptr<const ObjectTemplate>(tmpl));
|
templates.push_back(std::shared_ptr<const ObjectTemplate>(tmpl));
|
||||||
|
}
|
||||||
|
catch (const std::exception & e)
|
||||||
|
{
|
||||||
|
logGlobal->warn("Failed to load terrains for object %s: %s", entry.first, e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input["name"].isNull())
|
if (input["name"].isNull())
|
||||||
|
@ -282,25 +282,24 @@ void ObjectTemplate::readJson(const JsonNode &node, const bool withTerrain)
|
|||||||
else
|
else
|
||||||
visitDir = 0x00;
|
visitDir = 0x00;
|
||||||
|
|
||||||
if(withTerrain && !node["allowedTerrains"].isNull())
|
if (withTerrain && !node["allowedTerrains"].isNull())
|
||||||
{
|
{
|
||||||
for (auto & entry : node["allowedTerrains"].Vector())
|
for (auto& entry : node["allowedTerrains"].Vector())
|
||||||
allowedTerrains.insert(VLC->terrainTypeHandler->getInfoByName(entry.String())->id);
|
allowedTerrains.insert(VLC->terrainTypeHandler->getInfoByName(entry.String())->id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(const auto * terrain : VLC->terrainTypeHandler->terrains())
|
for (const auto* terrain : VLC->terrainTypeHandler->terrains())
|
||||||
{
|
{
|
||||||
if(!terrain->isPassable() || terrain->isWater())
|
if (!terrain->isPassable() || terrain->isWater())
|
||||||
continue;
|
continue;
|
||||||
allowedTerrains.insert(terrain->id);
|
allowedTerrains.insert(terrain->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(withTerrain && allowedTerrains.empty())
|
if (withTerrain && allowedTerrains.empty())
|
||||||
logGlobal->warn("Loaded template without allowed terrains!");
|
logGlobal->warn("Loaded template without allowed terrains!");
|
||||||
|
|
||||||
|
|
||||||
auto charToTile = [&](const char & ch) -> ui8
|
auto charToTile = [&](const char & ch) -> ui8
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
|
Loading…
Reference in New Issue
Block a user