(svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
authortron
Sat, 22 Jul 2006 07:36:01 +0000
changeset 4157 8d0051fdde68
parent 4156 22b62f705930
child 4158 91ff9bb84ced
(svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
clear_cmd.c
tree_cmd.c
--- a/clear_cmd.c	Sat Jul 22 07:28:04 2006 +0000
+++ b/clear_cmd.c	Sat Jul 22 07:36:01 2006 +0000
@@ -595,17 +595,16 @@
 /* convert into snowy tiles */
 static void TileLoopClearAlps(TileIndex tile)
 {
-	/* distance from snow line, in steps of 8 */
-	int k = GetTileZ(tile) - _opt.snow_line;
+	int k = GetTileZ(tile) - _opt.snow_line + TILE_HEIGHT;
 
-	if (k < -TILE_HEIGHT) { // well below the snow line
+	if (k < 0) { // well below the snow line
 		if (!IsClearGround(tile, CLEAR_SNOW)) return;
 		if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3);
 	} else {
 		if (!IsClearGround(tile, CLEAR_SNOW)) {
 			SetClearGroundDensity(tile, CLEAR_SNOW, 0);
 		} else {
-			uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3);
+			uint density = min((uint)k / TILE_HEIGHT, 3);
 
 			if (GetClearDensity(tile) < density) {
 				AddClearDensity(tile, 1);
--- a/tree_cmd.c	Sat Jul 22 07:28:04 2006 +0000
+++ b/tree_cmd.c	Sat Jul 22 07:36:01 2006 +0000
@@ -405,13 +405,13 @@
 
 static void TileLoopTreesAlps(TileIndex tile)
 {
-	int k = GetTileZ(tile) - _opt.snow_line;
+	int k = GetTileZ(tile) - _opt.snow_line + TILE_HEIGHT;
 
-	if (k < -TILE_HEIGHT) {
+	if (k < 0) {
 		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) return;
 		SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 0);
 	} else {
-		uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3);
+		uint density = min((uint)k / TILE_HEIGHT, 3);
 
 		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT ||
 				GetTreeDensity(tile) != density) {