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:
parent
be9813b4fb
commit
a7d0f0626a
@ -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",
|
||||
|
0
docs/modders/Biome_Format.json
Normal file
0
docs/modders/Biome_Format.json
Normal 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)
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user