}
else
{
- // Turn mud into grass
+ /*// Turn mud into grass
if(n.d == CONTENT_MUD)
{
n.d = CONTENT_GRASS;
block->setNode(relpos, n);
modified_blocks.insert(blockpos, block);
- }
+ }*/
// Sunlight goes no further
break;
}
/*
- This is called after changing a node from transparent to opaque.
- The lighting value of the node should be left as-is after changing
- other values. This sets the lighting value to 0.
*/
void Map::addNodeAndUpdate(v3s16 p, MapNode n,
core::map<v3s16, MapBlock*> &modified_blocks)
catch(InvalidPositionException &e)
{
}
-
+
+#if 1
/*
- If the new node doesn't propagate sunlight and there is
- grass below, change it to mud
+ If the new node is solid and there is grass below, change it to mud
*/
- if(content_features(n.d).sunlight_propagates == false)
+ if(content_features(n.d).walkable == true)
{
try{
MapNode bottomnode = getNode(bottompos);
{
}
}
+#endif
+#if 0
/*
If the new node is mud and it is under sunlight, change it
to grass
{
n.d = CONTENT_GRASS;
}
+#endif
/*
Remove all light that has come out of this node
}
}
+void make_cactus(VoxelManipulator &vmanip, v3s16 p0)
+{
+ MapNode cactusnode(CONTENT_CACTUS);
+
+ s16 trunk_h = 3;
+ v3s16 p1 = p0;
+ for(s16 ii=0; ii<trunk_h; ii++)
+ {
+ if(vmanip.m_area.contains(p1))
+ vmanip.m_data[vmanip.m_area.index(p1)] = cactusnode;
+ p1.Y++;
+ }
+}
+
/*
Noise functions. Make sure seed is mangled differently in each one.
*/
if(have_sand == false)
continue;
+ // Determine whether to have clay in the sand here
+ double claynoise = noise2d_perlin(
+ 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500,
+ data->seed+4321, 8, 0.95);
+
+ bool have_clay = have_sand && (claynoise > 0.95);
+
// Find ground level
s16 surface_y = find_ground_level_clever(data->vmanip, p2d);
MapNode *n = &data->vmanip.m_data[i];
if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
{
- n->d = CONTENT_SAND;
+ if(have_clay && (surface_y == WATER_LEVEL))
+ n->d = CONTENT_CLAY;
+ else
+ n->d = CONTENT_SAND;
}
else
{
if(y > y_nodes_max - 6)
continue;
v3s16 p(x,y,z);
- /*
- Trees grow only on mud and grass
- */
{
u32 i = data->vmanip.m_area.index(v3s16(p));
MapNode *n = &data->vmanip.m_data[i];
- if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS)
+ if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND)
continue;
+ // Trees grow only on mud and grass
+ if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
+ {
+ p.Y++;
+ make_tree(data->vmanip, p);
+ }
+ // Cactii grow only on sand
+ if(n->d == CONTENT_SAND)
+ {
+ p.Y++;
+ make_cactus(data->vmanip, p);
+ }
}
- p.Y++;
- // Make a tree
- make_tree(data->vmanip, p);
}
}
/*u32 tree_max = relative_area / 60;
sectorpos_base - v2s16(1,1) * max_spread_amount_sectors;
s16 sectorpos_bigbase_size =
sectorpos_base_size + 2 * max_spread_amount_sectors;
-
+
+ // Check limits
+ const s16 limit = MAP_GENERATION_LIMIT / MAP_BLOCKSIZE;
+ if(sectorpos_bigbase.X < -limit
+ || sectorpos_bigbase.X + sectorpos_bigbase_size >= limit
+ || sectorpos_bigbase.Y < -limit
+ || sectorpos_bigbase.Y + sectorpos_bigbase_size >= limit)
+ {
+ data.no_op = true;
+ return;
+ }
+
data.seed = m_seed;
data.chunkpos = chunkpos;
data.y_blocks_min = y_blocks_min;
*/
o.write((char*)&version, 1);
+ // Write basic data
block->serialize(o, version);
-
- /*
- Versions up from 9 have block objects.
- */
- if(version >= 9)
- {
- block->serializeObjects(o, version);
- }
- /*
- Versions up from 15 have static objects.
- */
- if(version >= 15)
- {
- block->m_static_objects.serialize(o);
- }
-
- // We just wrote it to the disk
+ // Write extra data stored on disk
+ block->serializeDiskExtra(o, version);
+
+ // We just wrote it to the disk so clear modified flag
block->resetChangedFlag();
}
created_new = true;
}
- // deserialize block data
+ // Read basic data
block->deSerialize(is, version);
-
- /*
- Versions up from 9 have block objects.
- */
- if(version >= 9)
- {
- block->updateObjects(is, version, NULL, 0);
- }
- /*
- Versions up from 15 have static objects.
- */
- if(version >= 15)
- {
- block->m_static_objects.deSerialize(is);
- }
+ // Read extra data stored on disk
+ block->deSerializeDiskExtra(is, version);
+ // If it's a new block, insert it to the map
if(created_new)
sector->insertBlock(block);
/*
- Convert old formats to new and save
+ Save blocks loaded in old format in new format
*/
- // Save old format blocks in new format
if(version < SER_FMT_VER_HIGHEST || save_after_load)
{
saveBlock(block);