Improve group-based connection between raillike nodes
authorBlockMen <nmuelll@web.de>
Sun, 22 Feb 2015 14:12:05 +0000 (15:12 +0100)
committerBlockMen <nmuelll@web.de>
Thu, 5 Mar 2015 22:24:32 +0000 (23:24 +0100)
doc/lua_api.txt
src/content_mapblock.cpp

index d73fb7721e459e6451a276e8edce0512d68bbe14..e2589d226f5c5f8187aca7ea3c93d9ada8dbb565 100644 (file)
@@ -1053,8 +1053,8 @@ Another example: Make red wool from white wool and red dye:
   dropped as an item. If the node is wallmounted the wallmounted direction is
   checked.
 * `soil`: saplings will grow on nodes in this group
-* `connect_to_raillike`: makes nodes of raillike drawtype connect to
-  other group members with same drawtype
+* `connect_to_raillike`: makes nodes of raillike drawtype with same group value
+  connect to each other
 
 ### Known damage and digging time defining groups
 * `crumbly`: dirt, sand
index 5bb787d019db95aa36a13a0c10051d56b558edd4..3428f85f98bb5814eaecaac13a8b55b2caafc188 100644 (file)
@@ -1421,77 +1421,65 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
 
                        content_t thiscontent = n.getContent();
                        std::string groupname = "connect_to_raillike"; // name of the group that enables connecting to raillike nodes of different kind
-                       bool self_connect_to_raillike = ((ItemGroupList) nodedef->get(n).groups)[groupname] != 0;
+                       int self_group = ((ItemGroupList) nodedef->get(n).groups)[groupname];
 
                        if ((nodedef->get(n_minus_x).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_minus_x).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_minus_x).groups)[groupname] != self_group)
                                        || n_minus_x.getContent() == thiscontent)
                                is_rail_x[0] = true;
 
                        if ((nodedef->get(n_minus_x_minus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_minus_x_minus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_minus_x_minus_y).groups)[groupname] != self_group)
                                        || n_minus_x_minus_y.getContent() == thiscontent)
                                is_rail_x_minus_y[0] = true;
 
                        if ((nodedef->get(n_minus_x_plus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_minus_x_plus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_minus_x_plus_y).groups)[groupname] != self_group)
                                        || n_minus_x_plus_y.getContent() == thiscontent)
                                is_rail_x_plus_y[0] = true;
 
                        if ((nodedef->get(n_plus_x).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_plus_x).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_plus_x).groups)[groupname] != self_group)
                                        || n_plus_x.getContent() == thiscontent)
                                is_rail_x[1] = true;
 
                        if ((nodedef->get(n_plus_x_minus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_plus_x_minus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_plus_x_minus_y).groups)[groupname] != self_group)
                                        || n_plus_x_minus_y.getContent() == thiscontent)
                                is_rail_x_minus_y[1] = true;
 
                        if ((nodedef->get(n_plus_x_plus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_plus_x_plus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_plus_x_plus_y).groups)[groupname] != self_group)
                                        || n_plus_x_plus_y.getContent() == thiscontent)
                                is_rail_x_plus_y[1] = true;
 
                        if ((nodedef->get(n_minus_z).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_minus_z).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_minus_z).groups)[groupname] != self_group)
                                        || n_minus_z.getContent() == thiscontent)
                                is_rail_z[0] = true;
 
                        if ((nodedef->get(n_minus_z_minus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_minus_z_minus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_minus_z_minus_y).groups)[groupname] != self_group)
                                        || n_minus_z_minus_y.getContent() == thiscontent)
                                is_rail_z_minus_y[0] = true;
 
                        if ((nodedef->get(n_minus_z_plus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_minus_z_plus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_minus_z_plus_y).groups)[groupname] != self_group)
                                        || n_minus_z_plus_y.getContent() == thiscontent)
                                is_rail_z_plus_y[0] = true;
 
                        if ((nodedef->get(n_plus_z).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_plus_z).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_plus_z).groups)[groupname] != self_group)
                                        || n_plus_z.getContent() == thiscontent)
                                is_rail_z[1] = true;
 
                        if ((nodedef->get(n_plus_z_minus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_plus_z_minus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_plus_z_minus_y).groups)[groupname] != self_group)
                                        || n_plus_z_minus_y.getContent() == thiscontent)
                                is_rail_z_minus_y[1] = true;
 
                        if ((nodedef->get(n_plus_z_plus_y).drawtype == NDT_RAILLIKE
-                                       && ((ItemGroupList) nodedef->get(n_plus_z_plus_y).groups)[groupname] != 0
-                                       && self_connect_to_raillike)
+                                       && ((ItemGroupList) nodedef->get(n_plus_z_plus_y).groups)[groupname] != self_group)
                                        || n_plus_z_plus_y.getContent() == thiscontent)
                                is_rail_z_plus_y[1] = true;