Skip to content

Commit 5a40a7d

Browse files
sofarest31
authored andcommittedMar 14, 2016
Connected nodes: fix 2 minor bugs
1. Copy-paste error: properly test for back-connection. In the case of two different connected nodebox types, we want to assure that if A connects to B, that B also connects to A. This test was accidentally not implemented correctly. 2. Clear the connects_to_ids before deserializing. With each new connected node, the deserialization code added more and more targets to the map, since the map wasn't cleared in between deserialization steps. This caused e.g. wall blocks to connect to things in the fence connects_to map.
1 parent 089f9bb commit 5a40a7d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/nodedef.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ void ContentFeatures::deSerialize(std::istream &is)
479479
collision_box.deSerialize(is);
480480
floodable = readU8(is);
481481
u16 connects_to_size = readU16(is);
482+
connects_to_ids.clear();
482483
for (u16 i = 0; i < connects_to_size; i++)
483484
connects_to_ids.insert(readU16(is));
484485
connect_sides = readU8(is);
@@ -1546,7 +1547,7 @@ bool CNodeDefManager::nodeboxConnects(MapNode from, MapNode to, u8 connect_face)
15461547

15471548
const ContentFeatures &f2 = get(to);
15481549

1549-
if ((f2.drawtype == NDT_NODEBOX) && (f1.node_box.type == NODEBOX_CONNECTED))
1550+
if ((f2.drawtype == NDT_NODEBOX) && (f2.node_box.type == NODEBOX_CONNECTED))
15501551
// ignores actually looking if back connection exists
15511552
return (f2.connects_to_ids.find(from.param0) != f2.connects_to_ids.end());
15521553

0 commit comments

Comments
 (0)
Please sign in to comment.