random stuff and different node lighting

This commit is contained in:
Perttu Ahola 2010-12-13 11:38:04 +02:00
parent de83bfb81e
commit 2b9d03b267
3 changed files with 20 additions and 10 deletions

@ -1961,9 +1961,10 @@ MapBlock * ServerMap::emergeBlock(
Add some minerals
*/
if(is_underground)
//if(is_underground)
if(some_part_underground)
{
s16 underground_level = lowest_ground_y/MAP_BLOCKSIZE - block_y;
s16 underground_level = (lowest_ground_y/MAP_BLOCKSIZE - block_y)+1;
for(s16 i=0; i<underground_level*3; i++)
{
if(rand()%2 == 0)
@ -1977,13 +1978,15 @@ MapBlock * ServerMap::emergeBlock(
MapNode n;
n.d = CONTENT_MESE;
if(is_ground_content(block->getNode(cp).d))
//if(is_ground_content(block->getNode(cp).d))
if(block->getNode(cp).d == CONTENT_STONE)
if(rand()%8 == 0)
block->setNode(cp, n);
for(u16 i=0; i<26; i++)
{
if(is_ground_content(block->getNode(cp+g_26dirs[i]).d))
//if(is_ground_content(block->getNode(cp+g_26dirs[i]).d))
if(block->getNode(cp+g_26dirs[i]).d == CONTENT_STONE)
if(rand()%8 == 0)
block->setNode(cp+g_26dirs[i], n);
}

@ -162,9 +162,15 @@ u8 MapBlock::getFaceLight(v3s16 p, v3s16 face_dir)
light = n2.getLight();
// Make some nice difference to different sides
if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
/*if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
light = diminish_light(diminish_light(light));
else if(face_dir.X == -1 || face_dir.Z == -1)
light = diminish_light(light);*/
if(face_dir.X == 1 || face_dir.X == -1 || face_dir.Y == -1)
light = diminish_light(diminish_light(light));
else if(face_dir.Z == 1 || face_dir.Z == -1)
light = diminish_light(light);
return light;
@ -832,13 +838,13 @@ void MapBlock::serialize(std::ostream &os, u8 version)
}
compress(materialdata, os, version);
// Get and compress params
SharedBuffer<u8> paramdata(nodecount);
// Get and compress lights
SharedBuffer<u8> lightdata(nodecount);
for(u32 i=0; i<nodecount; i++)
{
paramdata[i] = data[i].param;
lightdata[i] = data[i].param;
}
compress(paramdata, os, version);
compress(lightdata, os, version);
if(version >= 10)
{

@ -461,7 +461,8 @@ struct TestMapBlock
assert(b.getFaceLight(p, v3s16(0,-1,0)) == 0);
// According to MapBlock::getFaceLight,
// The face on the z+ side should have double-diminished light
assert(b.getFaceLight(p, v3s16(0,0,1)) == diminish_light(diminish_light(LIGHT_MAX)));
//assert(b.getFaceLight(p, v3s16(0,0,1)) == diminish_light(diminish_light(LIGHT_MAX)));
assert(b.getFaceLight(p, v3s16(0,0,1)) == diminish_light(LIGHT_MAX));
}
/*
Check how the block handles being in between blocks with some non-sunlight