summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-22 20:41:08 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-22 20:41:08 +0200
commit9dd0486faf6f52eb40e47f003d4c02eefc28c8f9 (patch)
tree3ca4ff0762816fe69ff0f7baf22232c9d30cf8f6 /source
parentMade redstone lamps turn on when powered and turn off when not powered. (diff)
downloadcuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.tar
cuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.tar.gz
cuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.tar.bz2
cuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.tar.lz
cuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.tar.xz
cuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.tar.zst
cuberite-9dd0486faf6f52eb40e47f003d4c02eefc28c8f9.zip
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp72
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockID.cpp41
-rw-r--r--source/BlockID.h29
-rw-r--r--source/Generating/ComposableGenerator.cpp13
-rw-r--r--source/Generating/EndGen.cpp217
-rw-r--r--source/Generating/EndGen.h69
-rw-r--r--source/Generating/FinishGen.cpp6
-rw-r--r--source/World.cpp5
-rw-r--r--source/World.h7
10 files changed, 437 insertions, 24 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 2432bc04f..386ec2e41 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/21/13 23:03:07.
+** Generated automatically by tolua++-1.0.92 on 06/22/13 19:31:23.
*/
#ifndef __cplusplus
@@ -2532,6 +2532,66 @@ static int tolua_AllToLua_ItemToFullString00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* function: StringToBiome */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_StringToBiome00
+static int tolua_AllToLua_StringToBiome00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const AString a_BiomeString = ((const AString) tolua_tocppstring(tolua_S,1,0));
+ {
+ EMCSBiome tolua_ret = (EMCSBiome) StringToBiome(a_BiomeString);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)a_BiomeString);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'StringToBiome'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: StringToDimension */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_StringToDimension00
+static int tolua_AllToLua_StringToDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const AString a_DimensionString = ((const AString) tolua_tocppstring(tolua_S,1,0));
+ {
+ eDimension tolua_ret = (eDimension) StringToDimension(a_DimensionString);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)a_DimensionString);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'StringToDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* get function: g_BlockLightValue */
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockLightValue
static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
@@ -10795,7 +10855,7 @@ static int tolua_AllToLua_cWorld_GetDimension00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetDimension'", NULL);
#endif
{
- cWorld::eDimension tolua_ret = (cWorld::eDimension) self->GetDimension();
+ eDimension tolua_ret = (eDimension) self->GetDimension();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@@ -27713,11 +27773,16 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_ENTITY_TYPE_OCELOT",E_ENTITY_TYPE_OCELOT);
tolua_constant(tolua_S,"E_ENTITY_TYPE_IRON_GOLEM",E_ENTITY_TYPE_IRON_GOLEM);
tolua_constant(tolua_S,"E_ENTITY_TYPE_VILLAGER",E_ENTITY_TYPE_VILLAGER);
+ tolua_constant(tolua_S,"dimNether",dimNether);
+ tolua_constant(tolua_S,"dimOverworld",dimOverworld);
+ tolua_constant(tolua_S,"dimEnd",dimEnd);
tolua_function(tolua_S,"BlockStringToType",tolua_AllToLua_BlockStringToType00);
tolua_function(tolua_S,"StringToItem",tolua_AllToLua_StringToItem00);
tolua_function(tolua_S,"ItemToString",tolua_AllToLua_ItemToString00);
tolua_function(tolua_S,"ItemTypeToString",tolua_AllToLua_ItemTypeToString00);
tolua_function(tolua_S,"ItemToFullString",tolua_AllToLua_ItemToFullString00);
+ tolua_function(tolua_S,"StringToBiome",tolua_AllToLua_StringToBiome00);
+ tolua_function(tolua_S,"StringToDimension",tolua_AllToLua_StringToDimension00);
tolua_array(tolua_S,"g_BlockLightValue",tolua_get_AllToLua_g_BlockLightValue,tolua_set_AllToLua_g_BlockLightValue);
tolua_array(tolua_S,"g_BlockSpreadLightFalloff",tolua_get_AllToLua_g_BlockSpreadLightFalloff,tolua_set_AllToLua_g_BlockSpreadLightFalloff);
tolua_array(tolua_S,"g_BlockTransparent",tolua_get_AllToLua_g_BlockTransparent,tolua_set_AllToLua_g_BlockTransparent);
@@ -28144,9 +28209,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cWorld","cWorld","",NULL);
tolua_beginmodule(tolua_S,"cWorld");
- tolua_constant(tolua_S,"dimNether",cWorld::dimNether);
- tolua_constant(tolua_S,"dimOverworld",cWorld::dimOverworld);
- tolua_constant(tolua_S,"dimEnd",cWorld::dimEnd);
tolua_function(tolua_S,"GetClassStatic",tolua_AllToLua_cWorld_GetClassStatic00);
tolua_function(tolua_S,"GetTime",tolua_AllToLua_cWorld_GetTime00);
tolua_function(tolua_S,"GetTicksUntilWeatherChange",tolua_AllToLua_cWorld_GetTicksUntilWeatherChange00);
diff --git a/source/Bindings.h b/source/Bindings.h
index b33124fe3..df29c6201 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/21/13 23:03:08.
+** Generated automatically by tolua++-1.0.92 on 06/22/13 19:31:24.
*/
/* Exported function */
diff --git a/source/BlockID.cpp b/source/BlockID.cpp
index f9a76daa2..a3bb75cf4 100644
--- a/source/BlockID.cpp
+++ b/source/BlockID.cpp
@@ -290,6 +290,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
{biHell, "Hell"},
{biHell, "Nether"},
{biSky, "Sky"},
+ {biSky, "End"},
{biFrozenOcean, "FrozenOcean"},
{biFrozenRiver, "FrozenRiver"},
{biIcePlains, "IcePlains"},
@@ -320,6 +321,46 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
+eDimension StringToDimension(const AString & a_DimensionString)
+{
+ int res = atoi(a_DimensionString.c_str());
+ if ((res != 0) || (a_DimensionString == "0"))
+ {
+ // It was a valid number
+ return (eDimension)res;
+ }
+
+ // Convert using a built-in map:
+ static struct
+ {
+ eDimension m_Dimension;
+ const char * m_String;
+ } DimensionMap [] =
+ {
+ { dimOverworld, "Overworld"},
+ { dimOverworld, "Normal"},
+ { dimOverworld, "World"},
+ { dimNether, "Nether"},
+ { dimNether, "Hell"}, // Alternate name for End
+ { dimEnd, "End"},
+ { dimEnd, "Sky"}, // Old name for End
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(DimensionMap); i++)
+ {
+ if (NoCaseCompare(DimensionMap[i].m_String, a_DimensionString) == 0)
+ {
+ return DimensionMap[i].m_Dimension;
+ }
+ } // for i - DimensionMap[]
+
+ // Not found
+ return (eDimension)-1000;
+}
+
+
+
+
+
// This is actually just some code that needs to run at program startup, so it is wrapped into a global var's constructor:
class cBlockPropertiesInitializer
{
diff --git a/source/BlockID.h b/source/BlockID.h
index cc89ad503..7e03388d3 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -602,6 +602,18 @@ enum
E_ENTITY_TYPE_IRON_GOLEM = 99,
E_ENTITY_TYPE_VILLAGER = 120,
} ;
+
+
+
+
+enum eDimension
+{
+ dimNether = -1,
+ dimOverworld = 0,
+ dimEnd = 1,
+} ;
+
+
// tolua_end
@@ -614,24 +626,31 @@ class cItem;
+// tolua_begin
+
/// Translates a blocktype string into blocktype. Takes either a number or an items.ini alias as input. Returns -1 on failure.
-extern BLOCKTYPE BlockStringToType(const AString & a_BlockTypeString); // tolua_export
+extern BLOCKTYPE BlockStringToType(const AString & a_BlockTypeString);
/// Translates an itemtype string into an item. Takes either a number, number^number, number:number or an items.ini alias as input. Returns true if successful.
-extern bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item); // tolua_export
+extern bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item);
/// Translates a full item into a string. If the ItemType is not recognized, the ItemType number is output into the string.
-extern AString ItemToString(const cItem & a_Item); // tolua_export
+extern AString ItemToString(const cItem & a_Item);
/// Translates itemtype into a string. If the type is not recognized, the itemtype number is output into the string.
-extern AString ItemTypeToString(short a_ItemType); // tolua_export
+extern AString ItemTypeToString(short a_ItemType);
/// Translates a full item into a fully-specified string (including meta and count). If the ItemType is not recognized, the ItemType number is output into the string.
-extern AString ItemToFullString(const cItem & a_Item); // tolua_export
+extern AString ItemToFullString(const cItem & a_Item);
/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
+/// Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns -1000 on failure
+extern eDimension StringToDimension(const AString & a_DimensionString);
+
+// tolua_end
+
diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp
index 7cf099c1f..c038712aa 100644
--- a/source/Generating/ComposableGenerator.cpp
+++ b/source/Generating/ComposableGenerator.cpp
@@ -19,6 +19,7 @@
#include "Caves.h"
#include "DistortedHeightmap.h"
+#include "EndGen.h"
#include "MineShafts.h"
#include "Noise3DGenerator.h"
#include "Ravines.h"
@@ -250,6 +251,11 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
((cDistortedHeightmap *)m_HeightGen)->Initialize(a_IniFile);
}
+ else if (NoCaseCompare(HeightGenName, "End") == 0)
+ {
+ m_HeightGen = new cEndGen(Seed);
+ ((cEndGen *)m_HeightGen)->Initialize(a_IniFile);
+ }
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
{
m_HeightGen = new cNoise3DComposable(Seed);
@@ -337,6 +343,11 @@ void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
m_CompositionGen = new cDistortedHeightmap(m_ChunkGenerator.GetSeed(), *m_BiomeGen);
((cDistortedHeightmap *)m_CompositionGen)->Initialize(a_IniFile);
}
+ else if (NoCaseCompare(CompoGenName, "end") == 0)
+ {
+ m_CompositionGen = new cEndGen(m_ChunkGenerator.GetSeed());
+ ((cEndGen *)m_CompositionGen)->Initialize(a_IniFile);
+ }
else if (NoCaseCompare(CompoGenName, "nether") == 0)
{
m_CompositionGen = new cCompoGenNether(m_ChunkGenerator.GetSeed());
@@ -469,7 +480,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
// Finishers, alpha-sorted:
if (NoCaseCompare(*itr, "BottomLava") == 0)
{
- int DefaultBottomLavaLevel = (m_World->GetDimension() == cWorld::dimNether) ? 30 : 10;
+ int DefaultBottomLavaLevel = (m_World->GetDimension() == dimNether) ? 30 : 10;
int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
}
diff --git a/source/Generating/EndGen.cpp b/source/Generating/EndGen.cpp
new file mode 100644
index 000000000..30fa457db
--- /dev/null
+++ b/source/Generating/EndGen.cpp
@@ -0,0 +1,217 @@
+
+// EndGen.cpp
+
+// Implements the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen
+
+#include "Globals.h"
+#include "EndGen.h"
+#include "../../iniFile/iniFile.h"
+#include "../LinearUpscale.h"
+
+
+
+
+
+enum
+{
+ // Interpolation cell size:
+ INTERPOL_X = 4,
+ INTERPOL_Y = 4,
+ INTERPOL_Z = 4,
+
+ // Size of chunk data, downscaled before interpolation:
+ DIM_X = 16 / INTERPOL_X + 1,
+ DIM_Y = 256 / INTERPOL_Y + 1,
+ DIM_Z = 16 / INTERPOL_Z + 1,
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cEndGen:
+
+cEndGen::cEndGen(int a_Seed) :
+ m_Seed(a_Seed),
+ m_IslandSizeX(256),
+ m_IslandSizeY(96),
+ m_IslandSizeZ(256),
+ m_FrequencyX(80),
+ m_FrequencyY(80),
+ m_FrequencyZ(80)
+{
+ m_Perlin.AddOctave(1, 1);
+ m_Perlin.AddOctave(2, 0.5);
+ m_Perlin.AddOctave(4, 0.25);
+}
+
+
+
+
+
+void cEndGen::Initialize(cIniFile & a_IniFile)
+{
+ m_IslandSizeX = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeX", m_IslandSizeX);
+ m_IslandSizeY = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeY", m_IslandSizeY);
+ m_IslandSizeZ = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeZ", m_IslandSizeZ);
+
+ m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyX", m_FrequencyX);
+ m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyY", m_FrequencyY);
+ m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyZ", m_FrequencyZ);
+
+ // Recalculate the min and max chunk coords of the island
+ m_MaxChunkX = (m_IslandSizeX + cChunkDef::Width - 1) / cChunkDef::Width;
+ m_MinChunkX = -m_MaxChunkX;
+ m_MaxChunkZ = (m_IslandSizeZ + cChunkDef::Width - 1) / cChunkDef::Width;
+ m_MinChunkZ = -m_MaxChunkZ;
+}
+
+
+
+
+
+/// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
+void cEndGen::PrepareState(int a_ChunkX, int a_ChunkZ)
+{
+ ASSERT(!IsChunkOutsideRange(a_ChunkX, a_ChunkZ)); // Should be filtered before calling this function
+
+ if ((m_LastChunkX == a_ChunkX) && (m_LastChunkZ == a_ChunkZ))
+ {
+ return;
+ }
+
+ m_LastChunkX = a_ChunkX;
+ m_LastChunkZ = a_ChunkZ;
+
+ GenerateNoiseArray();
+}
+
+
+
+
+
+/// Generates the m_NoiseArray array for the current chunk
+void cEndGen::GenerateNoiseArray(void)
+{
+ NOISE_DATATYPE NoiseData[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
+ NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
+
+ // Generate the downscaled noise:
+ NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width)) / m_FrequencyX;
+ NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_LastChunkX + 1) * cChunkDef::Width)) / m_FrequencyX;
+ NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_LastChunkZ * cChunkDef::Width)) / m_FrequencyZ;
+ NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_LastChunkZ + 1) * cChunkDef::Width)) / m_FrequencyZ;
+ NOISE_DATATYPE StartY = 0;
+ NOISE_DATATYPE EndY = ((NOISE_DATATYPE)257) / m_FrequencyY;
+ m_Perlin.Generate3D(NoiseData, DIM_X, DIM_Z, DIM_Y, StartX, EndX, StartZ, EndZ, StartY, EndY, Workspace);
+
+ // Add distance:
+ int idx = 0;
+ for (int y = 0; y < DIM_Y; y++)
+ {
+ NOISE_DATATYPE ValY = (NOISE_DATATYPE)(2 * INTERPOL_Y * y - m_IslandSizeY) / m_IslandSizeY;
+ ValY = ValY * ValY;
+ for (int z = 0; z < DIM_Z; z++)
+ {
+ NOISE_DATATYPE ValZ = (NOISE_DATATYPE)(m_LastChunkZ * cChunkDef::Width + (z * cChunkDef::Width / (DIM_Z - 1))) / m_IslandSizeZ;
+ ValZ = ValZ * ValZ;
+ for (int x = 0; x < DIM_X; x++)
+ {
+ // NOISE_DATATYPE ValX = StartX + (EndX - StartX) * x / (DIM_X - 1);
+ NOISE_DATATYPE ValX = (NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width + (x * cChunkDef::Width / (DIM_X - 1))) / m_IslandSizeX;
+ ValX = ValX * ValX;
+ NoiseData[idx++] += ValX + ValZ + ValY;
+ } // for x
+ } // for z
+ } // for y
+
+ // Upscale into real chunk size:
+ LinearUpscale3DArray(NoiseData, DIM_X, DIM_Z, DIM_Y, m_NoiseArray, INTERPOL_X, INTERPOL_Z, INTERPOL_Y);
+}
+
+
+
+
+
+/// Returns true if the chunk is outside of the island's dimensions
+bool cEndGen::IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ)
+{
+ return (
+ (a_ChunkX < m_MinChunkX) || (a_ChunkX > m_MaxChunkX) ||
+ (a_ChunkZ < m_MinChunkZ) || (a_ChunkZ > m_MaxChunkZ)
+ );
+}
+
+
+
+
+
+void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ))
+ {
+ for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
+ {
+ a_HeightMap[i] = 0;
+ }
+ return;
+ }
+
+ PrepareState(a_ChunkX, a_ChunkZ);
+
+ int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, MaxY);
+ for (int y = MaxY; y > 0; y--)
+ {
+ if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, y);
+ break;
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cEndGen::ComposeTerrain(cChunkDesc & a_ChunkDesc)
+{
+ if (IsChunkOutsideRange(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()))
+ {
+ a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
+ return;
+ }
+
+ PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
+
+ int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int y = MaxY; y > 0; y--)
+ {
+ if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_END_STONE, 0);
+ }
+ else
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_AIR, 0);
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
diff --git a/source/Generating/EndGen.h b/source/Generating/EndGen.h
new file mode 100644
index 000000000..cd316ed67
--- /dev/null
+++ b/source/Generating/EndGen.h
@@ -0,0 +1,69 @@
+
+// EndGen.h
+
+// Declares the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+class cEndGen :
+ public cTerrainHeightGen,
+ public cTerrainCompositionGen
+{
+public:
+ cEndGen(int a_Seed);
+
+ void Initialize(cIniFile & a_IniFile);
+
+protected:
+
+ /// Seed for the noise
+ int m_Seed;
+
+ /// The Perlin noise used for generating
+ cPerlinNoise m_Perlin;
+
+ // XYZ size of the "island", in blocks:
+ int m_IslandSizeX;
+ int m_IslandSizeY;
+ int m_IslandSizeZ;
+
+ // XYZ Frequencies of the noise functions:
+ NOISE_DATATYPE m_FrequencyX;
+ NOISE_DATATYPE m_FrequencyY;
+ NOISE_DATATYPE m_FrequencyZ;
+
+ // Minimum and maximum chunk coords for chunks inside the island area. Chunks outside won't get calculated at all
+ int m_MinChunkX, m_MaxChunkX;
+ int m_MinChunkZ, m_MaxChunkZ;
+
+ // Noise array for the last chunk (in the noise range)
+ int m_LastChunkX;
+ int m_LastChunkZ;
+ NOISE_DATATYPE m_NoiseArray[17 * 17 * 257]; // x + 17 * z + 17 * 17 * y
+
+ /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
+ void PrepareState(int a_ChunkX, int a_ChunkZ);
+
+ /// Generates the m_NoiseArray array for the current chunk
+ void GenerateNoiseArray(void);
+
+ /// Returns true if the chunk is outside of the island's dimensions
+ bool IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ);
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+
+ // cTerrainCompositionGen overrides:
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+} ;
diff --git a/source/Generating/FinishGen.cpp b/source/Generating/FinishGen.cpp
index df9b2f265..8899e4bd0 100644
--- a/source/Generating/FinishGen.cpp
+++ b/source/Generating/FinishGen.cpp
@@ -531,19 +531,19 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI
int DefaultChance;
switch (a_World.GetDimension())
{
- case cWorld::dimNether:
+ case dimNether:
{
DefaultHeightDistribution = IsWater ? DEF_NETHER_WATER_SPRINGS : DEF_NETHER_LAVA_SPRINGS;
DefaultChance = IsWater ? 0 : 15;
break;
}
- case cWorld::dimOverworld:
+ case dimOverworld:
{
DefaultHeightDistribution = IsWater ? DEF_OVERWORLD_WATER_SPRINGS : DEF_OVERWORLD_LAVA_SPRINGS;
DefaultChance = IsWater ? 24 : 9;
break;
}
- case cWorld::dimEnd:
+ case dimEnd:
{
DefaultHeightDistribution = IsWater ? DEF_END_WATER_SPRINGS : DEF_END_LAVA_SPRINGS;
DefaultChance = 0;
diff --git a/source/World.cpp b/source/World.cpp
index 2a73eb7ea..c8a7b9ded 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -215,7 +215,8 @@ cWorld::cWorld(const AString & a_WorldName) :
cIniFile IniFile(m_IniFileName);
IniFile.ReadFile();
- m_Dimension = (eDimension)(IniFile.GetValueSetI("General", "Dimension", 0));
+ AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld");
+ m_Dimension = StringToDimension(Dimension);
switch (m_Dimension)
{
case dimNether:
@@ -226,7 +227,7 @@ cWorld::cWorld(const AString & a_WorldName) :
}
default:
{
- LOGWARNING("Unknown dimension: %d. Setting to Overworld (0)", m_Dimension);
+ LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", Dimension.c_str());
m_Dimension = dimOverworld;
break;
}
diff --git a/source/World.h b/source/World.h
index 647c109e8..aa1f1f8bb 100644
--- a/source/World.h
+++ b/source/World.h
@@ -59,13 +59,6 @@ class cWorld
{
public:
- enum eDimension
- {
- dimNether = -1,
- dimOverworld = 0,
- dimEnd = 1,
- } ;
-
// tolua_end
/// A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor