summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-05-15 16:03:45 +0200
committermadmaxoft <github@xoft.cz>2014-05-15 16:03:45 +0200
commit70b0547499c4343e3071a54e3c093712669a3a8f (patch)
tree2f8c8423fc2e497a263393f18f889405ea4153f0
parentChanged village generator defaults to more reasonable values. (diff)
downloadcuberite-70b0547499c4343e3071a54e3c093712669a3a8f.tar
cuberite-70b0547499c4343e3071a54e3c093712669a3a8f.tar.gz
cuberite-70b0547499c4343e3071a54e3c093712669a3a8f.tar.bz2
cuberite-70b0547499c4343e3071a54e3c093712669a3a8f.tar.lz
cuberite-70b0547499c4343e3071a54e3c093712669a3a8f.tar.xz
cuberite-70b0547499c4343e3071a54e3c093712669a3a8f.tar.zst
cuberite-70b0547499c4343e3071a54e3c093712669a3a8f.zip
-rw-r--r--src/Generating/GridStructGen.cpp35
-rw-r--r--src/Generating/GridStructGen.h16
2 files changed, 42 insertions, 9 deletions
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp
index 3bbc89054..23946e2e9 100644
--- a/src/Generating/GridStructGen.cpp
+++ b/src/Generating/GridStructGen.cpp
@@ -9,6 +9,34 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cEmptyStructure:
+
+/** A cStructure descendant representing an empty structure.
+Used when the generator descended from cGridStructGen doesn't return any structure, to keep at least the
+Origin coords so that the structure isn't queried over and over again. */
+class cEmptyStructure :
+ public cGridStructGen::cStructure
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cEmptyStructure(int a_OriginX, int a_OriginZ) :
+ super(a_OriginX, a_OriginZ)
+ {
+ }
+
+protected:
+ virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override
+ {
+ // Do nothing
+ }
+} ;
+
+
+
+
+
cGridStructGen::cGridStructGen(
int a_Seed,
int a_GridSizeX, int a_GridSizeZ,
@@ -81,7 +109,12 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur
} // for itr - a_Structures[]
if (!Found)
{
- a_Structures.push_back(CreateStructure(OriginX, OriginZ));
+ cStructurePtr Structure = CreateStructure(OriginX, OriginZ);
+ if (Structure.get() == NULL)
+ {
+ Structure.reset(new cEmptyStructure(OriginX, OriginZ));
+ }
+ a_Structures.push_back(Structure);
}
} // for z
} // for x
diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h
index 234cc75c5..630a5e44e 100644
--- a/src/Generating/GridStructGen.h
+++ b/src/Generating/GridStructGen.h
@@ -39,14 +39,6 @@ class cGridStructGen :
public cFinishGen
{
public:
- cGridStructGen(
- int a_Seed,
- int a_GridSizeX, int a_GridSizeZ,
- int a_MaxStructureSizeX, int a_MaxStructureSizeZ,
- size_t a_MaxCacheSize
- );
-
-protected:
/** Represents a single structure that occupies the grid point. Knows how to draw itself into a chunk. */
class cStructure
{
@@ -75,6 +67,14 @@ protected:
typedef std::list<cStructurePtr> cStructurePtrs;
+ cGridStructGen(
+ int a_Seed,
+ int a_GridSizeX, int a_GridSizeZ,
+ int a_MaxStructureSizeX, int a_MaxStructureSizeZ,
+ size_t a_MaxCacheSize
+ );
+
+protected:
/** Seed for generating the semi-random grid. */
int m_Seed;