summaryrefslogtreecommitdiff
path: root/src/nodedef.cpp
diff options
context:
space:
mode:
authorThomas--S <Thomas--S@users.noreply.github.com>2017-04-22 21:17:46 +0200
committerparamat <mat.gregory@virginmedia.com>2018-01-03 04:05:21 +0000
commitf3b9d8707691b16d9c8b6a2e9e13db54b091dc93 (patch)
tree7eb55d8965838aa0b0af74d7d30519a9b5a6d053 /src/nodedef.cpp
parent345e1041a204ca9d40a25b71ae239ce3275f0755 (diff)
downloadminetest-f3b9d8707691b16d9c8b6a2e9e13db54b091dc93.tar.gz
minetest-f3b9d8707691b16d9c8b6a2e9e13db54b091dc93.tar.bz2
minetest-f3b9d8707691b16d9c8b6a2e9e13db54b091dc93.zip
Connected Nodeboxes: Add `disconnected` boxes
The `disconnected_*` boxes are the opposites of the `connect_*` ones, i.e. when a node has no suitable neighbours on the respective side, the according disconnected box is drawn. * disconnected_top * disconnected_bottom * disconnected_front * disconnected_left * disconnected_back * disconnected_right * disconnected (when there is *no* neighbour) * disconnected_sides (when there are *no* neighbours to the sides)
Diffstat (limited to 'src/nodedef.cpp')
-rw-r--r--src/nodedef.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 790f7154c..f7ff6b2eb 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -61,12 +61,20 @@ void NodeBox::reset()
connect_left.clear();
connect_back.clear();
connect_right.clear();
+ disconnected_top.clear();
+ disconnected_bottom.clear();
+ disconnected_front.clear();
+ disconnected_left.clear();
+ disconnected_back.clear();
+ disconnected_right.clear();
+ disconnected.clear();
+ disconnected_sides.clear();
}
void NodeBox::serialize(std::ostream &os, u16 protocol_version) const
{
// Protocol >= 36
- int version = 4;
+ int version = 5;
writeU8(os, version);
switch (type) {
@@ -107,6 +115,14 @@ void NodeBox::serialize(std::ostream &os, u16 protocol_version) const
WRITEBOX(connect_left);
WRITEBOX(connect_back);
WRITEBOX(connect_right);
+ WRITEBOX(disconnected_top);
+ WRITEBOX(disconnected_bottom);
+ WRITEBOX(disconnected_front);
+ WRITEBOX(disconnected_left);
+ WRITEBOX(disconnected_back);
+ WRITEBOX(disconnected_right);
+ WRITEBOX(disconnected);
+ WRITEBOX(disconnected_sides);
break;
default:
writeU8(os, type);
@@ -163,6 +179,16 @@ void NodeBox::deSerialize(std::istream &is)
READBOXES(connect_left);
READBOXES(connect_back);
READBOXES(connect_right);
+ if (version >= 5) {
+ READBOXES(disconnected_top);
+ READBOXES(disconnected_bottom);
+ READBOXES(disconnected_front);
+ READBOXES(disconnected_left);
+ READBOXES(disconnected_back);
+ READBOXES(disconnected_right);
+ READBOXES(disconnected);
+ READBOXES(disconnected_sides);
+ }
}
}
@@ -1245,13 +1271,21 @@ void getNodeBoxUnion(const NodeBox &nodebox, const ContentFeatures &features,
}
case NODEBOX_CONNECTED: {
// Add all possible connected boxes
- boxVectorUnion(nodebox.fixed, box_union);
- boxVectorUnion(nodebox.connect_top, box_union);
- boxVectorUnion(nodebox.connect_bottom, box_union);
- boxVectorUnion(nodebox.connect_front, box_union);
- boxVectorUnion(nodebox.connect_left, box_union);
- boxVectorUnion(nodebox.connect_back, box_union);
- boxVectorUnion(nodebox.connect_right, box_union);
+ boxVectorUnion(nodebox.fixed, box_union);
+ boxVectorUnion(nodebox.connect_top, box_union);
+ boxVectorUnion(nodebox.connect_bottom, box_union);
+ boxVectorUnion(nodebox.connect_front, box_union);
+ boxVectorUnion(nodebox.connect_left, box_union);
+ boxVectorUnion(nodebox.connect_back, box_union);
+ boxVectorUnion(nodebox.connect_right, box_union);
+ boxVectorUnion(nodebox.disconnected_top, box_union);
+ boxVectorUnion(nodebox.disconnected_bottom, box_union);
+ boxVectorUnion(nodebox.disconnected_front, box_union);
+ boxVectorUnion(nodebox.disconnected_left, box_union);
+ boxVectorUnion(nodebox.disconnected_back, box_union);
+ boxVectorUnion(nodebox.disconnected_right, box_union);
+ boxVectorUnion(nodebox.disconnected, box_union);
+ boxVectorUnion(nodebox.disconnected_sides, box_union);
break;
}
default: {