floodable = false;
rightclickable = true;
leveled = 0;
+ 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;
writeU8(os, legacy_wallmounted);
os << serializeString(node_dig_prediction);
+ writeU8(os, leveled_max);
}
void ContentFeatures::correctAlpha(TileDef *tiles, int length)
try {
node_dig_prediction = deSerializeString(is);
+ u8 tmp_leveled_max = readU8(is);
+ if (is.eof()) /* readU8 doesn't throw exceptions so we have to do this */
+ throw SerializationError("");
+ leveled_max = tmp_leveled_max;
} catch(SerializationError &e) {};
}
layer->material_type = material_type;
bool has_scale = tiledef.scale > 0;
- if (((tsettings.autoscale_mode == AUTOSCALE_ENABLE) && !has_scale) ||
- (tsettings.autoscale_mode == AUTOSCALE_FORCE)) {
+ bool use_autoscale = tsettings.autoscale_mode == AUTOSCALE_FORCE ||
+ (tsettings.autoscale_mode == AUTOSCALE_ENABLE && !has_scale);
+ if (use_autoscale && layer->texture) {
auto texture_size = layer->texture->getOriginalSize();
float base_size = tsettings.node_texture_size;
float size = std::fmin(texture_size.Width, texture_size.Height);
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();
}
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);
}
}
}
+void NodeResolver::cloneTo(NodeResolver *res) const
+{
+ FATAL_ERROR_IF(!m_resolve_done, "NodeResolver can only be cloned"
+ " after resolving has completed");
+ /* We don't actually do anything significant. Since the node resolving has
+ * already completed, the class that called us will already have the
+ * resolved IDs in its data structures (which it copies on its own) */
+ res->m_ndef = m_ndef;
+ res->m_resolve_done = true;
+}
+
+
void NodeResolver::nodeResolveInternal()
{
m_nodenames_idx = 0;