summaryrefslogtreecommitdiffstats
path: root/src/Generating/ChunkDesc.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-11-29 12:05:35 +0100
committerHowaner <franzi.moos@googlemail.com>2014-11-29 12:05:35 +0100
commit648fee1a087cb97da9a4646d72ffc590e7837a67 (patch)
treeeb55b68428a303089bc1120e9c3593542059f18e /src/Generating/ChunkDesc.cpp
parentFinished mob spawner implementation. (diff)
parentMerge pull request #1619 from mc-server/WarningFixes (diff)
downloadcuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.tar
cuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.tar.gz
cuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.tar.bz2
cuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.tar.lz
cuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.tar.xz
cuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.tar.zst
cuberite-648fee1a087cb97da9a4646d72ffc590e7837a67.zip
Diffstat (limited to 'src/Generating/ChunkDesc.cpp')
-rw-r--r--src/Generating/ChunkDesc.cpp65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 020d3bd0f..4a5ac5a18 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -7,7 +7,7 @@
#include "ChunkDesc.h"
#include "../BlockArea.h"
#include "../Cuboid.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
#include "../BlockEntities/BlockEntity.h"
@@ -152,6 +152,52 @@ int cChunkDesc::GetHeight(int a_RelX, int a_RelZ)
+void cChunkDesc::SetHeightFromShape(const Shape & a_Shape)
+{
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int y = cChunkDef::Height - 1; y > 0; y--)
+ {
+ if (a_Shape[y + x * 256 + z * 16 * 256] != 0)
+ {
+ cChunkDef::SetHeight(m_HeightMap, x, z, y);
+ break;
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cChunkDesc::GetShapeFromHeight(Shape & a_Shape) const
+{
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int height = cChunkDef::GetHeight(m_HeightMap, x, z);
+ for (int y = 0; y <= height; y++)
+ {
+ a_Shape[y + x * 256 + z * 16 * 256] = 1;
+ }
+
+ for (int y = height + 1; y < cChunkDef::Height; y++)
+ {
+ a_Shape[y + x * 256 + z * 16 * 256] = 0;
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
void cChunkDesc::SetUseDefaultBiomes(bool a_bUseDefaultBiomes)
{
m_bUseDefaultBiomes = a_bUseDefaultBiomes;
@@ -366,6 +412,23 @@ HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
+HEIGHTTYPE cChunkDesc::GetMinHeight(void) const
+{
+ HEIGHTTYPE MinHeight = m_HeightMap[0];
+ for (size_t i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
+ {
+ if (m_HeightMap[i] < MinHeight)
+ {
+ MinHeight = m_HeightMap[i];
+ }
+ }
+ return MinHeight;
+}
+
+
+
+
+
void cChunkDesc::FillRelCuboid(
int a_MinX, int a_MaxX,
int a_MinY, int a_MaxY,