1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Register templates for new objects from mods

This commit is contained in:
Tomasz Zieliński 2024-04-08 16:39:41 +02:00
parent c7149103ce
commit bf2c9237b2

View File

@ -108,10 +108,6 @@ std::vector<JsonNode> CObjectClassesHandler::loadLegacyData()
auto totalNumber = static_cast<size_t>(parser.readNumber()); // first line contains number of objects to read and nothing else
parser.endLine();
//std::map<TerrainId, std::map<MapObjectID, std::map<MapObjectSubID, ObstacleSet>>> obstacleSets;
// TODO: Create map defName -> tmpl
for (size_t i = 0; i < totalNumber; i++)
{
auto tmpl = std::make_shared<ObjectTemplate>();
@ -224,6 +220,12 @@ TObjectTypeHandler CObjectClassesHandler::loadSubObjectFromJson(const std::strin
createdObject->subtype = index;
createdObject->init(entry);
for (auto & templ : createdObject->getTemplates())
{
// Register templates for new objects
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))
{