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:
@@ -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 */)
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -30,6 +30,8 @@ public:
|
||||
/// loads single object into game. Scope is namespace of this object, same as name of source mod
|
||||
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;
|
||||
|
@@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user