mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +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
|
||||
{
|
||||
auto rockTerrainType = terr.second["rockTerrain"].String();
|
||||
resolveLater.push_back([this, rockTerrainType, info]()
|
||||
auto rockTerrainName = terr.second["rockTerrain"].String();
|
||||
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();
|
||||
objects.push_back(info);
|
||||
}
|
||||
info->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +169,8 @@ TerrainTypeHandler::TerrainTypeHandler()
|
||||
assert(objects(i));
|
||||
}
|
||||
|
||||
//TODO: add ids to resolve
|
||||
recreateTerrainMaps();
|
||||
|
||||
for (auto& functor : resolveLater)
|
||||
{
|
||||
functor();
|
||||
@ -216,7 +218,7 @@ TerrainType::operator std::string() const
|
||||
}
|
||||
|
||||
TerrainType::TerrainType(const std::string& _name):
|
||||
name(name),
|
||||
name(_name),
|
||||
id(Terrain::WRONG),
|
||||
rockTerrain(Terrain::ROCK),
|
||||
moveCost(100),
|
||||
|
@ -193,10 +193,10 @@ void LibClasses::init(bool onlyEssential)
|
||||
|
||||
createHandler(bth, "Bonus type", pomtime);
|
||||
|
||||
createHandler(generaltexth, "General text", pomtime);
|
||||
|
||||
createHandler(terrainTypeHandler, "Terrain", pomtime);
|
||||
|
||||
createHandler(generaltexth, "General text", pomtime);
|
||||
|
||||
createHandler(heroh, "Hero", 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())
|
||||
{
|
||||
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
||||
JsonUtils::inherit(entry.second, base);
|
||||
try
|
||||
{
|
||||
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
||||
JsonUtils::inherit(entry.second, base);
|
||||
|
||||
auto tmpl = new ObjectTemplate;
|
||||
tmpl->id = Obj(type);
|
||||
tmpl->subid = subtype;
|
||||
tmpl->stringID = entry.first; // FIXME: create "fullID" - type.object.template?
|
||||
tmpl->readJson(entry.second);
|
||||
templates.push_back(std::shared_ptr<const ObjectTemplate>(tmpl));
|
||||
auto tmpl = new ObjectTemplate;
|
||||
tmpl->id = Obj(type);
|
||||
tmpl->subid = subtype;
|
||||
tmpl->stringID = entry.first; // FIXME: create "fullID" - type.object.template?
|
||||
tmpl->readJson(entry.second);
|
||||
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())
|
||||
|
@ -282,25 +282,24 @@ void ObjectTemplate::readJson(const JsonNode &node, const bool withTerrain)
|
||||
else
|
||||
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);
|
||||
}
|
||||
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;
|
||||
allowedTerrains.insert(terrain->id);
|
||||
}
|
||||
}
|
||||
|
||||
if(withTerrain && allowedTerrains.empty())
|
||||
if (withTerrain && allowedTerrains.empty())
|
||||
logGlobal->warn("Loaded template without allowed terrains!");
|
||||
|
||||
|
||||
auto charToTile = [&](const char & ch) -> ui8
|
||||
{
|
||||
switch (ch)
|
||||
|
Loading…
Reference in New Issue
Block a user