diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-17 18:55:03 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-17 18:55:03 +0100 |
commit | 1ed3b3aed2e538af2c3bffa41f54a30ac6535f12 (patch) | |
tree | 173949d9abcbd08d9c3535704419a372e52c7c8a | |
parent | ProbabDistrib: fixed definition string parsing with nonzero start (diff) | |
download | cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.tar cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.tar.gz cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.tar.bz2 cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.tar.lz cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.tar.xz cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.tar.zst cuberite-1ed3b3aed2e538af2c3bffa41f54a30ac6535f12.zip |
-rw-r--r-- | source/Bindings.cpp | 141 | ||||
-rw-r--r-- | source/Bindings.h | 2 | ||||
-rw-r--r-- | source/Generating/Caves.cpp | 68 | ||||
-rw-r--r-- | source/Generating/Caves.h | 36 | ||||
-rw-r--r-- | source/Generating/ChunkDesc.cpp | 26 | ||||
-rw-r--r-- | source/Generating/ChunkDesc.h | 20 | ||||
-rw-r--r-- | source/Generating/CompoGen.cpp | 134 | ||||
-rw-r--r-- | source/Generating/CompoGen.h | 50 | ||||
-rw-r--r-- | source/Generating/ComposableGenerator.cpp | 11 | ||||
-rw-r--r-- | source/Generating/ComposableGenerator.h | 30 | ||||
-rw-r--r-- | source/Generating/FinishGen.cpp | 298 | ||||
-rw-r--r-- | source/Generating/FinishGen.h | 139 | ||||
-rw-r--r-- | source/Generating/Ravines.cpp | 17 | ||||
-rw-r--r-- | source/Generating/Ravines.h | 9 | ||||
-rw-r--r-- | source/Generating/StructGen.cpp | 88 | ||||
-rw-r--r-- | source/Generating/StructGen.h | 37 |
16 files changed, 444 insertions, 662 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 5c7ee3b1d..2f7ce10ce 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 03/14/13 10:02:26. +** Generated automatically by tolua++-1.0.92 on 03/17/13 18:47:08. */ #ifndef __cplusplus @@ -347,9 +347,9 @@ static int tolua_AllToLua_cVine_DirectionToMetaData00(lua_State* tolua_S) else #endif { - char a_Direction = ((char) tolua_tonumber(tolua_S,2,0)); + char a_BlockFace = ((char) tolua_tonumber(tolua_S,2,0)); { - unsigned char tolua_ret = (unsigned char) cVine::DirectionToMetaData(a_Direction); + unsigned char tolua_ret = (unsigned char) cVine::DirectionToMetaData(a_BlockFace); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -19595,6 +19595,105 @@ static int tolua_AllToLua_cBlockArea_HasBlockSkyLights00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: GetChunkX of class cChunkDesc */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_GetChunkX00 +static int tolua_AllToLua_cChunkDesc_GetChunkX00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cChunkDesc",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cChunkDesc* self = (const cChunkDesc*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetChunkX'", NULL); +#endif + { + int tolua_ret = (int) self->GetChunkX(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetChunkX'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetChunkZ of class cChunkDesc */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_GetChunkZ00 +static int tolua_AllToLua_cChunkDesc_GetChunkZ00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cChunkDesc",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cChunkDesc* self = (const cChunkDesc*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetChunkZ'", NULL); +#endif + { + int tolua_ret = (int) self->GetChunkZ(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetChunkZ'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetChunkCoords of class cChunkDesc */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_SetChunkCoords00 +static int tolua_AllToLua_cChunkDesc_SetChunkCoords00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cChunkDesc",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0); + int a_ChunkX = ((int) tolua_tonumber(tolua_S,2,0)); + int a_ChunkZ = ((int) tolua_tonumber(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetChunkCoords'", NULL); +#endif + { + self->SetChunkCoords(a_ChunkX,a_ChunkZ); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetChunkCoords'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: FillBlocks of class cChunkDesc */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_FillBlocks00 static int tolua_AllToLua_cChunkDesc_FillBlocks00(lua_State* tolua_S) @@ -20423,6 +20522,38 @@ static int tolua_AllToLua_cChunkDesc_ReadBlockArea00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: GetMaxHeight of class cChunkDesc */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_GetMaxHeight00 +static int tolua_AllToLua_cChunkDesc_GetMaxHeight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cChunkDesc",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cChunkDesc* self = (const cChunkDesc*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMaxHeight'", NULL); +#endif + { + unsigned char tolua_ret = ( unsigned char) self->GetMaxHeight(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetMaxHeight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: new of class cCraftingGrid */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_new00 static int tolua_AllToLua_cCraftingGrid_new00(lua_State* tolua_S) @@ -22505,6 +22636,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"cChunkDesc","cChunkDesc","",NULL); tolua_beginmodule(tolua_S,"cChunkDesc"); + tolua_function(tolua_S,"GetChunkX",tolua_AllToLua_cChunkDesc_GetChunkX00); + tolua_function(tolua_S,"GetChunkZ",tolua_AllToLua_cChunkDesc_GetChunkZ00); + tolua_function(tolua_S,"SetChunkCoords",tolua_AllToLua_cChunkDesc_SetChunkCoords00); tolua_function(tolua_S,"FillBlocks",tolua_AllToLua_cChunkDesc_FillBlocks00); tolua_function(tolua_S,"SetBlockTypeMeta",tolua_AllToLua_cChunkDesc_SetBlockTypeMeta00); tolua_function(tolua_S,"GetBlockTypeMeta",tolua_AllToLua_cChunkDesc_GetBlockTypeMeta00); @@ -22528,6 +22662,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"IsUsingDefaultFinish",tolua_AllToLua_cChunkDesc_IsUsingDefaultFinish00); tolua_function(tolua_S,"WriteBlockArea",tolua_AllToLua_cChunkDesc_WriteBlockArea00); tolua_function(tolua_S,"ReadBlockArea",tolua_AllToLua_cChunkDesc_ReadBlockArea00); + tolua_function(tolua_S,"GetMaxHeight",tolua_AllToLua_cChunkDesc_GetMaxHeight00); tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",tolua_collect_cCraftingGrid); diff --git a/source/Bindings.h b/source/Bindings.h index 525565986..d3e0643c2 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 03/14/13 10:02:26. +** Generated automatically by tolua++-1.0.92 on 03/17/13 18:47:09. */ /* Exported function */ diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp index 2bf145de6..fdd6d4dce 100644 --- a/source/Generating/Caves.cpp +++ b/source/Generating/Caves.cpp @@ -755,20 +755,15 @@ void cStructGenWormNestCaves::ClearCache(void) -void cStructGenWormNestCaves::GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
-)
+void cStructGenWormNestCaves::GenStructures(cChunkDesc & a_ChunkDesc)
{
+ int ChunkX = a_ChunkDesc.GetChunkX();
+ int ChunkZ = a_ChunkDesc.GetChunkZ();
cCaveSystems Caves;
- GetCavesForChunk(a_ChunkX, a_ChunkZ, Caves);
+ GetCavesForChunk(ChunkX, ChunkZ, Caves);
for (cCaveSystems::const_iterator itr = Caves.begin(); itr != Caves.end(); ++itr)
{
- (*itr)->ProcessChunk(a_ChunkX, a_ChunkZ, a_BlockTypes, a_HeightMap);
+ (*itr)->ProcessChunk(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap());
} // for itr - Caves[]
}
@@ -900,27 +895,20 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) -void cStructGenMarbleCaves::GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
-)
+void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
{
cNoise Noise(m_Seed);
for (int z = 0; z < cChunkDef::Width; z++)
{
- const float zz = (float)(a_ChunkZ * cChunkDef::Width + z);
+ const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z);
for (int x = 0; x < cChunkDef::Width; x++)
{
- const float xx = (float)(a_ChunkX * cChunkDef::Width + x);
+ const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
- int Top = cChunkDef::GetHeight(a_HeightMap, x, z);
+ int Top = a_ChunkDesc.GetHeight(x, z);
for (int y = 1; y < Top; ++y )
{
- if (cChunkDef::GetBlock(a_BlockTypes, x, y, z) != E_BLOCK_STONE)
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_STONE)
{
continue;
}
@@ -929,7 +917,7 @@ void cStructGenMarbleCaves::GenStructures( const float WaveNoise = 1;
if (cosf(GetMarbleNoise(xx, yy * 0.5f, zz, Noise)) * fabs(cosf(yy * 0.2f + WaveNoise * 2) * 0.75f + WaveNoise) > 0.0005f)
{
- cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
}
} // for y
} // for x
@@ -943,43 +931,27 @@ void cStructGenMarbleCaves::GenStructures( ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenDualRidgeCaves:
-void cStructGenDualRidgeCaves::GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
-)
+void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
{
- cNoise Noise1(m_Seed);
- cNoise Noise2(2 * m_Seed + 19999);
for (int z = 0; z < cChunkDef::Width; z++)
{
- const float zz = (float)(a_ChunkZ * cChunkDef::Width + z) / 10;
+ const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10;
for (int x = 0; x < cChunkDef::Width; x++)
{
- const float xx = (float)(a_ChunkX * cChunkDef::Width + x) / 10;
+ const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10;
- int Top = cChunkDef::GetHeight(a_HeightMap, x, z);
+ int Top = a_ChunkDesc.GetHeight(x, z);
for (int y = 1; y <= Top; ++y)
{
- /*
- if (cChunkDef::GetBlock(a_BlockTypes, x, y, z) != E_BLOCK_STONE)
- {
- continue;
- }
- */
-
const float yy = (float)y / 10;
const float WaveNoise = 1;
- float n1 = Noise1.CubicNoise3D(xx, yy, zz);
- float n2 = Noise2.CubicNoise3D(xx, yy, zz);
- float n3 = Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
- float n4 = Noise2.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
+ float n1 = m_Noise1.CubicNoise3D(xx, yy, zz);
+ float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
+ float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
+ float n4 = m_Noise2.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
if ((abs(n1 + n3) * abs(n2 + n4)) > m_Threshold)
{
- cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
}
} // for y
} // for x
diff --git a/source/Generating/Caves.h b/source/Generating/Caves.h index 58213abe2..bb69550a8 100644 --- a/source/Generating/Caves.h +++ b/source/Generating/Caves.h @@ -30,14 +30,7 @@ protected: int m_Seed;
// cStructureGen override:
- virtual void GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
- ) override;
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -49,25 +42,21 @@ class cStructGenDualRidgeCaves : {
public:
cStructGenDualRidgeCaves(int a_Seed, float a_Threshold) :
+ m_Noise1(a_Seed),
+ m_Noise2(2 * a_Seed + 19999),
m_Seed(a_Seed),
m_Threshold(a_Threshold)
{
}
protected:
-
- int m_Seed;
- float m_Threshold;
+ cNoise m_Noise1;
+ cNoise m_Noise2;
+ int m_Seed;
+ float m_Threshold;
// cStructureGen override:
- virtual void GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
- ) override;
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -105,14 +94,7 @@ protected: void GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cCaveSystems & a_Caves);
// cStructGen override:
- virtual void GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
- ) override;
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp index f19c0ae1e..00ccacc07 100644 --- a/source/Generating/ChunkDesc.cpp +++ b/source/Generating/ChunkDesc.cpp @@ -39,6 +39,16 @@ cChunkDesc::~cChunkDesc() +void cChunkDesc::SetChunkCoords(int a_ChunkX, int a_ChunkZ)
+{
+ m_ChunkX = a_ChunkX;
+ m_ChunkZ = a_ChunkZ;
+}
+
+
+
+
+
void cChunkDesc::FillBlocks(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
const NIBBLETYPE CompressedMeta = a_BlockMeta | (a_BlockMeta << 4);
@@ -411,3 +421,19 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX +HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
+{
+ HEIGHTTYPE MaxHeight = m_HeightMap[0];
+ for (int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
+ {
+ if (m_HeightMap[i] > MaxHeight)
+ {
+ MaxHeight = m_HeightMap[i];
+ }
+ }
+ return MaxHeight;
+}
+
+
+
+
diff --git a/source/Generating/ChunkDesc.h b/source/Generating/ChunkDesc.h index afe3df331..7df7a1d35 100644 --- a/source/Generating/ChunkDesc.h +++ b/source/Generating/ChunkDesc.h @@ -33,6 +33,11 @@ public: // tolua_begin + int GetChunkX(void) const { return m_ChunkX; } + int GetChunkZ(void) const { return m_ChunkZ; } + + void SetChunkCoords(int a_ChunkX, int a_ChunkZ); + void FillBlocks(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); @@ -67,16 +72,19 @@ public: /// Reads an area from the chunk into a cBlockArea void ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ); + /// Returns the maximum height value in the heightmap + HEIGHTTYPE GetMaxHeight(void) const; + // tolua_end // Accessors used by cChunkGenerator::Generator descendants: - cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; } - cChunkDef::BlockTypes & GetBlockTypes (void) { return m_BlockTypes; } - cChunkDef::BlockNibbles & GetBlockMetas (void) { return m_BlockMeta; } - cChunkDef::HeightMap & GetHeightMap (void) { return m_HeightMap; } - cEntityList & GetEntities (void) { return m_Entities; } - cBlockEntityList & GetBlockEntities(void) { return m_BlockEntities; } + inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; } + inline cChunkDef::BlockTypes & GetBlockTypes (void) { return m_BlockTypes; } + inline cChunkDef::BlockNibbles & GetBlockMetas (void) { return m_BlockMeta; } + inline cChunkDef::HeightMap & GetHeightMap (void) { return m_HeightMap; } + inline cEntityList & GetEntities (void) { return m_Entities; } + inline cBlockEntityList & GetBlockEntities(void) { return m_BlockEntities; } private: int m_ChunkX; diff --git a/source/Generating/CompoGen.cpp b/source/Generating/CompoGen.cpp index e1d620ab3..34a83bd52 100644 --- a/source/Generating/CompoGen.cpp +++ b/source/Generating/CompoGen.cpp @@ -18,18 +18,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cCompoGenSameBlock: -void cCompoGenSameBlock::ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) -) +void cCompoGenSameBlock::ComposeTerrain(cChunkDesc & a_ChunkDesc) { - memset(a_BlockTypes, E_BLOCK_AIR, sizeof(a_BlockTypes)); - memset(a_BlockMeta, 0, sizeof(a_BlockMeta)); + memset(a_ChunkDesc.GetBlockTypes(), E_BLOCK_AIR, sizeof(a_ChunkDesc.GetBlockTypes())); + memset(a_ChunkDesc.GetBlockMetas(), 0, sizeof(a_ChunkDesc.GetBlockMetas())); for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) @@ -37,16 +29,16 @@ void cCompoGenSameBlock::ComposeTerrain( int Start; if (m_IsBedrocked) { - a_BlockTypes[cChunkDef::MakeIndex(x, 0, z)] = E_BLOCK_BEDROCK; + a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK); Start = 1; } else { Start = 0; } - for (int y = a_HeightMap[x + cChunkDef::Width * z]; y >= Start; y--) + for (int y = a_ChunkDesc.GetHeight(x, z); y >= Start; y--) { - a_BlockTypes[cChunkDef::MakeIndex(x, y, z)] = m_BlockType; + a_ChunkDesc.SetBlockType(x, y, z, m_BlockType); } // for y } // for z } // for x @@ -59,15 +51,7 @@ void cCompoGenSameBlock::ComposeTerrain( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cCompoGenDebugBiomes: -void cCompoGenDebugBiomes::ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) -) +void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) { static BLOCKTYPE Blocks[] = { @@ -96,17 +80,17 @@ void cCompoGenDebugBiomes::ComposeTerrain( E_BLOCK_BEDROCK, } ; - memset(a_BlockTypes, E_BLOCK_AIR, sizeof(a_BlockTypes)); - memset(a_BlockMeta, 0, sizeof(a_BlockMeta)); + memset(a_ChunkDesc.GetBlockTypes(), E_BLOCK_AIR, sizeof(a_ChunkDesc.GetBlockTypes())); + memset(a_ChunkDesc.GetBlockMetas(), 0, sizeof(a_ChunkDesc.GetBlockMetas())); for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) { - BLOCKTYPE BlockType = Blocks[cChunkDef::GetBiome(a_BiomeMap, x, z) % ARRAYCOUNT(Blocks)]; - for (int y = a_HeightMap[x + cChunkDef::Width * z]; y >= 0; y--) + BLOCKTYPE BlockType = Blocks[a_ChunkDesc.GetBiome(x, z)]; + for (int y = a_ChunkDesc.GetHeight(x, z); y >= 0; y--) { - cChunkDef::SetBlock(a_BlockTypes, x, y, z, BlockType); + a_ChunkDesc.SetBlockType(x, y, z, BlockType); } // for y } // for z } // for x @@ -140,15 +124,7 @@ cCompoGenClassic::cCompoGenClassic( -void cCompoGenClassic::ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) -) +void cCompoGenClassic::ComposeTerrain(cChunkDesc & a_ChunkDesc) { /* The classic composition means: - 1 layer of grass, 3 of dirt and the rest stone, if the height > sealevel + beachheight @@ -158,13 +134,13 @@ void cCompoGenClassic::ComposeTerrain( - bedrock at the bottom */ - memset(a_BlockTypes, E_BLOCK_AIR, sizeof(a_BlockTypes)); - memset(a_BlockMeta, 0, sizeof(a_BlockMeta)); + memset(a_ChunkDesc.GetBlockTypes(), E_BLOCK_AIR, sizeof(a_ChunkDesc.GetBlockTypes())); + memset(a_ChunkDesc.GetBlockMetas(), 0, sizeof(a_ChunkDesc.GetBlockMetas())); // The patterns to use for different situations, must be same length! - static const BLOCKTYPE PatternGround[] = {m_BlockTop, m_BlockMiddle, m_BlockMiddle, m_BlockMiddle} ; - static const BLOCKTYPE PatternBeach[] = {m_BlockBeach, m_BlockBeach, m_BlockBeach, m_BlockBeachBottom} ; - static const BLOCKTYPE PatternOcean[] = {m_BlockMiddle, m_BlockMiddle, m_BlockMiddle, m_BlockBottom} ; + const BLOCKTYPE PatternGround[] = {m_BlockTop, m_BlockMiddle, m_BlockMiddle, m_BlockMiddle} ; + const BLOCKTYPE PatternBeach[] = {m_BlockBeach, m_BlockBeach, m_BlockBeach, m_BlockBeachBottom} ; + const BLOCKTYPE PatternOcean[] = {m_BlockMiddle, m_BlockMiddle, m_BlockMiddle, m_BlockBottom} ; static int PatternLength = ARRAYCOUNT(PatternGround); ASSERT(ARRAYCOUNT(PatternGround) == ARRAYCOUNT(PatternBeach)); ASSERT(ARRAYCOUNT(PatternGround) == ARRAYCOUNT(PatternOcean)); @@ -173,7 +149,7 @@ void cCompoGenClassic::ComposeTerrain( { for (int x = 0; x < cChunkDef::Width; x++) { - int Height = cChunkDef::GetHeight(a_HeightMap, x, z); + int Height = a_ChunkDesc.GetHeight(x, z); const BLOCKTYPE * Pattern; if (Height > m_SeaLevel + m_BeachHeight) { @@ -191,17 +167,17 @@ void cCompoGenClassic::ComposeTerrain( // Fill water from sealevel down to height (if any): for (int y = m_SeaLevel; y >= Height; --y) { - cChunkDef::SetBlock(a_BlockTypes, x, y, z, m_BlockSea); + a_ChunkDesc.SetBlockType(x, y, z, m_BlockSea); } // Fill from height till the bottom: for (int y = Height; y >= 1; y--) { - cChunkDef::SetBlock(a_BlockTypes, x, y, z, (Height - y < PatternLength) ? Pattern[Height - y] : m_BlockBottom); + a_ChunkDesc.SetBlockType(x, y, z, (Height - y < PatternLength) ? Pattern[Height - y] : m_BlockBottom); } // The last layer is always bedrock: - cChunkDef::SetBlock(a_BlockTypes, x, 0, z, E_BLOCK_BEDROCK); + a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK); } // for x } // for z } @@ -213,26 +189,21 @@ void cCompoGenClassic::ComposeTerrain( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cCompoGenBiomal: -void cCompoGenBiomal::ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) -) +void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc) { - memset(a_BlockTypes, 0, sizeof(a_BlockTypes)); - memset(a_BlockMeta, 0, sizeof(a_BlockMeta)); + memset(a_ChunkDesc.GetBlockTypes(), E_BLOCK_AIR, sizeof(a_ChunkDesc.GetBlockTypes())); + memset(a_ChunkDesc.GetBlockMetas(), 0, sizeof(a_ChunkDesc.GetBlockMetas())); + + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) { - int Height = cChunkDef::GetHeight(a_HeightMap, x, z); + int Height = a_ChunkDesc.GetHeight(x, z); if (Height > m_SeaLevel) { - switch (cChunkDef::GetBiome(a_BiomeMap, x, z)) + switch (a_ChunkDesc.GetBiome(x, z)) { case biOcean: case biPlains: @@ -251,20 +222,20 @@ void cCompoGenBiomal::ComposeTerrain( case biJungle: case biJungleHills: { - FillColumnGrass(x, z, Height, a_BlockTypes); + FillColumnGrass(x, z, Height, a_ChunkDesc.GetBlockTypes()); break; } case biDesertHills: case biDesert: case biBeach: { - FillColumnSand(x, z, Height, a_BlockTypes); + FillColumnSand(x, z, Height, a_ChunkDesc.GetBlockTypes()); break; } case biMushroomIsland: case biMushroomShore: { - FillColumnMycelium(x, z, Height, a_BlockTypes); + FillColumnMycelium(x, z, Height, a_ChunkDesc.GetBlockTypes()); break; } default: @@ -277,24 +248,24 @@ void cCompoGenBiomal::ComposeTerrain( } else { - switch (cChunkDef::GetBiome(a_BiomeMap, x, z)) + switch (a_ChunkDesc.GetBiome(x, z)) { case biDesert: case biBeach: { // Fill with water, sand, sandstone and stone - FillColumnWaterSand(x, z, Height, a_BlockTypes); + FillColumnWaterSand(x, z, Height, a_ChunkDesc.GetBlockTypes()); break; } default: { // Fill with water, sand/dirt/clay mix and stone - FillColumnWaterMix(a_ChunkX, a_ChunkZ, x, z, Height, a_BlockTypes); + FillColumnWaterMix(ChunkX, ChunkZ, x, z, Height, a_ChunkDesc.GetBlockTypes()); break; } } // switch (biome) } // else (under water) - cChunkDef::SetBlock(a_BlockTypes, x, 0, z, E_BLOCK_BEDROCK); + a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK); } // for x } // for z } @@ -440,29 +411,14 @@ cCompoGenNether::cCompoGenNether(int a_Seed) : -void cCompoGenNether::ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) -) +void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) { - HEIGHTTYPE MaxHeight = 0; - for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++) - { - if (a_HeightMap[i] > MaxHeight) - { - MaxHeight = a_HeightMap[i]; - } - } + HEIGHTTYPE MaxHeight = a_ChunkDesc.GetMaxHeight(); const int SEGMENT_HEIGHT = 8; const int INTERPOL_X = 16; // Must be a divisor of 16 const int INTERPOL_Z = 16; // Must be a divisor of 16 - // Interpolate the chunk in 16 * SEGMENT_HEIGHT * 16 "segments", each 8 blocks high and each linearly interpolated separately. + // Interpolate the chunk in 16 * SEGMENT_HEIGHT * 16 "segments", each SEGMENT_HEIGHT blocks high and each linearly interpolated separately. // Have two buffers, one for the lowest floor and one for the highest floor, so that Y-interpolation can be done between them // Then swap the buffers and use the previously-top one as the current-bottom, without recalculating it. @@ -470,8 +426,8 @@ void cCompoGenNether::ComposeTerrain( int FloorBuf2[17 * 17]; int * FloorHi = FloorBuf1; int * FloorLo = FloorBuf2; - int BaseX = a_ChunkX * cChunkDef::Width; - int BaseZ = a_ChunkZ * cChunkDef::Width; + int BaseX = a_ChunkDesc.GetChunkX() * cChunkDef::Width; + int BaseZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width; // Interpolate the lowest floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) @@ -504,7 +460,7 @@ void cCompoGenNether::ComposeTerrain( for (int y = 0; y < SEGMENT_HEIGHT; y++) { int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT; - cChunkDef::SetBlock(a_BlockTypes, x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_NETHERRACK : E_BLOCK_AIR); + a_ChunkDesc.SetBlockType(x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_NETHERRACK : E_BLOCK_AIR); } } @@ -515,8 +471,8 @@ void cCompoGenNether::ComposeTerrain( // Bedrock at the bottom and at the top: for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) { - cChunkDef::SetBlock(a_BlockTypes, x, 0, z, E_BLOCK_BEDROCK); - cChunkDef::SetBlock(a_BlockTypes, x, cChunkDef::GetHeight(a_HeightMap, x, z), z, E_BLOCK_BEDROCK); + a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK); + a_ChunkDesc.SetBlockType(x, a_ChunkDesc.GetHeight(x, z), z, E_BLOCK_BEDROCK); } } diff --git a/source/Generating/CompoGen.h b/source/Generating/CompoGen.h index e92ba505c..9880ce1a0 100644 --- a/source/Generating/CompoGen.h +++ b/source/Generating/CompoGen.h @@ -36,15 +36,7 @@ protected: bool m_IsBedrocked; // cTerrainCompositionGen overrides: - virtual void ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) - ) override; + virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override; } ; @@ -60,15 +52,7 @@ public: protected: // cTerrainCompositionGen overrides: - virtual void ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) - ) override; + virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override; } ; @@ -98,15 +82,7 @@ protected: BLOCKTYPE m_BlockSea; // cTerrainCompositionGen overrides: - virtual void ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) - ) override; + virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override; } ; @@ -129,15 +105,7 @@ protected: int m_SeaLevel; // cTerrainCompositionGen overrides: - virtual void ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) - ) override; + virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override; void FillColumnGrass (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnSand (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); @@ -166,15 +134,7 @@ protected: int m_Threshold; // cTerrainCompositionGen overrides: - virtual void ComposeTerrain( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated - cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated - const cChunkDef::HeightMap & a_HeightMap, // The height map to fit - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entitites may be generated along with the terrain - cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...) - ) override; + virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override; } ; diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp index e9196757b..b88fb90c7 100644 --- a/source/Generating/ComposableGenerator.cpp +++ b/source/Generating/ComposableGenerator.cpp @@ -9,7 +9,6 @@ #include "../World.h"
#include "../../iniFile/iniFile.h"
#include "../Root.h"
-#include "ChunkDesc.h"
// Individual composed algorithms:
#include "BioGen.h"
@@ -114,14 +113,14 @@ void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a if (a_ChunkDesc.IsUsingDefaultComposition())
{
- m_CompositionGen->ComposeTerrain(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, BiomeMap, Entities, BlockEntities);
+ m_CompositionGen->ComposeTerrain(a_ChunkDesc);
}
if (a_ChunkDesc.IsUsingDefaultStructures())
{
for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
{
- (*itr)->GenStructures(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, Entities, BlockEntities);
+ (*itr)->GenStructures(a_ChunkDesc);
} // for itr - m_StructureGens[]
}
@@ -129,7 +128,7 @@ void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a {
for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
{
- (*itr)->GenFinish(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, BiomeMap, Entities, BlockEntities);
+ (*itr)->GenFinish(a_ChunkDesc);
} // for itr - m_FinishGens[]
}
}
@@ -372,7 +371,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) }
else if (NoCaseCompare(*itr, "DeadBushes") == 0)
{
- m_FinishGens.push_back(new cFinishGenDeadBushes(Seed));
+ m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
}
else if (NoCaseCompare(*itr, "Ice") == 0)
{
@@ -384,7 +383,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) }
else if (NoCaseCompare(*itr, "Lilypads") == 0)
{
- m_FinishGens.push_back(new cFinishGenLilypads(Seed));
+ m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
}
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
{
diff --git a/source/Generating/ComposableGenerator.h b/source/Generating/ComposableGenerator.h index b6f946eb3..fca2c26c6 100644 --- a/source/Generating/ComposableGenerator.h +++ b/source/Generating/ComposableGenerator.h @@ -18,6 +18,7 @@ See http://forum.mc-server.org/showthread.php?tid=409 for details. #pragma once
#include "ChunkGenerator.h"
+#include "ChunkDesc.h"
@@ -72,15 +73,7 @@ class cTerrainCompositionGen public:
virtual ~cTerrainCompositionGen() {} // Force a virtual destructor in descendants
- virtual void ComposeTerrain(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // BlockTypes to be generated (the whole array gets initialized, even air)
- cChunkDef::BlockNibbles & a_BlockMeta, // BlockMetas to be generated (the whole array gets initialized)
- const cChunkDef::HeightMap & a_HeightMap, // The height map to fit
- const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to
- cEntityList & a_Entities, // Entitites may be generated along with the terrain
- cBlockEntityList & a_BlockEntities // Block entitites may be generated (chests / furnaces / ...)
- ) = 0;
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) = 0;
} ;
@@ -98,14 +91,7 @@ class cStructureGen public:
virtual ~cStructureGen() {} // Force a virtual destructor in descendants
- virtual void GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
- ) = 0;
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) = 0;
} ;
typedef std::list<cStructureGen *> cStructureGenList;
@@ -122,15 +108,7 @@ class cFinishGen public:
virtual ~cFinishGen() {} // Force a virtual destructor in descendants
- virtual void GenFinish(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
- ) = 0;
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) = 0;
} ;
typedef std::list<cFinishGen *> cFinishGenList;
diff --git a/source/Generating/FinishGen.cpp b/source/Generating/FinishGen.cpp index ab3d9488d..6a7d53b14 100644 --- a/source/Generating/FinishGen.cpp +++ b/source/Generating/FinishGen.cpp @@ -42,12 +42,7 @@ static inline bool IsWater(BLOCKTYPE a_BlockType) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: -bool cFinishGenSprinkleFoliage::TryAddSugarcane( - int a_ChunkX, int a_ChunkZ, - int a_RelX, int a_RelY, int a_RelZ, - cChunkDef::BlockTypes & a_BlockTypes, - cChunkDef::BlockNibbles & a_BlockMeta -) +bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ) { // We'll be doing comparison to neighbors, so require the coords to be 1 block away from the chunk edges: if ( @@ -60,7 +55,7 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane( } // Only allow dirt, grass or sand below sugarcane: - switch (cChunkDef::GetBlock(a_BlockTypes, a_RelX, a_RelY, a_RelZ)) + switch (a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ)) { case E_BLOCK_DIRT: case E_BLOCK_GRASS: @@ -76,17 +71,17 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane( // Water is required next to the block below the sugarcane: if ( - !IsWater(cChunkDef::GetBlock(a_BlockTypes, a_RelX - 1, a_RelY, a_RelZ)) && - !IsWater(cChunkDef::GetBlock(a_BlockTypes, a_RelX + 1, a_RelY, a_RelZ)) && - !IsWater(cChunkDef::GetBlock(a_BlockTypes, a_RelX , a_RelY, a_RelZ - 1)) && - !IsWater(cChunkDef::GetBlock(a_BlockTypes, a_RelX , a_RelY, a_RelZ + 1)) + !IsWater(a_ChunkDesc.GetBlockType(a_RelX - 1, a_RelY, a_RelZ)) && + !IsWater(a_ChunkDesc.GetBlockType(a_RelX + 1, a_RelY, a_RelZ)) && + !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ - 1)) && + !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ + 1)) ) { return false; } // All conditions met, place a sugarcane here: - cChunkDef::SetBlock(a_BlockTypes, a_RelX, a_RelY + 1, a_RelZ, E_BLOCK_SUGARCANE); + a_ChunkDesc.SetBlockType(a_RelX, a_RelY + 1, a_RelZ, E_BLOCK_SUGARCANE); return true; } @@ -94,38 +89,29 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane( -void cFinishGenSprinkleFoliage::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) +void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { // Generate small foliage (1-block): // TODO: Update heightmap with 1-block-tall foliage - cNoise Noise(m_Seed); for (int z = 0; z < cChunkDef::Width; z++) { - int BlockZ = a_ChunkZ * cChunkDef::Width + z; + int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; const float zz = (float)BlockZ; for (int x = 0; x < cChunkDef::Width; x++) { - int BlockX = a_ChunkX * cChunkDef::Width + x; - if (((Noise.IntNoise2DInt(BlockX, BlockZ) / 8) % 128) < 124) + int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; + if (((m_Noise.IntNoise2DInt(BlockX, BlockZ) / 8) % 128) < 124) { continue; } - int Top = cChunkDef::GetHeight(a_HeightMap, x, z); + int Top = a_ChunkDesc.GetHeight(x, z); if (Top > 250) { // Nothing grows above Y=250 continue; } - if (cChunkDef::GetBlock(a_BlockTypes, x, Top + 1, z) != E_BLOCK_AIR) + if (a_ChunkDesc.GetBlockType(x, Top + 1, z) != E_BLOCK_AIR) { // Space already taken by something else, don't grow here // WEIRD, since we're using heightmap, so there should NOT be anything above it @@ -133,43 +119,41 @@ void cFinishGenSprinkleFoliage::GenFinish( } const float xx = (float)BlockX; - float val1 = Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f ); - float val2 = Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f ); - switch (cChunkDef::GetBlock(a_BlockTypes, x, Top, z)) + float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f ); + float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f ); + switch (a_ChunkDesc.GetBlockType(x, Top, z)) { case E_BLOCK_GRASS: { - float val3 = Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10 ); - float val4 = Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20 ); + float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10 ); + float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20 ); if (val1 + val2 > 0.2f) { - cChunkDef::SetBlock(a_BlockTypes, x, ++Top, z, E_BLOCK_YELLOW_FLOWER); + a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_YELLOW_FLOWER); } else if (val2 + val3 > 0.2f) { - cChunkDef::SetBlock(a_BlockTypes, x, ++Top, z, E_BLOCK_RED_ROSE); + a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_RED_ROSE); } else if (val3 + val4 > 0.2f) { - cChunkDef::SetBlock(a_BlockTypes, x, ++Top, z, E_BLOCK_RED_MUSHROOM); + a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_RED_MUSHROOM); } else if (val1 + val4 > 0.2f) { - cChunkDef::SetBlock(a_BlockTypes, x, ++Top, z, E_BLOCK_BROWN_MUSHROOM); + a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_BROWN_MUSHROOM); } else if (val1 + val2 + val3 + val4 < -0.1) { - cChunkDef::SetBlock (a_BlockTypes, x, ++Top, z, E_BLOCK_TALL_GRASS); - cChunkDef::SetNibble(a_BlockMeta, x, Top, z, E_META_TALL_GRASS_GRASS); + a_ChunkDesc.SetBlockTypeMeta(x, ++Top, z, E_BLOCK_TALL_GRASS, E_META_TALL_GRASS_GRASS); } - else if (TryAddSugarcane(a_ChunkX, a_ChunkZ, x, Top, z, a_BlockTypes, a_BlockMeta)) + else if (TryAddSugarcane(a_ChunkDesc, x, Top, z)) { ++Top; } else if ((val1 > 0.5) && (val2 < -0.5)) { - cChunkDef::SetBlock (a_BlockTypes, x, ++Top, z, E_BLOCK_PUMPKIN); - cChunkDef::SetNibble(a_BlockMeta, x, Top, z, (int)(val3 * 8) % 4); + a_ChunkDesc.SetBlockTypeMeta(x, ++Top, z, E_BLOCK_PUMPKIN, (int)(val3 * 8) % 4); } break; } // case E_BLOCK_GRASS @@ -181,22 +165,22 @@ void cFinishGenSprinkleFoliage::GenFinish( (x > 0) && (x < cChunkDef::Width - 1) && (z > 0) && (z < cChunkDef::Width - 1) && (val1 + val2 > 0.5f) && - (cChunkDef::GetBlock(a_BlockTypes, x + 1, y, z) == E_BLOCK_AIR) && - (cChunkDef::GetBlock(a_BlockTypes, x - 1, y, z) == E_BLOCK_AIR) && - (cChunkDef::GetBlock(a_BlockTypes, x, y, z + 1) == E_BLOCK_AIR) && - (cChunkDef::GetBlock(a_BlockTypes, x, y, z - 1) == E_BLOCK_AIR) + (a_ChunkDesc.GetBlockType(x + 1, y, z) == E_BLOCK_AIR) && + (a_ChunkDesc.GetBlockType(x - 1, y, z) == E_BLOCK_AIR) && + (a_ChunkDesc.GetBlockType(x, y, z + 1) == E_BLOCK_AIR) && + (a_ChunkDesc.GetBlockType(x, y, z - 1) == E_BLOCK_AIR) ) { - cChunkDef::SetBlock(a_BlockTypes, x, ++Top, z, E_BLOCK_CACTUS); + a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_CACTUS); } - else if (TryAddSugarcane(a_ChunkX, a_ChunkZ, x, Top, z, a_BlockTypes, a_BlockMeta)) + else if (TryAddSugarcane(a_ChunkDesc, x, Top, z)) { ++Top; } break; } } // switch (TopBlock) - cChunkDef::SetHeight(a_HeightMap, x, z, Top); + a_ChunkDesc.SetHeight(x, z, Top); } // for y } // for z } @@ -208,22 +192,14 @@ void cFinishGenSprinkleFoliage::GenFinish( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenSnow: -void cFinishGenSnow::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) +void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc) { // Add a snow block in snowy biomes onto blocks that can be snowed over for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) { - switch (cChunkDef::GetBiome(a_BiomeMap, x, z)) + switch (a_ChunkDesc.GetBiome(x, z)) { case biIcePlains: case biIceMountains: @@ -232,11 +208,11 @@ void cFinishGenSnow::GenFinish( case biFrozenRiver: case biFrozenOcean: { - int Height = cChunkDef::GetHeight(a_HeightMap, x, z); - if (g_BlockIsSnowable[cChunkDef::GetBlock(a_BlockTypes, x, Height, z)]) + int Height = a_ChunkDesc.GetHeight(x, z); + if (g_BlockIsSnowable[a_ChunkDesc.GetBlockType(x, Height, z)]) { - cChunkDef::SetBlock(a_BlockTypes, x, Height + 1, z, E_BLOCK_SNOW); - cChunkDef::SetHeight(a_HeightMap, x, z, Height + 1); + a_ChunkDesc.SetBlockType(x, Height + 1, z, E_BLOCK_SNOW); + a_ChunkDesc.SetHeight(x, z, Height + 1); } break; } @@ -252,22 +228,14 @@ void cFinishGenSnow::GenFinish( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenIce: -void cFinishGenIce::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) +void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) { // Turn surface water into ice in icy biomes for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) { - switch (cChunkDef::GetBiome(a_BiomeMap, x, z)) + switch (a_ChunkDesc.GetBiome(x, z)) { case biIcePlains: case biIceMountains: @@ -276,13 +244,13 @@ void cFinishGenIce::GenFinish( case biFrozenRiver: case biFrozenOcean: { - int Height = cChunkDef::GetHeight(a_HeightMap, x, z); - switch (cChunkDef::GetBlock(a_BlockTypes, x, Height, z)) + int Height = a_ChunkDesc.GetHeight(x, z); + switch (a_ChunkDesc.GetBlockType(x, Height, z)) { case E_BLOCK_WATER: case E_BLOCK_STATIONARY_WATER: { - cChunkDef::SetBlock(a_BlockTypes, x, Height, z, E_BLOCK_ICE); + a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_ICE); break; } } @@ -300,68 +268,58 @@ void cFinishGenIce::GenFinish( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenLilypads: -int cFinishGenLilypads::GetNumLilypads(const cChunkDef::BiomeMap & a_BiomeMap) +int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) { int res = 0; for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { - if (a_BiomeMap[i] == biSwampland) + if (a_BiomeMap[i] == m_Biome) { res++; } } // for i - a_BiomeMap[] - return res / 64; + return m_Amount * res / 256; } -void cFinishGenLilypads::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) +void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) { // Add Lilypads on top of water surface in Swampland - int NumLilypads = GetNumLilypads(a_BiomeMap); - for (int i = 0; i < NumLilypads; i++) + int NumToGen = GetNumToGen(a_ChunkDesc.GetBiomeMap()); + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); + for (int i = 0; i < NumToGen; i++) { - int x = (m_Noise.IntNoise3DInt(a_ChunkX + a_ChunkZ, a_ChunkZ, i) / 13) % cChunkDef::Width; - int z = (m_Noise.IntNoise3DInt(a_ChunkX - a_ChunkZ, i, a_ChunkZ) / 11) % cChunkDef::Width; + int x = (m_Noise.IntNoise3DInt(ChunkX + ChunkZ, ChunkZ, i) / 13) % cChunkDef::Width; + int z = (m_Noise.IntNoise3DInt(ChunkX - ChunkZ, i, ChunkZ) / 11) % cChunkDef::Width; - // Place a lily pad at {x, z} if possible (swampland, empty block, water below): - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biSwampland) + // Place the block at {x, z} if possible: + if (a_ChunkDesc.GetBiome(x, z) != m_Biome) { - // not swampland + // Incorrect biome continue; } - int Height = cChunkDef::GetHeight(a_HeightMap, x, z); + int Height = a_ChunkDesc.GetHeight(x, z); if (Height >= cChunkDef::Height) { // Too high up continue; } - if (cChunkDef::GetBlock(a_BlockTypes, x, Height + 1, z) != E_BLOCK_AIR) + if (a_ChunkDesc.GetBlockType(x, Height + 1, z) != E_BLOCK_AIR) { - // not empty block + // Not an empty block continue; } - switch (cChunkDef::GetBlock(a_BlockTypes, x, Height, z)) + BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, Height, z); + if ((BlockBelow == m_AllowedBelow1) || (BlockBelow == m_AllowedBelow2)) { - case E_BLOCK_WATER: - case E_BLOCK_STATIONARY_WATER: - { - cChunkDef::SetBlock(a_BlockTypes, x, Height + 1, z, E_BLOCK_LILY_PAD); - cChunkDef::SetHeight(a_HeightMap, x, z, Height + 1); - break; - } - } // switch (GetBlock) + a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType); + a_ChunkDesc.SetHeight(x, z, Height + 1); + } } // for i } @@ -372,24 +330,17 @@ void cFinishGenLilypads::GenFinish( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenBottomLava: -void cFinishGenBottomLava::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) +void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc) { + cChunkDef::BlockTypes & BlockTypes = a_ChunkDesc.GetBlockTypes(); for (int y = m_Level; y > 0; y--) { for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++) { int Index = cChunkDef::MakeIndexNoCheck(x, y, z); - if (a_BlockTypes[Index] == E_BLOCK_AIR) + if (BlockTypes[Index] == E_BLOCK_AIR) { - a_BlockTypes[Index] = E_BLOCK_STATIONARY_LAVA; + BlockTypes[Index] = E_BLOCK_STATIONARY_LAVA; } } // for x, for z } // for y @@ -411,19 +362,11 @@ cFinishGenPreSimulator::cFinishGenPreSimulator(void) -void cFinishGenPreSimulator::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) +void cFinishGenPreSimulator::GenFinish(cChunkDesc & a_ChunkDesc) { - CollapseSandGravel(a_BlockTypes, a_HeightMap); - StationarizeFluid(a_BlockTypes, a_HeightMap, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER); - StationarizeFluid(a_BlockTypes, a_HeightMap, E_BLOCK_LAVA, E_BLOCK_STATIONARY_LAVA); + CollapseSandGravel(a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap()); + StationarizeFluid(a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap(), E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER); + StationarizeFluid(a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap(), E_BLOCK_LAVA, E_BLOCK_STATIONARY_LAVA); // TODO: other operations } @@ -575,77 +518,6 @@ void cFinishGenPreSimulator::StationarizeFluid( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cFinishGenDeadBushes: - -int cFinishGenDeadBushes::GetNumDeadBushes(const cChunkDef::BiomeMap & a_BiomeMap) -{ - int res = 0; - for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) - { - if (a_BiomeMap[i] == biDesert) - { - res++; - } - } // for i - a_BiomeMap[] - return res / 128; -} - - - - - -void cFinishGenDeadBushes::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) -{ - // Add DeadBushes on top of sand surface in Desert - - int NumDeadBushes = GetNumDeadBushes(a_BiomeMap); - for (int i = 0; i < NumDeadBushes; i++) - { - int x = (m_Noise.IntNoise3DInt(a_ChunkX + a_ChunkZ, a_ChunkZ, i) / 13) % cChunkDef::Width; - int z = (m_Noise.IntNoise3DInt(a_ChunkX - a_ChunkZ, i, a_ChunkZ) / 11) % cChunkDef::Width; - - // Place a dead bush at {x, z} if possible (desert, empty block, sand below): - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biDesert) - { - // not swampland - continue; - } - int Height = cChunkDef::GetHeight(a_HeightMap, x, z); - if (Height >= cChunkDef::Height) - { - // Too high up - continue; - } - if (cChunkDef::GetBlock(a_BlockTypes, x, Height + 1, z) != E_BLOCK_AIR) - { - // not empty block - continue; - } - switch (cChunkDef::GetBlock(a_BlockTypes, x, Height, z)) - { - case E_BLOCK_SAND: - { - cChunkDef::SetBlock(a_BlockTypes, x, Height + 1, z, E_BLOCK_DEAD_BUSH); - cChunkDef::SetHeight(a_HeightMap, x, z, Height + 1); - break; - } - } // switch (GetBlock) - } // for i -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenFluidSprings: cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, const cWorld & a_World) : @@ -699,17 +571,9 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI -void cFinishGenFluidSprings::GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) +void cFinishGenFluidSprings::GenFinish(cChunkDesc & a_ChunkDesc) { - int ChanceRnd = (m_Noise.IntNoise3DInt(128 * a_ChunkX, 512, 256 * a_ChunkZ) / 13) % 100; + int ChanceRnd = (m_Noise.IntNoise3DInt(128 * a_ChunkDesc.GetChunkX(), 512, 256 * a_ChunkDesc.GetChunkZ()) / 13) % 100; if (ChanceRnd > m_Chance) { // Not in this chunk @@ -717,7 +581,7 @@ void cFinishGenFluidSprings::GenFinish( } // Get the height at which to try: - int Height = m_Noise.IntNoise3DInt(128 * a_ChunkX, 512, 256 * a_ChunkZ) / 11; + int Height = m_Noise.IntNoise3DInt(128 * a_ChunkDesc.GetChunkX(), 1024, 256 * a_ChunkDesc.GetChunkZ()) / 11; Height %= m_HeightDistribution.GetSum(); Height = m_HeightDistribution.MapValue(Height); @@ -729,20 +593,12 @@ void cFinishGenFluidSprings::GenFinish( { for (int x = 1; x < cChunkDef::Width - 1; x++) { - switch (cChunkDef::GetBlock(a_BlockTypes, x, y, z)) + switch (a_ChunkDesc.GetBlockType(x, y, z)) { case E_BLOCK_NETHERRACK: - { - if (m_Fluid != E_BLOCK_LAVA) - { - // Only lava springs in the netherrack - continue; - } - // fallthrough: - } case E_BLOCK_STONE: { - if (TryPlaceSpring(a_BlockTypes, a_BlockMeta, x, y, z)) + if (TryPlaceSpring(a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetBlockMetas(), x, y, z)) { // Succeeded, bail out return; diff --git a/source/Generating/FinishGen.h b/source/Generating/FinishGen.h index dde073f67..b4bf67022 100644 --- a/source/Generating/FinishGen.h +++ b/source/Generating/FinishGen.h @@ -28,15 +28,7 @@ class cFinishGenSnow : { protected: // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; @@ -48,15 +40,7 @@ class cFinishGenIce : { protected: // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; @@ -67,59 +51,57 @@ class cFinishGenSprinkleFoliage : public cFinishGen { public: - cFinishGenSprinkleFoliage(int a_Seed) : m_Seed(a_Seed) {} + cFinishGenSprinkleFoliage(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} protected: - int m_Seed; + cNoise m_Noise; + int m_Seed; /// Tries to place sugarcane at the coords specified, returns true if successful - bool TryAddSugarcane( - int a_ChunkX, int a_ChunkZ, - int a_RelX, int a_RelY, int a_RelZ, // relative block coords of the sugarcane's base - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta // Block meta to read and change - ); + bool TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ); // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; -class cFinishGenLilypads : +/** This class adds a single top block in random positions in the specified biome on top of specified allowed blocks. +Used for: +- Lilypads finisher +- DeadBushes finisher +*/ +class cFinishGenSingleBiomeSingleTopBlock : public cFinishGen { public: - cFinishGenLilypads(int a_Seed) : - m_Noise(a_Seed) + cFinishGenSingleBiomeSingleTopBlock( + int a_Seed, BLOCKTYPE a_BlockType, EMCSBiome a_Biome, int a_Amount, + BLOCKTYPE a_AllowedBelow1, BLOCKTYPE a_AllowedBelow2 + ) : + m_Noise(a_Seed), + m_BlockType(a_BlockType), + m_Biome(a_Biome), + m_Amount(a_Amount), + m_AllowedBelow1(a_AllowedBelow1), + m_AllowedBelow2(a_AllowedBelow2) { } protected: cNoise m_Noise; + BLOCKTYPE m_BlockType; + EMCSBiome m_Biome; + int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns. + BLOCKTYPE m_AllowedBelow1; ///< First of the two blocktypes that are allowed below m_BlockType + BLOCKTYPE m_AllowedBelow2; ///< Second of the two blocktypes that are allowed below m_BlockType - int GetNumLilypads(const cChunkDef::BiomeMap & a_BiomeMap); + int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap); // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; @@ -139,15 +121,7 @@ protected: int m_Level; // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; @@ -179,52 +153,13 @@ protected: ); // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; -} ; - - - - - -class cFinishGenDeadBushes : - public cFinishGen -{ -public: - cFinishGenDeadBushes(int a_Seed) : - m_Noise(a_Seed) - { - } - -protected: - cNoise m_Noise; - - int GetNumDeadBushes(const cChunkDef::BiomeMap & a_BiomeMap); - - // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; - class cFinishGenFluidSprings : public cFinishGen { @@ -239,15 +174,7 @@ protected: int m_Chance; ///< Chance, [0..100], that a spring will be generated in a chunk // cFinishGen override: - virtual void GenFinish( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful bool TryPlaceSpring( diff --git a/source/Generating/Ravines.cpp b/source/Generating/Ravines.cpp index af53259bc..94d91c0bb 100644 --- a/source/Generating/Ravines.cpp +++ b/source/Generating/Ravines.cpp @@ -117,20 +117,15 @@ void cStructGenRavines::ClearCache(void) -void cStructGenRavines::GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
-)
+void cStructGenRavines::GenStructures(cChunkDesc & a_ChunkDesc)
{
+ int ChunkX = a_ChunkDesc.GetChunkX();
+ int ChunkZ = a_ChunkDesc.GetChunkZ();
cRavines Ravines;
- GetRavinesForChunk(a_ChunkX, a_ChunkZ, Ravines);
- for (cRavines::const_iterator itr = Ravines.begin(); itr != Ravines.end(); ++itr)
+ GetRavinesForChunk(ChunkX, ChunkZ, Ravines);
+ for (cRavines::const_iterator itr = Ravines.begin(), end = Ravines.end(); itr != end; ++itr)
{
- (*itr)->ProcessChunk(a_ChunkX, a_ChunkZ, a_BlockTypes, a_HeightMap);
+ (*itr)->ProcessChunk(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap());
} // for itr - Ravines[]
}
diff --git a/source/Generating/Ravines.h b/source/Generating/Ravines.h index 79db697d0..1c559c70d 100644 --- a/source/Generating/Ravines.h +++ b/source/Generating/Ravines.h @@ -38,14 +38,7 @@ protected: void GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cRavines & a_Ravines);
// cStructureGen override:
- virtual void GenStructures(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
- cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
- cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
- cEntityList & a_Entities, // Entities may be added or deleted
- cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
- ) override;
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index b0828f15a..6d139da2a 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -70,68 +70,62 @@ static bool SortTreeBlocks(const sSetBlock & a_First, const sSetBlock & a_Second /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenTrees: -void cStructGenTrees::GenStructures( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMetas, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) +void cStructGenTrees::GenStructures(cChunkDesc & a_ChunkDesc) { - cChunkDef::BlockTypes WorkerBlockTypes; - cChunkDef::BlockNibbles WorkerBlockMeta; - cChunkDef::HeightMap WorkerHeight; - - cEntityList Entities; - cBlockEntityList BlockEntities; + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); + + cChunkDesc WorkerDesc(ChunkX, ChunkZ); // Generate trees: for (int x = 0; x <= 2; x++) { - int BaseX = a_ChunkX + x - 1; + int BaseX = ChunkX + x - 1; for (int z = 0; z <= 2; z++) { - int BaseZ = a_ChunkZ + z - 1; + int BaseZ = ChunkZ + z - 1; cChunkDef::BlockTypes * BlT; cChunkDef::BlockNibbles * BlM; cChunkDef::HeightMap * Hei; - - cChunkDef::BiomeMap Biomes; - m_BiomeGen->GenBiomes(BaseX, BaseZ, Biomes); + cChunkDef::BiomeMap * Bio; + if ((x != 1) || (z != 1)) { - BlT = &WorkerBlockTypes; - BlM = &WorkerBlockMeta; - Hei = &WorkerHeight; + BlT = &(WorkerDesc.GetBlockTypes()); + BlM = &(WorkerDesc.GetBlockMetas()); + Hei = &(WorkerDesc.GetHeightMap()); + Bio = &(WorkerDesc.GetBiomeMap()); + WorkerDesc.SetChunkCoords(BaseX, BaseZ); - m_HeightGen->GenHeightMap (BaseX, BaseZ, *Hei); - m_CompositionGen->ComposeTerrain(BaseX, BaseZ, *BlT, *BlM, *Hei, Biomes, Entities, BlockEntities); + m_BiomeGen->GenBiomes (BaseX, BaseZ, WorkerDesc.GetBiomeMap()); + m_HeightGen->GenHeightMap (BaseX, BaseZ, WorkerDesc.GetHeightMap()); + m_CompositionGen->ComposeTerrain(WorkerDesc); // TODO: Free the entity lists } else { - BlT = &a_BlockTypes; - BlM = &a_BlockMetas; - Hei = &a_HeightMap; + BlT = &(a_ChunkDesc.GetBlockTypes()); + BlM = &(a_ChunkDesc.GetBlockMetas()); + Hei = &(a_ChunkDesc.GetHeightMap()); + Bio = &(a_ChunkDesc.GetBiomeMap()); } - int NumTrees = GetNumTrees(BaseX, BaseZ, Biomes); + int NumTrees = GetNumTrees(BaseX, BaseZ, *Bio); sSetBlockVector OutsideLogs, OutsideOther; for (int i = 0; i < NumTrees; i++) { - GenerateSingleTree(BaseX, BaseZ, i, *BlT, *BlM, *Hei, Biomes, OutsideLogs, OutsideOther); + GenerateSingleTree(BaseX, BaseZ, i, *BlT, *BlM, *Hei, *Bio, OutsideLogs, OutsideOther); } sSetBlockVector IgnoredOverflow; IgnoredOverflow.reserve(OutsideOther.size()); - ApplyTreeImage(a_ChunkX, a_ChunkZ, a_BlockTypes, a_BlockMetas, OutsideOther, IgnoredOverflow); + ApplyTreeImage(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetBlockMetas(), OutsideOther, IgnoredOverflow); IgnoredOverflow.clear(); IgnoredOverflow.reserve(OutsideLogs.size()); - ApplyTreeImage(a_ChunkX, a_ChunkZ, a_BlockTypes, a_BlockMetas, OutsideLogs, IgnoredOverflow); + ApplyTreeImage(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetBlockMetas(), OutsideLogs, IgnoredOverflow); } // for z } // for x @@ -142,9 +136,9 @@ void cStructGenTrees::GenStructures( { for (int y = cChunkDef::Height - 1; y >= 0; y--) { - if (cChunkDef::GetBlock(a_BlockTypes, x, y, z) != E_BLOCK_AIR) + if (cChunkDef::GetBlock(a_ChunkDesc.GetBlockTypes(), x, y, z) != E_BLOCK_AIR) { - cChunkDef::SetHeight(a_HeightMap, x, z, y); + cChunkDef::SetHeight(a_ChunkDesc.GetHeightMap(), x, z, y); break; } } // for y @@ -306,23 +300,19 @@ int cStructGenTrees::GetNumTrees( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenOreNests: -void cStructGenOreNests::GenStructures( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted -) +void cStructGenOreNests::GenStructures(cChunkDesc & a_ChunkDesc) { - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_COAL_ORE, MAX_HEIGHT_COAL, NUM_NESTS_COAL, NEST_SIZE_COAL, a_BlockTypes, 1); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_IRON_ORE, MAX_HEIGHT_IRON, NUM_NESTS_IRON, NEST_SIZE_IRON, a_BlockTypes, 2); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_REDSTONE_ORE, MAX_HEIGHT_REDSTONE, NUM_NESTS_REDSTONE, NEST_SIZE_REDSTONE, a_BlockTypes, 3); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_GOLD_ORE, MAX_HEIGHT_GOLD, NUM_NESTS_GOLD, NEST_SIZE_GOLD, a_BlockTypes, 4); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_DIAMOND_ORE, MAX_HEIGHT_DIAMOND, NUM_NESTS_DIAMOND, NEST_SIZE_DIAMOND, a_BlockTypes, 5); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_LAPIS_ORE, MAX_HEIGHT_LAPIS, NUM_NESTS_LAPIS, NEST_SIZE_LAPIS, a_BlockTypes, 6); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_DIRT, MAX_HEIGHT_DIRT, NUM_NESTS_DIRT, NEST_SIZE_DIRT, a_BlockTypes, 10); - GenerateOre(a_ChunkX, a_ChunkZ, E_BLOCK_GRAVEL, MAX_HEIGHT_GRAVEL, NUM_NESTS_GRAVEL, NEST_SIZE_GRAVEL, a_BlockTypes, 11); + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); + cChunkDef::BlockTypes & BlockTypes = a_ChunkDesc.GetBlockTypes(); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_COAL_ORE, MAX_HEIGHT_COAL, NUM_NESTS_COAL, NEST_SIZE_COAL, BlockTypes, 1); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_IRON_ORE, MAX_HEIGHT_IRON, NUM_NESTS_IRON, NEST_SIZE_IRON, BlockTypes, 2); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_REDSTONE_ORE, MAX_HEIGHT_REDSTONE, NUM_NESTS_REDSTONE, NEST_SIZE_REDSTONE, BlockTypes, 3); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_GOLD_ORE, MAX_HEIGHT_GOLD, NUM_NESTS_GOLD, NEST_SIZE_GOLD, BlockTypes, 4); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_DIAMOND_ORE, MAX_HEIGHT_DIAMOND, NUM_NESTS_DIAMOND, NEST_SIZE_DIAMOND, BlockTypes, 5); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_LAPIS_ORE, MAX_HEIGHT_LAPIS, NUM_NESTS_LAPIS, NEST_SIZE_LAPIS, BlockTypes, 6); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_DIRT, MAX_HEIGHT_DIRT, NUM_NESTS_DIRT, NEST_SIZE_DIRT, BlockTypes, 10); + GenerateOre(ChunkX, ChunkZ, E_BLOCK_GRAVEL, MAX_HEIGHT_GRAVEL, NUM_NESTS_GRAVEL, NEST_SIZE_GRAVEL, BlockTypes, 11); } diff --git a/source/Generating/StructGen.h b/source/Generating/StructGen.h index 1b2941649..c627499e2 100644 --- a/source/Generating/StructGen.h +++ b/source/Generating/StructGen.h @@ -69,14 +69,7 @@ protected: ); // cStructureGen override: - virtual void GenStructures( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMetas, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenStructures(cChunkDesc & a_ChunkDesc) override; } ; @@ -94,14 +87,7 @@ protected: int m_Seed; // cStructureGen override: - virtual void GenStructures( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change - cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change - cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data - cEntityList & a_Entities, // Entities may be added or deleted - cBlockEntityList & a_BlockEntities // Block entities may be added or deleted - ) override; + virtual void GenStructures(cChunkDesc & a_ChunkDesc) override; void GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_OreType, int a_MaxHeight, int a_NumNests, int a_NestSize, cChunkDef::BlockTypes & a_BlockTypes, int a_Seq); } ; @@ -110,3 +96,22 @@ protected: +class cStructGenLakes : + public cStructureGen +{ +public: + cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid) : m_Noise(a_Seed), m_Seed(a_Seed), m_Fluid(a_Fluid) {} + +protected: + cNoise m_Noise; + int m_Seed; + BLOCKTYPE m_Fluid; + + // cStructureGen override: + virtual void GenStructures(cChunkDesc & a_ChunkDesc) override; +} ; + + + + + |