Skip to content

Commit

Permalink
Connected nodes: fix 2 minor bugs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sofar authored and est31 committed Mar 14, 2016
1 parent 089f9bb commit 5a40a7d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nodedef.cpp
Expand Up @@ -479,6 +479,7 @@ void ContentFeatures::deSerialize(std::istream &is)
collision_box.deSerialize(is);
floodable = readU8(is);
u16 connects_to_size = readU16(is);
connects_to_ids.clear();
for (u16 i = 0; i < connects_to_size; i++)
connects_to_ids.insert(readU16(is));
connect_sides = readU8(is);
Expand Down Expand Up @@ -1546,7 +1547,7 @@ bool CNodeDefManager::nodeboxConnects(MapNode from, MapNode to, u8 connect_face)

const ContentFeatures &f2 = get(to);

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

Expand Down

0 comments on commit 5a40a7d

Please sign in to comment.