Skip to content

Commit 3abbe7e

Browse files
JeijaPilzAdam
authored andcommittedMay 22, 2013
Make raillike nodes connect to any other raillike nodes if both are in the group connect_to_raillike
1 parent 7f6e9e9 commit 3abbe7e

File tree

2 files changed

+64
-14
lines changed

2 files changed

+64
-14
lines changed
 

Diff for: ‎doc/lua_api.txt

+2
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ Special groups
584584
dropped as an item. If the node is wallmounted the
585585
wallmounted direction is checked.
586586
- soil: saplings will grow on nodes in this group
587+
- connect_to_raillike: makes nodes of raillike drawtype connect to
588+
other group members with same drawtype
587589

588590
Known damage and digging time defining groups
589591
----------------------------------------------

Diff for: ‎src/content_mapblock.cpp

+62-14
Original file line numberDiff line numberDiff line change
@@ -1188,34 +1188,81 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
11881188
MapNode n_minus_z_plus_y = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y+1, z-1));
11891189
MapNode n_plus_z_minus_y = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y-1, z+1));
11901190
MapNode n_minus_z_minus_y = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y-1, z-1));
1191-
1191+
11921192
content_t thiscontent = n.getContent();
1193-
if(n_minus_x.getContent() == thiscontent)
1193+
std::string groupname = "connect_to_raillike"; // name of the group that enables connecting to raillike nodes of different kind
1194+
bool self_connect_to_raillike = ((ItemGroupList) nodedef->get(n).groups)[groupname] != 0;
1195+
1196+
if ((nodedef->get(n_minus_x).drawtype == NDT_RAILLIKE
1197+
&& ((ItemGroupList) nodedef->get(n_minus_x).groups)[groupname] != 0
1198+
&& self_connect_to_raillike)
1199+
|| n_minus_x.getContent() == thiscontent)
11941200
is_rail_x[0] = true;
1195-
if (n_minus_x_minus_y.getContent() == thiscontent)
1201+
1202+
if ((nodedef->get(n_minus_x_minus_y).drawtype == NDT_RAILLIKE
1203+
&& ((ItemGroupList) nodedef->get(n_minus_x_minus_y).groups)[groupname] != 0
1204+
&& self_connect_to_raillike)
1205+
|| n_minus_x_minus_y.getContent() == thiscontent)
11961206
is_rail_x_minus_y[0] = true;
1197-
if(n_minus_x_plus_y.getContent() == thiscontent)
1207+
1208+
if ((nodedef->get(n_minus_x_plus_y).drawtype == NDT_RAILLIKE
1209+
&& ((ItemGroupList) nodedef->get(n_minus_x_plus_y).groups)[groupname] != 0
1210+
&& self_connect_to_raillike)
1211+
|| n_minus_x_plus_y.getContent() == thiscontent)
11981212
is_rail_x_plus_y[0] = true;
11991213

1200-
if(n_plus_x.getContent() == thiscontent)
1214+
if ((nodedef->get(n_plus_x).drawtype == NDT_RAILLIKE
1215+
&& ((ItemGroupList) nodedef->get(n_plus_x).groups)[groupname] != 0
1216+
&& self_connect_to_raillike)
1217+
|| n_plus_x.getContent() == thiscontent)
12011218
is_rail_x[1] = true;
1202-
if (n_plus_x_minus_y.getContent() == thiscontent)
1219+
1220+
if ((nodedef->get(n_plus_x_minus_y).drawtype == NDT_RAILLIKE
1221+
&& ((ItemGroupList) nodedef->get(n_plus_x_minus_y).groups)[groupname] != 0
1222+
&& self_connect_to_raillike)
1223+
|| n_plus_x_minus_y.getContent() == thiscontent)
12031224
is_rail_x_minus_y[1] = true;
1204-
if(n_plus_x_plus_y.getContent() == thiscontent)
1225+
1226+
if ((nodedef->get(n_plus_x_plus_y).drawtype == NDT_RAILLIKE
1227+
&& ((ItemGroupList) nodedef->get(n_plus_x_plus_y).groups)[groupname] != 0
1228+
&& self_connect_to_raillike)
1229+
|| n_plus_x_plus_y.getContent() == thiscontent)
12051230
is_rail_x_plus_y[1] = true;
12061231

1207-
if(n_minus_z.getContent() == thiscontent)
1232+
if ((nodedef->get(n_minus_z).drawtype == NDT_RAILLIKE
1233+
&& ((ItemGroupList) nodedef->get(n_minus_z).groups)[groupname] != 0
1234+
&& self_connect_to_raillike)
1235+
|| n_minus_z.getContent() == thiscontent)
12081236
is_rail_z[0] = true;
1209-
if (n_minus_z_minus_y.getContent() == thiscontent)
1237+
1238+
if ((nodedef->get(n_minus_z_minus_y).drawtype == NDT_RAILLIKE
1239+
&& ((ItemGroupList) nodedef->get(n_minus_z_minus_y).groups)[groupname] != 0
1240+
&& self_connect_to_raillike)
1241+
|| n_minus_z_minus_y.getContent() == thiscontent)
12101242
is_rail_z_minus_y[0] = true;
1211-
if(n_minus_z_plus_y.getContent() == thiscontent)
1243+
1244+
if ((nodedef->get(n_minus_z_plus_y).drawtype == NDT_RAILLIKE
1245+
&& ((ItemGroupList) nodedef->get(n_minus_z_plus_y).groups)[groupname] != 0
1246+
&& self_connect_to_raillike)
1247+
|| n_minus_z_plus_y.getContent() == thiscontent)
12121248
is_rail_z_plus_y[0] = true;
12131249

1214-
if(n_plus_z.getContent() == thiscontent)
1250+
if ((nodedef->get(n_plus_z).drawtype == NDT_RAILLIKE
1251+
&& ((ItemGroupList) nodedef->get(n_plus_z).groups)[groupname] != 0
1252+
&& self_connect_to_raillike)
1253+
|| n_plus_z.getContent() == thiscontent)
12151254
is_rail_z[1] = true;
1216-
if (n_plus_z_minus_y.getContent() == thiscontent)
1255+
1256+
if ((nodedef->get(n_plus_z_minus_y).drawtype == NDT_RAILLIKE
1257+
&& ((ItemGroupList) nodedef->get(n_plus_z_minus_y).groups)[groupname] != 0
1258+
&& self_connect_to_raillike)
1259+
|| n_plus_z_minus_y.getContent() == thiscontent)
12171260
is_rail_z_minus_y[1] = true;
1218-
if(n_plus_z_plus_y.getContent() == thiscontent)
1261+
1262+
if ((nodedef->get(n_plus_z_plus_y).drawtype == NDT_RAILLIKE
1263+
&& ((ItemGroupList) nodedef->get(n_plus_z_plus_y).groups)[groupname] != 0
1264+
&& self_connect_to_raillike)
1265+
|| n_plus_z_plus_y.getContent() == thiscontent)
12191266
is_rail_z_plus_y[1] = true;
12201267

12211268
bool is_rail_x_all[] = {false, false};
@@ -1255,7 +1302,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
12551302
if(is_rail_x_all[0] && is_rail_x_all[1])
12561303
angle = 90;
12571304
if(is_rail_z_all[0] && is_rail_z_all[1]){
1258-
if (n_minus_z_plus_y.getContent() == thiscontent) angle = 180;
1305+
if (is_rail_z_plus_y[0])
1306+
angle = 180;
12591307
}
12601308
else if(is_rail_x_all[0] && is_rail_z_all[0])
12611309
angle = 270;

0 commit comments

Comments
 (0)
Please sign in to comment.