diff options
Diffstat (limited to '')
-rw-r--r-- | src/nodedef.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp index b8211fceb..cb841e544 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -371,7 +371,9 @@ void ContentFeatures::reset() leveled_max = LEVELED_MAX; liquid_type = LIQUID_NONE; liquid_alternative_flowing = ""; + liquid_alternative_flowing_id = CONTENT_IGNORE; liquid_alternative_source = ""; + liquid_alternative_source_id = CONTENT_IGNORE; liquid_viscosity = 0; liquid_renewable = true; liquid_range = LIQUID_LEVEL_MAX+1; @@ -1444,6 +1446,10 @@ void NodeDefManager::deSerialize(std::istream &is) getNodeBoxUnion(f.selection_box, f, &m_selection_box_union); fixSelectionBoxIntUnion(); } + + // Since liquid_alternative_flowing_id and liquid_alternative_source_id + // are not sent, resolve them client-side too. + resolveCrossrefs(); } @@ -1504,15 +1510,28 @@ void NodeDefManager::resetNodeResolveState() m_pending_resolve_callbacks.clear(); } -void NodeDefManager::mapNodeboxConnections() +static void removeDupes(std::vector<content_t> &list) +{ + std::sort(list.begin(), list.end()); + auto new_end = std::unique(list.begin(), list.end()); + list.erase(new_end, list.end()); +} + +void NodeDefManager::resolveCrossrefs() { for (ContentFeatures &f : m_content_features) { + if (f.liquid_type != LIQUID_NONE) { + f.liquid_alternative_flowing_id = getId(f.liquid_alternative_flowing); + f.liquid_alternative_source_id = getId(f.liquid_alternative_source); + continue; + } if (f.drawtype != NDT_NODEBOX || f.node_box.type != NODEBOX_CONNECTED) continue; for (const std::string &name : f.connects_to) { getIds(name, f.connects_to_ids); } + removeDupes(f.connects_to_ids); } } |