1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Inherit terrain types only after all terrain Ids are resolved.

This commit is contained in:
Tomasz Zieliński
2023-07-02 09:28:51 +02:00
parent 04e2cf728e
commit cb4d818241
5 changed files with 13 additions and 5 deletions

View File

@@ -728,8 +728,6 @@ void CRmgTemplate::serializeJson(JsonSerializeFormat & handler)
}
}
}
if(!handler.saving)
afterLoad();
}
std::set<TerrainId> CRmgTemplate::inheritTerrainType(std::shared_ptr<ZoneOptions> zone, uint32_t iteration /* = 0 */)

View File

@@ -245,6 +245,7 @@ public:
void validate() const; /// Tests template on validity and throws exception on failure
void serializeJson(JsonSerializeFormat & handler);
void afterLoad();
private:
std::string id;
@@ -255,7 +256,6 @@ private:
std::vector<rmg::ZoneConnection> connectedZoneIds;
std::set<EWaterContent::EWaterContent> allowedWaterContent;
void afterLoad();
std::set<TerrainId> inheritTerrainType(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);
std::map<TResource, ui16> inheritMineTypes(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);
std::vector<CTreasureInfo> inheritTreasureInfo(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);

View File

@@ -26,6 +26,14 @@ void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const
loadObject(scope, name, data);
}
void CRmgTemplateStorage::afterLoadFinalization()
{
for (auto& temp : templates)
{
temp.second.afterLoad();
}
}
void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const JsonNode & data)
{
try

View File

@@ -31,6 +31,8 @@ public:
virtual void loadObject(std::string scope, std::string name, const JsonNode & data) override;
virtual void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
void afterLoadFinalization() override;
const CRmgTemplate* getTemplate(const std::string & templateName) const;
std::vector<const CRmgTemplate *> getTemplates() const;

View File

@@ -79,8 +79,8 @@ void TerrainPainter::initTerrainType()
{
if (terrain->isLand() && terrain->isPassable())
{
if (terrain->isSurface() && !zone.isUnderground() ||
terrain->isUnderground() && zone.isUnderground())
if ((terrain->isSurface() && !zone.isUnderground()) ||
(terrain->isUnderground() && zone.isUnderground()))
{
terrainTypes.insert(terrain->getId());
}