Skip to content

Commit

Permalink
Make raillike nodes connect to any other raillike nodes if both are i…
Browse files Browse the repository at this point in the history
…n the group connect_to_raillike
  • Loading branch information
Jeija authored and PilzAdam committed May 22, 2013
1 parent 7f6e9e9 commit 3abbe7e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 14 deletions.
2 changes: 2 additions & 0 deletions doc/lua_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ Special groups
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

Known damage and digging time defining groups
----------------------------------------------
Expand Down
76 changes: 62 additions & 14 deletions src/content_mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,34 +1188,81 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
MapNode n_minus_z_plus_y = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y+1, z-1));
MapNode n_plus_z_minus_y = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y-1, z+1));
MapNode n_minus_z_minus_y = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y-1, z-1));

content_t thiscontent = n.getContent();
if(n_minus_x.getContent() == thiscontent)
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;

if ((nodedef->get(n_minus_x).drawtype == NDT_RAILLIKE
&& ((ItemGroupList) nodedef->get(n_minus_x).groups)[groupname] != 0
&& self_connect_to_raillike)
|| n_minus_x.getContent() == thiscontent)
is_rail_x[0] = true;
if (n_minus_x_minus_y.getContent() == thiscontent)

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)
|| n_minus_x_minus_y.getContent() == thiscontent)
is_rail_x_minus_y[0] = true;
if(n_minus_x_plus_y.getContent() == thiscontent)

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)
|| n_minus_x_plus_y.getContent() == thiscontent)
is_rail_x_plus_y[0] = true;

if(n_plus_x.getContent() == thiscontent)
if ((nodedef->get(n_plus_x).drawtype == NDT_RAILLIKE
&& ((ItemGroupList) nodedef->get(n_plus_x).groups)[groupname] != 0
&& self_connect_to_raillike)
|| n_plus_x.getContent() == thiscontent)
is_rail_x[1] = true;
if (n_plus_x_minus_y.getContent() == thiscontent)

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)
|| n_plus_x_minus_y.getContent() == thiscontent)
is_rail_x_minus_y[1] = true;
if(n_plus_x_plus_y.getContent() == thiscontent)

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)
|| n_plus_x_plus_y.getContent() == thiscontent)
is_rail_x_plus_y[1] = true;

if(n_minus_z.getContent() == thiscontent)
if ((nodedef->get(n_minus_z).drawtype == NDT_RAILLIKE
&& ((ItemGroupList) nodedef->get(n_minus_z).groups)[groupname] != 0
&& self_connect_to_raillike)
|| n_minus_z.getContent() == thiscontent)
is_rail_z[0] = true;
if (n_minus_z_minus_y.getContent() == thiscontent)

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)
|| n_minus_z_minus_y.getContent() == thiscontent)
is_rail_z_minus_y[0] = true;
if(n_minus_z_plus_y.getContent() == thiscontent)

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)
|| n_minus_z_plus_y.getContent() == thiscontent)
is_rail_z_plus_y[0] = true;

if(n_plus_z.getContent() == thiscontent)
if ((nodedef->get(n_plus_z).drawtype == NDT_RAILLIKE
&& ((ItemGroupList) nodedef->get(n_plus_z).groups)[groupname] != 0
&& self_connect_to_raillike)
|| n_plus_z.getContent() == thiscontent)
is_rail_z[1] = true;
if (n_plus_z_minus_y.getContent() == thiscontent)

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)
|| n_plus_z_minus_y.getContent() == thiscontent)
is_rail_z_minus_y[1] = true;
if(n_plus_z_plus_y.getContent() == thiscontent)

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)
|| n_plus_z_plus_y.getContent() == thiscontent)
is_rail_z_plus_y[1] = true;

bool is_rail_x_all[] = {false, false};
Expand Down Expand Up @@ -1255,7 +1302,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
if(is_rail_x_all[0] && is_rail_x_all[1])
angle = 90;
if(is_rail_z_all[0] && is_rail_z_all[1]){
if (n_minus_z_plus_y.getContent() == thiscontent) angle = 180;
if (is_rail_z_plus_y[0])
angle = 180;
}
else if(is_rail_x_all[0] && is_rail_z_all[0])
angle = 270;
Expand Down

0 comments on commit 3abbe7e

Please sign in to comment.