merged the content type extension and delta
authorPerttu Ahola <celeron55@gmail.com>
Sat, 23 Jul 2011 16:04:37 +0000 (19:04 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 23 Jul 2011 16:04:37 +0000 (19:04 +0300)
1  2 
src/content_craft.cpp
src/content_inventory.cpp
src/content_mapblock.cpp
src/content_mapnode.cpp
src/content_mapnode.h
src/environment.cpp
src/game.cpp
src/main.cpp
src/map.cpp
src/mapgen.cpp
src/mapnode.h

Simple merge
Simple merge
index 38bc9620cd748c6b7209adaf35d884c8527326f3,d8bf71dc032ad3d77da461e9f19d763aeffe6c11..4a9fa5e98cdfaf8c4c54f184e56854c9125b6244
@@@ -895,14 -904,56 +905,56 @@@ void mapblock_mesh_generate_special(Mes
                                                vertices[i].Pos.rotateXZBy(90);
                                }
                                else if(j == 4)
 -              else if(n.d == CONTENT_PAPYRUS)
+                               for(u16 i=0; i<4; i++)
+                               {
+                                       vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
+                               }
+                               u16 indices[] = {0,1,2,2,3,0};
+                               // Add to mesh collector
+                               collector.append(material_general, vertices, 4, indices, 6);
+                       }
+               }
+ #endif
++              else if(n.getContent() == CONTENT_PAPYRUS)
+               {
+                       u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
+                       video::SColor c(255,l,l,l);
+                       for(u32 j=0; j<4; j++)
+                       {
+                               video::S3DVertex vertices[4] =
+                               {
+                                       video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x0(), pa_papyrus.y1()),
+                                       video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x1(), pa_papyrus.y1()),
+                                       video::S3DVertex(BS/2,BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x1(), pa_papyrus.y0()),
+                                       video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x0(), pa_papyrus.y0()),
+                               };
+                               if(j == 0)
                                {
                                        for(u16 i=0; i<4; i++)
-                                               vertices[i].Pos.rotateYZBy(-90);
+                                               vertices[i].Pos.rotateXZBy(45);
                                }
-                               else if(j == 5)
+                               else if(j == 1)
                                {
                                        for(u16 i=0; i<4; i++)
-                                               vertices[i].Pos.rotateYZBy(90);
+                                               vertices[i].Pos.rotateXZBy(-45);
+                               }
+                               else if(j == 2)
+                               {
+                                       for(u16 i=0; i<4; i++)
+                                               vertices[i].Pos.rotateXZBy(135);
+                               }
+                               else if(j == 3)
+                               {
+                                       for(u16 i=0; i<4; i++)
+                                               vertices[i].Pos.rotateXZBy(-135);
                                }
  
                                for(u16 i=0; i<4; i++)
  
                                u16 indices[] = {0,1,2,2,3,0};
                                // Add to mesh collector
-                               collector.append(material_general, vertices, 4, indices, 6);
+                               collector.append(material_papyrus, vertices, 4, indices, 6);
                        }
                }
- #endif
 -              else if(n.d == CONTENT_RAIL)
++              else if(n.getContent() == 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)
++                      if(n_minus_x.getContent() == CONTENT_RAIL)
+                               is_rail_x[0] = true;
 -                      if(n_plus_x.d == CONTENT_RAIL)
++                      if(n_plus_x.getContent() == CONTENT_RAIL)
+                               is_rail_x[1] = true;
 -                      if(n_minus_z.d == CONTENT_RAIL)
++                      if(n_minus_z.getContent() == CONTENT_RAIL)
+                               is_rail_z[0] = true;
 -                      if(n_plus_z.d == CONTENT_RAIL)
++                      if(n_plus_z.getContent() == 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);
+               }
        }
  }
  #endif
index e2aed24581e208ca1bbe2772c8c3bf6465e10bc1,79e10fd617abfd4dbdbffb4b61f8ce866fdc0dfd..8701ab887ff84e56b65110cf69a7e23938bbca26
@@@ -31,59 -31,6 +31,65 @@@ void setStoneLikeDiggingProperties(Digg
  void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
  void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
  
 +content_t trans_table_19[][2] = {
 +      {CONTENT_GRASS, 1},
 +      {CONTENT_TREE, 4},
 +      {CONTENT_LEAVES, 5},
 +      {CONTENT_GRASS_FOOTSTEPS, 6},
 +      {CONTENT_MESE, 7},
 +      {CONTENT_MUD, 8},
 +      {CONTENT_CLOUD, 10},
 +      {CONTENT_COALSTONE, 11},
 +      {CONTENT_WOOD, 12},
 +      {CONTENT_SAND, 13},
 +      {CONTENT_COBBLE, 18},
 +      {CONTENT_STEEL, 19},
 +      {CONTENT_GLASS, 20},
 +      {CONTENT_MOSSYCOBBLE, 22},
 +      {CONTENT_GRAVEL, 23},
++      {CONTENT_SANDSTONE, 24},
++      {CONTENT_CACTUS, 25},
++      {CONTENT_BRICK, 26},
++      {CONTENT_CLAY, 27},
++      {CONTENT_PAPYRUS, 28},
++      {CONTENT_BOOKSHELF, 29},
 +};
 +
 +MapNode mapnode_translate_from_internal(MapNode n_from, u8 version)
 +{
 +      MapNode result = n_from;
 +      if(version <= 19)
 +      {
 +              content_t c_from = n_from.getContent();
 +              for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
 +              {
 +                      if(trans_table_19[i][0] == c_from)
 +                      {
 +                              result.setContent(trans_table_19[i][1]);
 +                              break;
 +                      }
 +              }
 +      }
 +      return result;
 +}
 +MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
 +{
 +      MapNode result = n_from;
 +      if(version <= 19)
 +      {
 +              content_t c_from = n_from.getContent();
 +              for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
 +              {
 +                      if(trans_table_19[i][1] == c_from)
 +                      {
 +                              result.setContent(trans_table_19[i][0]);
 +                              break;
 +                      }
 +              }
 +      }
 +      return result;
 +}
 +
  void content_mapnode_init()
  {
        // Read some settings
index b484cb2255be8be0ed694f83ac84ba2aa7753e5c,e53624c21597d5cb19d6e62d1299d387254d253a..02c604c60d3279971a6dbdafe14275b553d00e40
@@@ -20,48 -20,43 +20,55 @@@ with this program; if not, write to th
  #ifndef CONTENT_MAPNODE_HEADER
  #define CONTENT_MAPNODE_HEADER
  
 +#include "mapnode.h"
 +
  void content_mapnode_init();
  
 +MapNode mapnode_translate_from_internal(MapNode n_from, u8 version);
 +MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
 +
  /*
        Node content type IDs
 +      Ranges:
  */
- // Use these sparingly, only when the extra space in param2 is needed.
 +
 +// 0x000...0x07f (0...127): param2 is fully usable
 +// 126 and 127 are reserved.
++// Use these sparingly, only when the extra space in param2 might be needed.
  #define CONTENT_STONE 0
 -#define CONTENT_GRASS 1
  #define CONTENT_WATER 2
  #define CONTENT_TORCH 3
 -#define CONTENT_TREE 4
 -#define CONTENT_LEAVES 5
 -#define CONTENT_GRASS_FOOTSTEPS 6
 -#define CONTENT_MESE 7
 -#define CONTENT_MUD 8
  #define CONTENT_WATERSOURCE 9
 -// Pretty much useless, clouds won't be drawn this way
 -#define CONTENT_CLOUD 10
 -#define CONTENT_COALSTONE 11
 -#define CONTENT_WOOD 12
 -#define CONTENT_SAND 13
  #define CONTENT_SIGN_WALL 14
  #define CONTENT_CHEST 15
  #define CONTENT_FURNACE 16
--//#define CONTENT_WORKBENCH 17
 -#define CONTENT_COBBLE 18
 -#define CONTENT_STEEL 19
 -#define CONTENT_GLASS 20
  #define CONTENT_FENCE 21
 -#define CONTENT_MOSSYCOBBLE 22
 -#define CONTENT_GRAVEL 23
 -#define CONTENT_SANDSTONE 24
 -#define CONTENT_CACTUS 25
 -#define CONTENT_BRICK 26
 -#define CONTENT_CLAY 27
 -#define CONTENT_PAPYRUS 28
 -#define CONTENT_BOOKSHELF 29
+ #define CONTENT_RAIL 30
  
- // 0x800...0xfff: param2 higher 4 bytes are not usable
++// 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
 +#define CONTENT_GRASS 0x800 //1
 +#define CONTENT_TREE 0x801 //4
 +#define CONTENT_LEAVES 0x802 //5
 +#define CONTENT_GRASS_FOOTSTEPS 0x803 //6
 +#define CONTENT_MESE 0x804 //7
 +#define CONTENT_MUD 0x805 //8
 +// Pretty much useless, clouds won't be drawn this way
 +#define CONTENT_CLOUD 0x806 //10
 +#define CONTENT_COALSTONE 0x807 //11
 +#define CONTENT_WOOD 0x808 //12
 +#define CONTENT_SAND 0x809 //13
 +#define CONTENT_COBBLE 0x80a //18
 +#define CONTENT_STEEL 0x80b //19
 +#define CONTENT_GLASS 0x80c //20
 +#define CONTENT_MOSSYCOBBLE 0x80d //22
 +#define CONTENT_GRAVEL 0x80e //23
++#define CONTENT_SANDSTONE 0x80f //24
++#define CONTENT_CACTUS 0x810 //25
++#define CONTENT_BRICK 0x811 //26
++#define CONTENT_CLAY 0x812 //27
++#define CONTENT_PAPYRUS 0x813 //28
++#define CONTENT_BOOKSHELF 0x814 //29
++
 +
  #endif
  
Simple merge
diff --cc src/game.cpp
index 7e2ee44fc25b39faac46205ebaa819fdfc7e3a3b,0f858e879694cc3404a896e207ec0223d91e8afe..b26d489673e600cd4a9aec664db06b4551421477
@@@ -538,6 -538,43 +538,43 @@@ void getPointedNode(Client *client, v3
                                }
                        }
                }
 -              else if(n.d == CONTENT_RAIL)
++              else if(n.getContent() == CONTENT_RAIL)
+               {
 -                      v3s16 dir = unpackDir(n.dir);
++                      v3s16 dir = unpackDir(n.param0);
+                       v3f dir_f = v3f(dir.X, dir.Y, dir.Z);
+                       dir_f *= BS/2 - BS/6 - BS/20;
+                       v3f cpf = npf + dir_f;
+                       f32 distance = (cpf - camera_position).getLength();
+                       float d = (float)BS/16;
+                       v3f vertices[4] =
+                       {
+                               v3f(BS/2, -BS/2+d, -BS/2),
+                               v3f(-BS/2, -BS/2, BS/2),
+                       };
+                       for(s32 i=0; i<2; i++)
+                       {
+                               vertices[i] += npf;
+                       }
+                       core::aabbox3d<f32> box;
+                       box = core::aabbox3d<f32>(vertices[0]);
+                       box.addInternalPoint(vertices[1]);
+                       if(distance < mindistance)
+                       {
+                               if(box.intersectsWithLine(shootline))
+                               {
+                                       nodefound = true;
+                                       nodepos = np;
+                                       neighbourpos = np;
+                                       mindistance = distance;
+                                       nodehilightbox = box;
+                               }
+                       }
+               }
                /*
                        Regular blocks
                */
diff --cc src/main.cpp
index 5aff62bf29b776153ee77d75d1d7640515816670,9a1e1960f049ef5233a9a456020f89ac375dad6a..783faa4e24a83cd68a82607fcc46573729f74db5
@@@ -355,8 -337,14 +355,14 @@@ TODO: Restart irrlicht completely when 
  \r
  TODO: Merge bahamada's audio stuff (clean patch available)\r
  \r
 -TODO: Merge key configuration menu (no clean patch available)\r
 +TODO: Move content_features to mapnode_content_features.{h,cpp} or so\r
  \r
+ TODO: Add some kind of content range validation to mapnode serialization\r
\r
+ TODO: Make sure menu text position is fixed\r
\r
+ TODO: Fix sector over limits error\r
\r
  Making it more portable:\r
  ------------------------\r
   \r
diff --cc src/map.cpp
Simple merge
diff --cc src/mapgen.cpp
index d4143b6d6a93199594591f4d86b5693269c5f915,8dda93c960e30a74cd4cd2d55e30b11ba741e882..bc4f822808273ff7aace824cbc3a9dde4ca66622
@@@ -1894,7 -1938,7 +1938,7 @@@ void make_block(BlockMakeData *data
                        {
                                u32 i = data->vmanip->m_area.index(p);
                                MapNode *n = &data->vmanip->m_data[i];
-                               if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_IGNORE)
 -                              if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE && n->d != CONTENT_IGNORE)
++                              if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_WATERSOURCE && n->getContent() != CONTENT_IGNORE)
                                {
                                        found = true;
                                        break;
                        {
                                u32 i = data->vmanip->m_area.index(p);
                                MapNode *n = &data->vmanip->m_data[i];
-                               if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS)
-                                       continue;
 -                              if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND)
++                              if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS && n->getContent() != CONTENT_SAND)
+                                               continue;
+                               // Papyrus grows only on mud and in water
 -                              if(n->d == CONTENT_MUD && y <= WATER_LEVEL)
++                              if(n->getContent() == CONTENT_MUD && y <= WATER_LEVEL)
+                               {
+                                       p.Y++;
+                                       make_papyrus(vmanip, p);
+                               }
+                               // Trees grow only on mud and grass, on land
 -                              else if((n->d == CONTENT_MUD || n->d == CONTENT_GRASS) && y > WATER_LEVEL + 2)
++                              else if((n->getContent() == CONTENT_MUD || n->getContent() == CONTENT_GRASS) && y > WATER_LEVEL + 2)
+                               {
+                                       p.Y++;
+                                       make_tree(vmanip, p);
+                               }
+                               // Cactii grow only on sand, on land
 -                              else if(n->d == CONTENT_SAND && y > WATER_LEVEL + 2)
++                              else if(n->getContent() == CONTENT_SAND && y > WATER_LEVEL + 2)
+                               {
+                                       p.Y++;
+                                       make_cactus(vmanip, p);
+                               }
                        }
-                       // Tree will be placed one higher
-                       p.Y++;
-                       // Make a tree
-                       make_tree(vmanip, p);
                }
  
  #if 0
diff --cc src/mapnode.h
index 1b10a546b4d0470ac442eaba2496ce2698e8473c,33128049a2599692bf35212d671991e7b6401e2d..3b7ef58787899aa0780f3a0d8fd5e227c9c57cc0
@@@ -146,8 -150,10 +146,10 @@@ struct ContentFeature
        NodeMetadata *initial_metadata;
        
        // If the content is liquid, this is the flowing version of the liquid.
 -      // If content is flowing liquid, this is the same content.
 -      u8 liquid_alternative_flowing;
 +      // If content is liquid, this is the same content.
 +      content_t liquid_alternative_flowing;
+       // If the content is liquid, this is the source version of the liquid.
 -      u8 liquid_alternative_source;
++      content_t liquid_alternative_source;
        
        // Amount of light the node emits
        u8 light_source;