From 3be6891938fec9927854a0f0abe821a6271bba23 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 7 Jun 2011 19:24:30 +0200 Subject: [PATCH] + rail --- data/rail.png | Bin 0 -> 507 bytes data/rail_crossing.png | Bin 0 -> 555 bytes data/rail_curved.png | Bin 0 -> 545 bytes data/rail_t_junction.png | Bin 0 -> 542 bytes src/mapblock.cpp | 104 +++++++++++++++++++++++++++++++++++++++ src/mapnode.cpp | 11 +++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 21 ++++++++ 9 files changed, 138 insertions(+) create mode 100644 data/rail.png create mode 100644 data/rail_crossing.png create mode 100644 data/rail_curved.png create mode 100644 data/rail_t_junction.png diff --git a/data/rail.png b/data/rail.png new file mode 100644 index 0000000000000000000000000000000000000000..18176d9f3ca96ec9d6e4f6d41ab7a370aa93afeb GIT binary patch literal 507 zcmVPx#32;bRa{vGf6951U69E94oEQKA0ia1lK~y-)&6B@N98na7zxU=j>tw-1NU+dC z$R7|iDkRvYlN13FYq7KtBq?H-#uQ1DLLq{r2&pX$1_VLKkH%H8P!L5{QJk!+E9*{n zX7{~$DP}X0Dv+e`l=mJ!?mgTK4J|D%+M(e=%O5l}JZP7e7gL`C`1G$_s@G%;@gRCt94BK9S=tc{8B`VrwD5XzZ8-yC%%tU5AEa0 zZ%GDwheg^NfZc;4K{aOo$Uz8D5~8}Lreho_z)O6&E&n=Y@L{qqCC-d@S?->n;GR+yChoegbuB)%daag-!qf002ovPDHLkV1f&}+gAVp literal 0 HcmV?d00001 diff --git a/data/rail_crossing.png b/data/rail_crossing.png new file mode 100644 index 0000000000000000000000000000000000000000..98464057704a84ab9dfeac63f13e9b1af8d6f1ae GIT binary patch literal 555 zcmV+`0@VG9P)Px#32;bRa{vGf6951U69E94oEQKA0nkZAK~y-)rIO1_TTu{)f0KKoRRR_lqV;bm zr9MLUuEdQf>aH763q==-RD)0`2t`A5A%f3E>!UtMqfi%uOLtnqN=hSIF*o-pii$|c z>ty({&l`wmn9nC&tD zH{AA?^Bi{ARl;OvDH8~}ISS4$W0-b1*|(SCzIB!H`>z{h1AxD~y6j~C@EDu^AQFir zb^-#M{vfve8te*TV<#xNKLOpG!k0OXZZF(EopQ4kgia&yEa^1#>zHD30}NnbSxBzm zt5e1?UWF6L&&!s%F#la8LLGMC{;szre zHPGi3)H|ab;?J8O#A-SS!%Zm%xl t#n10DZ{q#v_X+}p%soCq9-m0t(KTmX;6MA&eM$fT002ovPDHLkV1jh{_{snP literal 0 HcmV?d00001 diff --git a/data/rail_curved.png b/data/rail_curved.png new file mode 100644 index 0000000000000000000000000000000000000000..62afa3d2b81c4dc6f85275ea6de89ffb43a1be8b GIT binary patch literal 545 zcmV++0^a?JP)Px#32;bRa{vGf6951U69E94oEQKA0mey0K~y-)y^~K!lW`cwKfi6gPR1Y?nzVF- zL=q2^R^-8Bdg>w+Aq8Qg{Si8hC?ObxLVpgHC@34dc#&995Eu+Rb&64R=o+CI6;86b zcguHwo(|)kdubEB^xS?Ae811<`SXMS84s_Wl*N0er8?(0h{2Cdo#5qZ5(89B)PBW@ zm1O~lMq-w{I;gPCNaFW;xIOnt)otPaP=|E+nrP{NP!YzTzf=I@=Z}lWt?fMn!!Rmh zQ)q_AeTYH_F*VOk^mUQM1u{%N8#a0vw^6wU^t5@eIF8V}k&^XrY=El>H z3LrGtF5cF|WrFaPPMI3+mU<+Q;;Tx}8tB;^ixX!Az$geVr=v`8_kvH(-JB;HiE*jx z8+xutNlFYq`CuUl4YteCBQ6@98t*nbtSy-MZAKE8)6TCMdY=pOS*XikO-TO1mzFFTjQ;6NB jK=T98eWHb{kCW;zgEX_2=&9K_00000NkvXXu0mjfyq^6z literal 0 HcmV?d00001 diff --git a/data/rail_t_junction.png b/data/rail_t_junction.png new file mode 100644 index 0000000000000000000000000000000000000000..9985f63cd49ce29f636e72fe3b168fe1b6bad236 GIT binary patch literal 542 zcmV+(0^$9MP)Px#32;bRa{vGf6951U69E94oEQKA0mDf|K~y-)m6J_KRB;r=fB$)ZUZZ_L8#mDh z6@df|6=4fE5w?gnGRPpb3DLkd89|F;KxiSMsTeWLFzblP3<84zTeORaAX>G1evpBZ zito*PZ+!2znCAKQ)V#}c?>U@vxflLbd1_KRGHGFt>d2&}JT)23X@FNxS|T8K|Du>W zf$aq-AQaGsqPiAh>I5I>YjeZB7o_jycclS7eVe2GTCMTZTI6t}W^vi)P=lu81vDlN zTtCF|0yuISfb;1A%4tMxj8MoIDZL(7an|d$3;E(ETJI_k< z$)hy2^+&|Iv#pDc74UsOBJUKbUWquctv5#@UnJG=gE!f$vM+&+%UoEhVEtZZ^j=E# z<)B_8@21tS1&5VYm*T_A@?Qd5a}SPN%643=`4w_~mn2pod;8q3IR{FXvK=4Wsch?M z0N3>*Ak#d@tw&cRl#n~mzD7=l-dgHG`w78Z{|SI?mw4R&!oj4$pVca@sbf^UfaC## z&ZnO@-9dLxSNt73pO}tB6-YGzQ!7f@7Fn{_D9_f&A70#Lcw$EFddg$(XV=9PVk8up gr)tl1rU{tgFLW2g;W?8CasU7T07*qoM6N<$g8pIiBme*a literal 0 HcmV?d00001 diff --git a/src/mapblock.cpp b/src/mapblock.cpp index c6b82634d..71044652d 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -1672,6 +1672,110 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) collector.append(material_papyrus, vertices, 4, indices, 6); } } + else if(n.d == CONTENT_RAIL) + { + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); + video::SColor c(255,l,l,l); + + bool is_rail_x [] = { false, false }; /* x-1, x+1 */ + bool is_rail_z [] = { false, false }; /* z-1, z+1 */ + + MapNode n_minus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x-1,y,z)); + MapNode n_plus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x+1,y,z)); + MapNode n_minus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z-1)); + MapNode n_plus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z+1)); + + if(n_minus_x.d == CONTENT_RAIL) + is_rail_x[0] = true; + if(n_plus_x.d == CONTENT_RAIL) + is_rail_x[1] = true; + if(n_minus_z.d == CONTENT_RAIL) + is_rail_z[0] = true; + if(n_plus_z.d == CONTENT_RAIL) + is_rail_z[1] = true; + + float d = (float)BS/16; + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c, + 0, 1), + video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c, + 1, 1), + video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c, + 1, 0), + video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c, + 0, 0), + }; + + video::SMaterial material_rail; + material_rail.setFlag(video::EMF_LIGHTING, false); + material_rail.setFlag(video::EMF_BACK_FACE_CULLING, false); + material_rail.setFlag(video::EMF_BILINEAR_FILTER, false); + material_rail.setFlag(video::EMF_FOG_ENABLE, true); + material_rail.MaterialType + = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + + int adjacencies = is_rail_x[0] + is_rail_x[1] + is_rail_z[0] + is_rail_z[1]; + + // Assign textures + if(adjacencies < 2) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + else if(adjacencies == 2) + { + if((is_rail_x[0] && is_rail_x[1]) || (is_rail_z[0] && is_rail_z[1])) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + else + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png")); + } + else if(adjacencies == 3) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png")); + else if(adjacencies == 4) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png")); + + // Rotate textures + int angle = 0; + + if(adjacencies == 1) + { + if(is_rail_x[0] || is_rail_x[1]) + angle = 90; + } + else if(adjacencies == 2) + { + if(is_rail_x[0] && is_rail_x[1]) + angle = 90; + else if(is_rail_x[0] && is_rail_z[0]) + angle = 270; + else if(is_rail_x[0] && is_rail_z[1]) + angle = 180; + else if(is_rail_x[1] && is_rail_z[1]) + angle = 90; + } + else if(adjacencies == 3) + { + if(!is_rail_x[0]) + angle=0; + if(!is_rail_x[1]) + angle=180; + if(!is_rail_z[0]) + angle=90; + if(!is_rail_z[1]) + angle=270; + } + + if(angle != 0) { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(angle); + } + + for(s32 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + u16 indices[] = {0,1,2,2,3,0}; + collector.append(material_rail, vertices, 4, indices, 6); + } } diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 7e97a8d04..1c0a2740b 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -281,6 +281,17 @@ void init_mapnode() f->solidness = 0; // drawn separately, makes no faces f->air_equivalent = true; // grass grows underneath + i = CONTENT_RAIL; + f = &g_content_features[i]; + f->setInventoryTexture("rail.png"); + f->light_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->solidness = 0; // drawn separately, makes no faces + f->air_equivalent = true; // grass grows underneath + f->walkable = false; + // Deprecated i = CONTENT_COALSTONE; f = &g_content_features[i]; diff --git a/src/mapnode.h b/src/mapnode.h index 57335b741..409fe2bcf 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -107,6 +107,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_CLAY 25 #define CONTENT_PAPYRUS 26 #define CONTENT_BOOKSHELF 27 +#define CONTENT_RAIL 28 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 7815f593e..a8a9a94a8 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -79,6 +79,7 @@ void initializeMaterialProperties() setWoodLikeDiggingProperties(CONTENT_PAPYRUS, 0.25); setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75); + setDirtLikeDiggingProperties(CONTENT_RAIL, 0.75); setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); setWoodLikeDiggingProperties(CONTENT_BOOKSHELF, 0.75); setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0); diff --git a/src/server.cpp b/src/server.cpp index f40ed05a5..4e9ff076f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3915,6 +3915,26 @@ void Server::UpdateCrafting(u16 peer_id) } } + // Rail + if(!found) + { + ItemSpec specs[9]; + specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[1] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[4] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[6] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[7] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_RAIL, 15)); + found = true; + } + } + // Chest if(!found) { @@ -4163,6 +4183,7 @@ void setCreativeInventory(Player *player) CONTENT_BOOKSHELF, CONTENT_GLASS, CONTENT_FENCE, + CONTENT_RAIL, CONTENT_MESE, CONTENT_WATERSOURCE, CONTENT_CLOUD,