summaryrefslogtreecommitdiffstats
path: root/src/Generating/GridStructGen.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-04 14:14:38 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-04 14:14:38 +0200
commit86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791 (patch)
tree1b5c702a9e9da9115e64c317bdad5aba3544d4a1 /src/Generating/GridStructGen.cpp
parentImplemented bed homes (diff)
parentMerge pull request #1059 from mc-server/coverity_fixes (diff)
downloadcuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.gz
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.bz2
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.lz
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.xz
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.zst
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.zip
Diffstat (limited to 'src/Generating/GridStructGen.cpp')
-rw-r--r--src/Generating/GridStructGen.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp
index bfa6bccb1..474242557 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,
@@ -90,7 +118,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