summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/.gitignore1
-rw-r--r--src/Blocks/BlockSlab.h33
-rw-r--r--src/ClientHandle.cpp2
-rw-r--r--src/Generating/Caves.cpp6
-rw-r--r--src/Generating/Caves.h16
-rw-r--r--src/Generating/ChunkDesc.cpp2
-rw-r--r--src/Generating/ComposableGenerator.cpp157
-rw-r--r--src/Generating/ComposableGenerator.h56
-rw-r--r--src/Generating/MineShafts.cpp2
-rw-r--r--src/Generating/MineShafts.h6
-rw-r--r--src/Generating/Ravines.cpp2
-rw-r--r--src/Generating/Ravines.h6
-rw-r--r--src/Generating/StructGen.cpp10
-rw-r--r--src/Generating/StructGen.h30
-rw-r--r--src/Mobs/Creeper.cpp41
-rw-r--r--src/Mobs/Creeper.h3
-rw-r--r--src/Simulator/FireSimulator.cpp13
-rw-r--r--src/WorldStorage/FastNBT.h48
18 files changed, 245 insertions, 189 deletions
diff --git a/MCServer/Plugins/.gitignore b/MCServer/Plugins/.gitignore
index 89eab800a..8553945b5 100644
--- a/MCServer/Plugins/.gitignore
+++ b/MCServer/Plugins/.gitignore
@@ -1,2 +1,3 @@
*.txt
*.md
+*/
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index 3628303ce..7cd2c97b2 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -28,7 +28,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
+ a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta & 0x7));
}
@@ -41,7 +41,7 @@ public:
{
a_BlockType = m_BlockType;
BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType);
- NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07);
+ NIBBLETYPE Meta = (NIBBLETYPE) a_Player->GetEquippedItem().m_ItemDamage;
// HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type));
@@ -159,21 +159,30 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- if (m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB)
- {
- m_BlockType = E_BLOCK_STONE_SLAB;
- }
- else
+ BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
+ a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7));
+ }
+
+ inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType)
+ {
+ switch (a_BlockType)
{
- m_BlockType = E_BLOCK_WOODEN_SLAB;
+ case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB;
+ case E_BLOCK_DOUBLE_WOODEN_SLAB: return E_BLOCK_WOODEN_SLAB;
}
- a_Pickups.push_back(cItem(m_BlockType, 2, a_BlockMeta));
+ ASSERT(!"Unhandled double slab type!");
+ return a_BlockType;
}
-
virtual const char * GetStepSound(void) override
- {
- return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
+ {
+ switch (m_BlockType)
+ {
+ case E_BLOCK_DOUBLE_STONE_SLAB: return "step.stone";
+ case E_BLOCK_DOUBLE_WOODEN_SLAB: return "step.wood";
+ }
+ ASSERT(!"Unhandled double slab type!");
+ return "";
}
} ;
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 60f14af54..07a8984c5 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1043,7 +1043,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
if (
cBlockSlabHandler::IsAnySlabType(ClickedBlock) && // Is there a slab already?
cBlockSlabHandler::IsAnySlabType(EquippedBlock) && // Is the player placing another slab?
- ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) && // Is it the same slab type?
+ ((ClickedBlockMeta & 0x07) == EquippedBlockDamage) && // Is it the same slab type?
(
(a_BlockFace == BLOCK_FACE_TOP) || // Clicking the top of a bottom slab
(a_BlockFace == BLOCK_FACE_BOTTOM) // Clicking the bottom of a top slab
diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp
index 2571e6b77..98b7c8681 100644
--- a/src/Generating/Caves.cpp
+++ b/src/Generating/Caves.cpp
@@ -762,7 +762,7 @@ void cStructGenWormNestCaves::ClearCache(void)
-void cStructGenWormNestCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenWormNestCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -902,7 +902,7 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise )
-void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
cNoise Noise(m_Seed);
for (int z = 0; z < cChunkDef::Width; z++)
@@ -938,7 +938,7 @@ void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenDualRidgeCaves:
-void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h
index ea7f10bf4..7c45c056b 100644
--- a/src/Generating/Caves.h
+++ b/src/Generating/Caves.h
@@ -20,7 +20,7 @@
class cStructGenMarbleCaves :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenMarbleCaves(int a_Seed) : m_Seed(a_Seed) {}
@@ -29,8 +29,8 @@ protected:
int m_Seed;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -38,7 +38,7 @@ protected:
class cStructGenDualRidgeCaves :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenDualRidgeCaves(int a_Seed, float a_Threshold) :
@@ -55,8 +55,8 @@ protected:
int m_Seed;
float m_Threshold;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -64,7 +64,7 @@ protected:
class cStructGenWormNestCaves :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) :
@@ -94,7 +94,7 @@ protected:
void GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cCaveSystems & a_Caves);
// cStructGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index d9529b4b0..308fbe423 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -209,6 +209,7 @@ bool cChunkDesc::IsUsingDefaultComposition(void) const
void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
{
+ LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__);
m_bUseDefaultStructures = a_bUseDefaultStructures;
}
@@ -218,6 +219,7 @@ void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
bool cChunkDesc::IsUsingDefaultStructures(void) const
{
+ LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__);
return m_bUseDefaultStructures;
}
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index cfa7e9c6f..e96e9a645 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -133,11 +133,6 @@ cComposableGenerator::~cComposableGenerator()
delete *itr;
}
m_FinishGens.clear();
- for (cStructureGenList::const_iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
- {
- delete *itr;
- }
- m_StructureGens.clear();
delete m_CompositionGen;
m_CompositionGen = NULL;
@@ -164,7 +159,6 @@ void cComposableGenerator::Initialize(cIniFile & a_IniFile)
InitBiomeGen(a_IniFile);
InitHeightGen(a_IniFile);
InitCompositionGen(a_IniFile);
- InitStructureGens(a_IniFile);
InitFinishGens(a_IniFile);
}
@@ -201,14 +195,6 @@ void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a
m_CompositionGen->ComposeTerrain(a_ChunkDesc);
}
- if (a_ChunkDesc.IsUsingDefaultStructures())
- {
- for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
- {
- (*itr)->GenStructures(a_ChunkDesc);
- } // for itr - m_StructureGens[]
- }
-
if (a_ChunkDesc.IsUsingDefaultFinish())
{
for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
@@ -290,35 +276,69 @@ void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
-void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
+void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
- AString Structures = a_IniFile.GetValueSet("Generator", "Structures", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees");
-
int Seed = m_ChunkGenerator.GetSeed();
- AStringVector Str = StringSplitAndTrim(Structures, ",");
+ eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
+
+ // Older configuration used "Structures" in addition to "Finishers"; we don't distinguish between the two anymore (#398)
+ // Therefore, we load Structures from the ini file for compatibility, but move its contents over to Finishers:
+ AString Structures = a_IniFile.GetValue("Generator", "Structures", "");
+ AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator");
+ if (!Structures.empty())
+ {
+ LOGINFO("[Generator].Structures is deprecated, moving the contents to [Generator].Finishers.");
+ // Structures used to generate before Finishers, so place them first:
+ Structures.append(", ");
+ Finishers = Structures + Finishers;
+ a_IniFile.SetValue("Generator", "Finishers", Finishers);
+ }
+ a_IniFile.DeleteValue("Generator", "Structures");
+
+ // Create all requested finishers:
+ AStringVector Str = StringSplitAndTrim(Finishers, ",");
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
{
- if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
+ // Finishers, alpha-sorted:
+ if (NoCaseCompare(*itr, "BottomLava") == 0)
{
- float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
- m_StructureGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
+ int DefaultBottomLavaLevel = (Dimension == dimNether) ? 30 : 10;
+ int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
+ m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
+ }
+ else if (NoCaseCompare(*itr, "DeadBushes") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
}
else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
{
- m_StructureGens.push_back(new cStructGenDirectOverhangs(Seed));
+ m_FinishGens.push_back(new cStructGenDirectOverhangs(Seed));
}
else if (NoCaseCompare(*itr, "DistortedMembraneOverhangs") == 0)
{
- m_StructureGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
+ m_FinishGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
+ }
+ else if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
+ {
+ float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
+ m_FinishGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
+ }
+ else if (NoCaseCompare(*itr, "Ice") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenIce);
}
else if (NoCaseCompare(*itr, "LavaLakes") == 0)
{
int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
- m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
+ m_FinishGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
+ }
+ else if (NoCaseCompare(*itr, "LavaSprings") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, Dimension));
}
else if (NoCaseCompare(*itr, "MarbleCaves") == 0)
{
- m_StructureGens.push_back(new cStructGenMarbleCaves(Seed));
+ m_FinishGens.push_back(new cStructGenMarbleCaves(Seed));
}
else if (NoCaseCompare(*itr, "MineShafts") == 0)
{
@@ -327,71 +347,11 @@ void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600);
int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200);
int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200);
- m_StructureGens.push_back(new cStructGenMineShafts(
+ m_FinishGens.push_back(new cStructGenMineShafts(
Seed, GridSize, MaxSystemSize,
ChanceCorridor, ChanceCrossing, ChanceStaircase
));
}
- else if (NoCaseCompare(*itr, "OreNests") == 0)
- {
- m_StructureGens.push_back(new cStructGenOreNests(Seed));
- }
- else if (NoCaseCompare(*itr, "Ravines") == 0)
- {
- m_StructureGens.push_back(new cStructGenRavines(Seed, 128));
- }
- else if (NoCaseCompare(*itr, "Trees") == 0)
- {
- m_StructureGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
- }
- else if (NoCaseCompare(*itr, "WaterLakes") == 0)
- {
- int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
- m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
- }
- else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
- {
- m_StructureGens.push_back(new cStructGenWormNestCaves(Seed));
- }
- else
- {
- LOGWARNING("Unknown structure generator: \"%s\". Ignoring.", itr->c_str());
- }
- } // for itr - Str[]
-}
-
-
-
-
-
-void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
-{
- int Seed = m_ChunkGenerator.GetSeed();
- eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
-
- AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
- AStringVector Str = StringSplitAndTrim(Finishers, ",");
- for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
- {
- // Finishers, alpha-sorted:
- if (NoCaseCompare(*itr, "BottomLava") == 0)
- {
- int DefaultBottomLavaLevel = (Dimension == dimNether) ? 30 : 10;
- int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
- m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
- }
- else if (NoCaseCompare(*itr, "DeadBushes") == 0)
- {
- 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)
- {
- m_FinishGens.push_back(new cFinishGenIce);
- }
- else if (NoCaseCompare(*itr, "LavaSprings") == 0)
- {
- m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, Dimension));
- }
else if (NoCaseCompare(*itr, "Lilypads") == 0)
{
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
@@ -400,10 +360,18 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenNetherClumpFoliage(Seed));
}
+ else if (NoCaseCompare(*itr, "OreNests") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenOreNests(Seed));
+ }
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
{
m_FinishGens.push_back(new cFinishGenPreSimulator);
}
+ else if (NoCaseCompare(*itr, "Ravines") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenRavines(Seed, 128));
+ }
else if (NoCaseCompare(*itr, "Snow") == 0)
{
m_FinishGens.push_back(new cFinishGenSnow);
@@ -412,10 +380,27 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
}
+ else if (NoCaseCompare(*itr, "Trees") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
+ }
+ else if (NoCaseCompare(*itr, "WaterLakes") == 0)
+ {
+ int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
+ m_FinishGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
+ }
else if (NoCaseCompare(*itr, "WaterSprings") == 0)
{
m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, Dimension));
}
+ else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenWormNestCaves(Seed));
+ }
+ else
+ {
+ LOGWARNING("Unknown Finisher in the [Generator] section: \"%s\". Ignoring.", itr->c_str());
+ }
} // for itr - Str[]
}
diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h
index 29add0636..6b7627d2e 100644
--- a/src/Generating/ComposableGenerator.h
+++ b/src/Generating/ComposableGenerator.h
@@ -43,16 +43,16 @@ class cBiomeGen
public:
virtual ~cBiomeGen() {} // Force a virtual destructor in descendants
- /// Generates biomes for the given chunk
+ /** Generates biomes for the given chunk */
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) = 0;
- /// Reads parameters from the ini file, prepares generator for use.
+ /** Reads parameters from the ini file, prepares generator for use. */
virtual void InitializeBiomeGen(cIniFile & a_IniFile) {}
- /// Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
- /// a_CacheOffByDefault gets set to whether the cache should be disabled by default
- /// Used in BiomeVisualiser, too.
- /// Implemented in BioGen.cpp!
+ /** Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
+ a_CacheOffByDefault gets set to whether the cache should be disabled by default.
+ Used in BiomeVisualiser, too.
+ Implemented in BioGen.cpp! */
static cBiomeGen * CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault);
} ;
@@ -72,10 +72,10 @@ class cTerrainHeightGen
public:
virtual ~cTerrainHeightGen() {} // Force a virtual destructor in descendants
- /// Generates heightmap for the given chunk
+ /** Generates heightmap for the given chunk */
virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) = 0;
- /// Reads parameters from the ini file, prepares generator for use.
+ /** Reads parameters from the ini file, prepares generator for use. */
virtual void InitializeHeightGen(cIniFile & a_IniFile) {}
/** Creates the correct TerrainHeightGen descendant based on the ini file settings and the seed provided.
@@ -102,7 +102,7 @@ public:
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) = 0;
- /// Reads parameters from the ini file, prepares generator for use.
+ /** Reads parameters from the ini file, prepares generator for use. */
virtual void InitializeCompoGen(cIniFile & a_IniFile) {}
/** Creates the correct TerrainCompositionGen descendant based on the ini file settings and the seed provided.
@@ -116,28 +116,12 @@ public:
-/** The interface that a structure generator must implement
-Structures are generated after the terrain composition took place. It should modify the blocktype data to account
-for whatever structures the generator is generating.
-Note that ores are considered structures too, at least from the interface point of view.
-Also note that a worldgenerator may contain multiple structure generators, one for each type of structure
-*/
-class cStructureGen
-{
-public:
- virtual ~cStructureGen() {} // Force a virtual destructor in descendants
-
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) = 0;
-} ;
-
-typedef std::list<cStructureGen *> cStructureGenList;
-
-
-
-
-
/** The interface that a finisher must implement
-Finisher implements small additions after all structures have been generated.
+Finisher implements changes to the chunk after the rough terrain has been generated.
+Examples of finishers are trees, snow, ore, lilypads and others.
+Note that a worldgenerator may contain multiple finishers.
+Also note that previously we used to distinguish between a structuregen and a finisher; this distinction is
+no longer relevant, all structure generators are considered finishers now (#398)
*/
class cFinishGen
{
@@ -171,7 +155,6 @@ protected:
cBiomeGen * m_BiomeGen;
cTerrainHeightGen * m_HeightGen;
cTerrainCompositionGen * m_CompositionGen;
- cStructureGenList m_StructureGens;
cFinishGenList m_FinishGens;
// Generators underlying the caches:
@@ -180,19 +163,16 @@ protected:
cTerrainCompositionGen * m_UnderlyingCompositionGen;
- /// Reads the biome gen settings from the ini and initializes m_BiomeGen accordingly
+ /** Reads the biome gen settings from the ini and initializes m_BiomeGen accordingly */
void InitBiomeGen(cIniFile & a_IniFile);
- /// Reads the HeightGen settings from the ini and initializes m_HeightGen accordingly
+ /** Reads the HeightGen settings from the ini and initializes m_HeightGen accordingly */
void InitHeightGen(cIniFile & a_IniFile);
- /// Reads the CompositionGen settings from the ini and initializes m_CompositionGen accordingly
+ /** Reads the CompositionGen settings from the ini and initializes m_CompositionGen accordingly */
void InitCompositionGen(cIniFile & a_IniFile);
- /// Reads the structures to generate from the ini and initializes m_StructureGens accordingly
- void InitStructureGens(cIniFile & a_IniFile);
-
- /// Reads the finishers from the ini and initializes m_FinishGens accordingly
+ /** Reads the finishers from the ini and initializes m_FinishGens accordingly */
void InitFinishGens(cIniFile & a_IniFile);
} ;
diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp
index cc39cef7b..d9acc57bb 100644
--- a/src/Generating/MineShafts.cpp
+++ b/src/Generating/MineShafts.cpp
@@ -1407,7 +1407,7 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk(
-void cStructGenMineShafts::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenMineShafts::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h
index c53d3bc53..ba32e75ad 100644
--- a/src/Generating/MineShafts.h
+++ b/src/Generating/MineShafts.h
@@ -17,7 +17,7 @@
class cStructGenMineShafts :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenMineShafts(
@@ -52,8 +52,8 @@ protected:
*/
void GetMineShaftSystemsForChunk(int a_ChunkX, int a_ChunkZ, cMineShaftSystems & a_MineShaftSystems);
- // cStructureGen overrides:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen overrides:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp
index cfda47e32..e64f55214 100644
--- a/src/Generating/Ravines.cpp
+++ b/src/Generating/Ravines.cpp
@@ -117,7 +117,7 @@ void cStructGenRavines::ClearCache(void)
-void cStructGenRavines::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenRavines::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h
index 05164a5b2..c76b9f19f 100644
--- a/src/Generating/Ravines.h
+++ b/src/Generating/Ravines.h
@@ -17,7 +17,7 @@
class cStructGenRavines :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenRavines(int a_Seed, int a_Size);
@@ -37,8 +37,8 @@ protected:
/// Returns all ravines that *may* intersect the given chunk. All the ravines are valid until the next call to this function.
void GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cRavines & a_Ravines);
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp
index 47945cc2b..3cc8a09c3 100644
--- a/src/Generating/StructGen.cpp
+++ b/src/Generating/StructGen.cpp
@@ -54,7 +54,7 @@ const int NEST_SIZE_GRAVEL = 32;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenTrees:
-void cStructGenTrees::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenTrees::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -306,7 +306,7 @@ int cStructGenTrees::GetNumTrees(
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenOreNests:
-void cStructGenOreNests::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -413,7 +413,7 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenLakes:
-void cStructGenLakes::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenLakes::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -545,7 +545,7 @@ cStructGenDirectOverhangs::cStructGenDirectOverhangs(int a_Seed) :
-void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
{
// If there is no column of the wanted biome, bail out:
if (!HasWantedBiome(a_ChunkDesc))
@@ -665,7 +665,7 @@ cStructGenDistortedMembraneOverhangs::cStructGenDistortedMembraneOverhangs(int a
-void cStructGenDistortedMembraneOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenDistortedMembraneOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
{
const NOISE_DATATYPE Frequency = (NOISE_DATATYPE)16;
const NOISE_DATATYPE Amount = (NOISE_DATATYPE)1;
diff --git a/src/Generating/StructGen.h b/src/Generating/StructGen.h
index 853748bb8..9176bc192 100644
--- a/src/Generating/StructGen.h
+++ b/src/Generating/StructGen.h
@@ -21,7 +21,7 @@
class cStructGenTrees :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenTrees(int a_Seed, cBiomeGen * a_BiomeGen, cTerrainHeightGen * a_HeightGen, cTerrainCompositionGen * a_CompositionGen) :
@@ -64,8 +64,8 @@ protected:
const cChunkDef::BiomeMap & a_Biomes
);
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -73,7 +73,7 @@ protected:
class cStructGenOreNests :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenOreNests(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {}
@@ -82,8 +82,8 @@ protected:
cNoise m_Noise;
int m_Seed;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(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);
} ;
@@ -93,7 +93,7 @@ protected:
class cStructGenLakes :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid, cTerrainHeightGen & a_HeiGen, int a_Probability) :
@@ -112,8 +112,8 @@ protected:
cTerrainHeightGen & m_HeiGen;
int m_Probability; ///< Chance, 0 .. 100, of a chunk having the lake
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
/// Creates a lake image for the specified chunk into a_Lake
void CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a_Lake);
@@ -125,7 +125,7 @@ protected:
class cStructGenDirectOverhangs :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenDirectOverhangs(int a_Seed);
@@ -134,8 +134,8 @@ protected:
cNoise m_Noise1;
cNoise m_Noise2;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
bool HasWantedBiome(cChunkDesc & a_ChunkDesc) const;
} ;
@@ -145,7 +145,7 @@ protected:
class cStructGenDistortedMembraneOverhangs :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenDistortedMembraneOverhangs(int a_Seed);
@@ -156,8 +156,8 @@ protected:
cNoise m_NoiseZ;
cNoise m_NoiseH;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 40ee20e44..3471b4cf1 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -4,6 +4,7 @@
#include "Creeper.h"
#include "../World.h"
#include "../Entities/ProjectileEntity.h"
+#include "../Entities/Player.h"
@@ -13,6 +14,7 @@ cCreeper::cCreeper(void) :
super("Creeper", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false),
+ m_BurnedWithFlintAndSteel(false),
m_ExplodingTimer(0)
{
}
@@ -25,12 +27,25 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (!ReachedFinalDestination())
+ if (!ReachedFinalDestination() && !m_BurnedWithFlintAndSteel)
{
m_ExplodingTimer = 0;
m_bIsBlowing = false;
m_World->BroadcastEntityMetadata(*this);
}
+ else
+ {
+ if (m_bIsBlowing)
+ {
+ m_ExplodingTimer += 1;
+ }
+
+ if (m_ExplodingTimer == 30)
+ {
+ m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
+ Destroy();
+ }
+ }
}
@@ -80,22 +95,30 @@ void cCreeper::Attack(float a_Dt)
{
UNUSED(a_Dt);
- m_ExplodingTimer += 1;
-
if (!m_bIsBlowing)
{
m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
}
-
- if (m_ExplodingTimer == 20)
- {
- m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
- Destroy();
- }
}
+
+void cCreeper::OnRightClicked(cPlayer & a_Player)
+{
+ if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_FLINT_AND_STEEL))
+ {
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.UseEquippedItem();
+ }
+ m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_bIsBlowing = true;
+ m_World->BroadcastEntityMetadata(*this);
+ m_BurnedWithFlintAndSteel = true;
+ }
+}
+
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index 0f71e5ad2..9abca369b 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -21,13 +21,14 @@ public:
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Attack(float a_Dt) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsBlowing(void) const {return m_bIsBlowing; }
bool IsCharged(void) const {return m_bIsCharged; }
private:
- bool m_bIsBlowing, m_bIsCharged;
+ bool m_bIsBlowing, m_bIsCharged, m_BurnedWithFlintAndSteel;
int m_ExplodingTimer;
} ;
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 6aef97079..4967c83f9 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -162,14 +162,27 @@ bool cFireSimulator::IsFuel(BLOCKTYPE a_BlockType)
switch (a_BlockType)
{
case E_BLOCK_PLANKS:
+ case E_BLOCK_DOUBLE_WOODEN_SLAB:
+ case E_BLOCK_WOODEN_SLAB:
+ case E_BLOCK_WOODEN_STAIRS:
+ case E_BLOCK_SPRUCE_WOOD_STAIRS:
+ case E_BLOCK_BIRCH_WOOD_STAIRS:
+ case E_BLOCK_JUNGLE_WOOD_STAIRS:
case E_BLOCK_LEAVES:
+ case E_BLOCK_NEW_LEAVES:
case E_BLOCK_LOG:
+ case E_BLOCK_NEW_LOG:
case E_BLOCK_WOOL:
case E_BLOCK_BOOKCASE:
case E_BLOCK_FENCE:
case E_BLOCK_TNT:
case E_BLOCK_VINES:
case E_BLOCK_HAY_BALE:
+ case E_BLOCK_TALL_GRASS:
+ case E_BLOCK_BIG_FLOWER:
+ case E_BLOCK_DANDELION:
+ case E_BLOCK_FLOWER:
+ case E_BLOCK_CARPET:
{
return true;
}
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index d68ebd54c..01a9ad274 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -106,6 +106,10 @@ public:
/** Parses and contains the parsed data
Also implements data accessor functions for tree traversal and value getters
The data pointer passed in the constructor is assumed to be valid throughout the object's life. Care must be taken not to initialize from a temporary.
+The parser decomposes the input data into a tree of tags that is stored as an array of cFastNBTTag items,
+and accessing the tree is done by using the array indices for tags. Each tag stores the indices for its parent,
+first child, last child, prev sibling and next sibling, a value of -1 indicates that the indice is not valid.
+Each primitive tag also stores the length of the contained data, in bytes.
*/
class cParsedNBT
{
@@ -114,13 +118,32 @@ public:
bool IsValid(void) const {return m_IsValid; }
+ /** Returns the root tag of the hierarchy. */
int GetRoot(void) const {return 0; }
+
+ /** Returns the first child of the specified tag, or -1 if none / not applicable. */
int GetFirstChild (int a_Tag) const { return m_Tags[a_Tag].m_FirstChild; }
+
+ /** Returns the last child of the specified tag, or -1 if none / not applicable. */
int GetLastChild (int a_Tag) const { return m_Tags[a_Tag].m_LastChild; }
+
+ /** Returns the next sibling of the specified tag, or -1 if none. */
int GetNextSibling(int a_Tag) const { return m_Tags[a_Tag].m_NextSibling; }
+
+ /** Returns the previous sibling of the specified tag, or -1 if none. */
int GetPrevSibling(int a_Tag) const { return m_Tags[a_Tag].m_PrevSibling; }
- int GetDataLength (int a_Tag) const { return m_Tags[a_Tag].m_DataLength; }
+
+ /** Returns the length of the tag's data, in bytes.
+ Not valid for Compound or List tags! */
+ int GetDataLength (int a_Tag) const
+ {
+ ASSERT(m_Tags[a_Tag].m_Type != TAG_List);
+ ASSERT(m_Tags[a_Tag].m_Type != TAG_Compound);
+ return m_Tags[a_Tag].m_DataLength;
+ }
+ /** Returns the data stored in this tag.
+ Not valid for Compound or List tags! */
const char * GetData(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type != TAG_List);
@@ -128,47 +151,56 @@ public:
return m_Data + m_Tags[a_Tag].m_DataStart;
}
+ /** Returns the direct child tag of the specified name, or -1 if no such tag. */
int FindChildByName(int a_Tag, const AString & a_Name) const
{
return FindChildByName(a_Tag, a_Name.c_str(), a_Name.length());
}
+ /** Returns the direct child tag of the specified name, or -1 if no such tag. */
int FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLength = 0) const;
- int FindTagByPath (int a_Tag, const AString & a_Path) const;
+
+ /** Returns the child tag of the specified path (Name1\Name2\Name3...), or -1 if no such tag. */
+ int FindTagByPath(int a_Tag, const AString & a_Path) const;
eTagType GetType(int a_Tag) const { return m_Tags[a_Tag].m_Type; }
- /// Returns the children type for a list tag; undefined on other tags. If list empty, returns TAG_End
+ /** Returns the children type for a List tag; undefined on other tags. If list empty, returns TAG_End. */
eTagType GetChildrenType(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_List);
return (m_Tags[a_Tag].m_FirstChild < 0) ? TAG_End : m_Tags[m_Tags[a_Tag].m_FirstChild].m_Type;
}
+ /** Returns the value stored in a Byte tag. Not valid for any other tag type. */
inline unsigned char GetByte(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Byte);
return (unsigned char)(m_Data[m_Tags[a_Tag].m_DataStart]);
}
+ /** Returns the value stored in a Short tag. Not valid for any other tag type. */
inline Int16 GetShort(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Short);
return GetBEShort(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in an Int tag. Not valid for any other tag type. */
inline Int32 GetInt(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Int);
return GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in a Long tag. Not valid for any other tag type. */
inline Int64 GetLong(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Long);
return NetworkToHostLong8(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in a Float tag. Not valid for any other tag type. */
inline float GetFloat(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Float);
@@ -186,12 +218,21 @@ public:
return f;
}
+ /** Returns the value stored in a Double tag. Not valid for any other tag type. */
inline double GetDouble(int a_Tag) const
{
+ // Cause a compile-time error if sizeof(double) != 8
+ // If your platform produces a compiler error here, you'll need to add code that manually decodes 64-bit doubles
+ char Check1[9 - sizeof(double)]; // Fails if sizeof(double) > 8
+ char Check2[sizeof(double) - 7]; // Fails if sizeof(double) < 8
+ UNUSED(Check1);
+ UNUSED(Check2);
+
ASSERT(m_Tags[a_Tag].m_Type == TAG_Double);
return NetworkToHostDouble8(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in a String tag. Not valid for any other tag type. */
inline AString GetString(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_String);
@@ -200,6 +241,7 @@ public:
return res;
}
+ /** Returns the tag's name. For tags that are not named, returns an empty string. */
inline AString GetName(int a_Tag) const
{
AString res;