Added DeadBushes finisher (initial patch by STR_Warrior; DeathBushes FTW!)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1037 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
934d3fe565
commit
e8e678e1b7
@ -340,18 +340,20 @@ void cChunkGenerator::InitStructureGens(cIniFile & a_IniFile)
|
|||||||
|
|
||||||
void cChunkGenerator::InitFinishGens(cIniFile & a_IniFile)
|
void cChunkGenerator::InitFinishGens(cIniFile & a_IniFile)
|
||||||
{
|
{
|
||||||
AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava");
|
AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
|
||||||
|
|
||||||
AStringVector Str = StringSplit(Structures, ",");
|
AStringVector Str = StringSplit(Structures, ",");
|
||||||
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
|
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (NoCaseCompare(*itr, "SprinkleFoliage") == 0)
|
// Finishers, alpha-sorted:
|
||||||
|
if (NoCaseCompare(*itr, "BottomLava") == 0)
|
||||||
{
|
{
|
||||||
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(m_Seed));
|
int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", 10);
|
||||||
|
m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
|
||||||
}
|
}
|
||||||
else if (NoCaseCompare(*itr, "Snow") == 0)
|
else if (NoCaseCompare(*itr, "DeadBushes") == 0)
|
||||||
{
|
{
|
||||||
m_FinishGens.push_back(new cFinishGenSnow);
|
m_FinishGens.push_back(new cFinishGenDeadBushes(m_Seed));
|
||||||
}
|
}
|
||||||
else if (NoCaseCompare(*itr, "Ice") == 0)
|
else if (NoCaseCompare(*itr, "Ice") == 0)
|
||||||
{
|
{
|
||||||
@ -361,15 +363,18 @@ void cChunkGenerator::InitFinishGens(cIniFile & a_IniFile)
|
|||||||
{
|
{
|
||||||
m_FinishGens.push_back(new cFinishGenLilypads(m_Seed));
|
m_FinishGens.push_back(new cFinishGenLilypads(m_Seed));
|
||||||
}
|
}
|
||||||
else if (NoCaseCompare(*itr, "BottomLava") == 0)
|
|
||||||
{
|
|
||||||
int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", 10);
|
|
||||||
m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
|
|
||||||
}
|
|
||||||
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
|
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
|
||||||
{
|
{
|
||||||
m_FinishGens.push_back(new cFinishGenPreSimulator);
|
m_FinishGens.push_back(new cFinishGenPreSimulator);
|
||||||
}
|
}
|
||||||
|
else if (NoCaseCompare(*itr, "Snow") == 0)
|
||||||
|
{
|
||||||
|
m_FinishGens.push_back(new cFinishGenSnow);
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(*itr, "SprinkleFoliage") == 0)
|
||||||
|
{
|
||||||
|
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(m_Seed));
|
||||||
|
}
|
||||||
} // for itr - Str[]
|
} // for itr - Str[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,12 +307,12 @@ int cFinishGenLilypads::GetNumLilypads(const cChunkDef::BiomeMap & a_BiomeMap)
|
|||||||
|
|
||||||
void cFinishGenLilypads::GenFinish(
|
void cFinishGenLilypads::GenFinish(
|
||||||
int a_ChunkX, int a_ChunkZ,
|
int a_ChunkX, int a_ChunkZ,
|
||||||
cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
|
cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
|
||||||
cChunkDef::BlockNibbles & a_BlockMeta, // Block meta 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
|
cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
|
||||||
const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to
|
const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to
|
||||||
cEntityList & a_Entities, // Entities may be added or deleted
|
cEntityList & a_Entities, // Entities may be added or deleted
|
||||||
cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
|
cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Add Lilypads on top of water surface in Swampland
|
// Add Lilypads on top of water surface in Swampland
|
||||||
@ -320,8 +320,8 @@ void cFinishGenLilypads::GenFinish(
|
|||||||
int NumLilypads = GetNumLilypads(a_BiomeMap);
|
int NumLilypads = GetNumLilypads(a_BiomeMap);
|
||||||
for (int i = 0; i < NumLilypads; i++)
|
for (int i = 0; i < NumLilypads; i++)
|
||||||
{
|
{
|
||||||
int x = m_Noise.IntNoise3DInt(a_ChunkX + a_ChunkZ, a_ChunkZ, i) % cChunkDef::Width;
|
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) % cChunkDef::Width;
|
int z = (m_Noise.IntNoise3DInt(a_ChunkX - a_ChunkZ, i, a_ChunkZ) / 11) % cChunkDef::Width;
|
||||||
|
|
||||||
// Place a lily pad at {x, z} if possible (swampland, empty block, water below):
|
// Place a lily pad at {x, z} if possible (swampland, empty block, water below):
|
||||||
if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biSwampland)
|
if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biSwampland)
|
||||||
@ -545,3 +545,71 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
- cFinishGenSprinkleFoliage
|
- cFinishGenSprinkleFoliage
|
||||||
- cFinishGenLilypads
|
- cFinishGenLilypads
|
||||||
- cFinishGenBottomLava
|
- cFinishGenBottomLava
|
||||||
|
- cFinishGenPreSimulator
|
||||||
|
- cFinishGenDeadBushes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cFinishGenSprinkleFoliage :
|
class cFinishGenSprinkleFoliage :
|
||||||
public cFinishGen
|
public cFinishGen
|
||||||
{
|
{
|
||||||
@ -150,7 +153,6 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cFinishGenPreSimulator :
|
class cFinishGenPreSimulator :
|
||||||
public cFinishGen
|
public cFinishGen
|
||||||
{
|
{
|
||||||
@ -190,3 +192,34 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user