1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Docs & final touches

This commit is contained in:
Tomasz Zieliński 2024-04-12 14:53:07 +02:00
parent be9813b4fb
commit a7d0f0626a
6 changed files with 28 additions and 16 deletions

View File

@ -16,9 +16,6 @@
"additionalProperties" : true, // Not validated on its own - instead data copied to main object and validated as part of it
"type" : "object"
},
"biome" : {
"type" : "object"
},
"rmg" : {
"additionalProperties" : false,
"type" : "object",

View File

View File

@ -73,6 +73,7 @@ Other:
- [Terrain](Entities_Format/Terrain_Format.md)
- [River](Entities_Format/River_Format.md)
- [Road](Entities_Format/Road_Format.md)
- [Biome](Entities_Format/Biome_Format.md)
- [Battlefield](Entities_Format/Battlefield_Format.md)
- [Battle Obstacle](Entities_Format/Battle_Obstacle_Format.md)

View File

@ -212,18 +212,26 @@ TObjectTypeHandler CObjectClassesHandler::loadSubObjectFromJson(const std::strin
createdObject->subtype = index;
createdObject->init(entry);
for (auto & templ : createdObject->getTemplates())
bool staticObject = createdObject->isStaticObject();
if (staticObject)
{
// Register templates for new objects from mods
VLC->biomeHandler->addTemplate(scope, templ->stringID, templ);
for (auto & templ : createdObject->getTemplates())
{
// Register templates for new objects from mods
VLC->biomeHandler->addTemplate(scope, templ->stringID, templ);
}
}
auto range = legacyTemplates.equal_range(std::make_pair(obj->id, index));
for (auto & templ : boost::make_iterator_range(range.first, range.second))
{
// Register legacy templates as "core"
VLC->biomeHandler->addTemplate("core", templ.second->stringID, templ.second);
// FIXME: Why does it clear stringID?
if (staticObject)
{
// Register legacy templates as "core"
// FIXME: Why does it clear stringID?
VLC->biomeHandler->addTemplate("core", templ.second->stringID, templ.second);
}
createdObject->addTemplate(templ.second);
}

View File

@ -13,6 +13,7 @@
#include "../modding/IdentifierStorage.h"
#include "../constants/StringConstants.h"
#include "../TerrainHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -303,7 +304,7 @@ std::shared_ptr<ObstacleSet> ObstacleSetHandler::loadFromJson(const std::string
os->setTerrain(TerrainId(id));
});
}
else // Other cases won't pass validation
else if (biome["terrain"].isVector())
{
auto terrains = biome["terrain"].Vector();
@ -315,8 +316,12 @@ std::shared_ptr<ObstacleSet> ObstacleSetHandler::loadFromJson(const std::string
});
}
}
else
{
logMod->error("No terrain specified for obstacle set %s", name);
}
auto parseFaction = [os, scope](const std::string & str) -> FactionID
auto handleFaction = [os, scope](const std::string & str)
{
VLC->identifiers()->requestIdentifier(scope, "faction", str, [os](si32 id)
{
@ -327,14 +332,14 @@ std::shared_ptr<ObstacleSet> ObstacleSetHandler::loadFromJson(const std::string
if (biome["faction"].isString())
{
auto factionName = biome["faction"].String();
parseFaction(factionName);
handleFaction(factionName);
}
else if (biome["faction"].isVector())
{
auto factions = biome["faction"].Vector();
for (const auto & node : factions)
{
parseFaction(node.String());
handleFaction(node.String());
}
}

View File

@ -61,10 +61,11 @@ public:
si32 id;
private:
EObstacleType type;
std::set<TerrainId> allowedTerrains;
std::set<FactionID> allowedFactions;
std::set<EAlignment> allowedAlignments; // Empty means all
std::set<TerrainId> allowedTerrains; // Empty means all terrains
std::set<FactionID> allowedFactions; // Empty means all factions
std::set<EAlignment> allowedAlignments; // Empty means all alignments
std::vector<std::shared_ptr<const ObjectTemplate>> obstacles;
};