From 2b9d03b267a3a11e6fc81d94423caaa852616fa8 Mon Sep 17 00:00:00 2001
From: Perttu Ahola <celeron55@gmail.com>
Date: Mon, 13 Dec 2010 11:38:04 +0200
Subject: [PATCH] random stuff and different node lighting

---
 src/map.cpp      | 11 +++++++----
 src/mapblock.cpp | 16 +++++++++++-----
 src/test.cpp     |  3 ++-
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/map.cpp b/src/map.cpp
index ff57e8d90..8bc914cfd 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -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);
 				}
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 033c69cdb..7500143c0 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -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)
 		{
diff --git a/src/test.cpp b/src/test.cpp
index 726930ce6..6d71566f4 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -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
-- 
GitLab