summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--VC2008/MCServer.vcproj8
-rw-r--r--VC2010/MCServer.vcxproj2
-rw-r--r--VC2010/MCServer.vcxproj.filters2
-rw-r--r--source/WGFlat.cpp101
-rw-r--r--source/WGFlat.h35
-rw-r--r--source/cChunkGenerator.cpp14
-rw-r--r--source/cWorld.cpp6
-rw-r--r--source/cWorld.h2
8 files changed, 160 insertions, 10 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index b55517642..589abdc27 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -1698,6 +1698,14 @@
RelativePath="..\source\cWorldGenerator_Test.h"
>
</File>
+ <File
+ RelativePath="..\source\WGFlat.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WGFlat.h"
+ >
+ </File>
</Filter>
</Filter>
<File
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj
index 83515f880..06d7a9710 100644
--- a/VC2010/MCServer.vcxproj
+++ b/VC2010/MCServer.vcxproj
@@ -485,6 +485,7 @@
<ClCompile Include="..\source\Vector3d.cpp" />
<ClCompile Include="..\source\Vector3f.cpp" />
<ClCompile Include="..\source\Vector3i.cpp" />
+ <ClCompile Include="..\source\WGFlat.cpp" />
<ClCompile Include="..\source\WorldStorage.cpp" />
<ClCompile Include="..\source\WSSAnvil.cpp" />
<ClCompile Include="..\source\WSSCompact.cpp" />
@@ -666,6 +667,7 @@
<ClInclude Include="..\source\Vector3d.h" />
<ClInclude Include="..\source\Vector3f.h" />
<ClInclude Include="..\source\Vector3i.h" />
+ <ClInclude Include="..\source\WGFlat.h" />
<ClInclude Include="..\source\WorldStorage.h" />
<ClInclude Include="..\source\WSSAnvil.h" />
<ClInclude Include="..\source\WSSCompact.h" />
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters
index 294a954a9..794d49ede 100644
--- a/VC2010/MCServer.vcxproj.filters
+++ b/VC2010/MCServer.vcxproj.filters
@@ -921,6 +921,7 @@
<ClCompile Include="..\source\ChunkSender.cpp" />
<ClCompile Include="..\source\WSSAnvil.cpp" />
<ClCompile Include="..\source\NBT.cpp" />
+ <ClCompile Include="..\source\WGFlat.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\cServer.h">
@@ -1423,6 +1424,7 @@
<ClInclude Include="..\source\ChunkSender.h" />
<ClInclude Include="..\source\WSSAnvil.h" />
<ClInclude Include="..\source\NBT.h" />
+ <ClInclude Include="..\source\WGFlat.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\source\AllToLua.pkg">
diff --git a/source/WGFlat.cpp b/source/WGFlat.cpp
new file mode 100644
index 000000000..725572334
--- /dev/null
+++ b/source/WGFlat.cpp
@@ -0,0 +1,101 @@
+
+// WGFlat.cpp
+
+// Implements the cWGFlat class representing the flat world generator
+
+#include "Globals.h"
+#include "WGFlat.h"
+#include "../iniFile/iniFile.h"
+#include "cWorld.h"
+
+
+
+
+
+cWGFlat::cWGFlat(cWorld * a_World) :
+ super(a_World)
+{
+ // Load the settings from the INI file:
+ cIniFile INI(a_World->GetIniFileName());
+ INI.ReadFile();
+ m_Height = INI.GetValueI("flat", "height", 5);
+ if (m_Height < 1)
+ {
+ m_Height = 1;
+ }
+ if (m_Height > 250)
+ {
+ m_Height = 250;
+ }
+}
+
+
+
+
+
+void cWGFlat::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
+{
+ int SliceSize = cChunk::c_ChunkWidth * cChunk::c_ChunkWidth;
+ memset(a_BlockData, E_BLOCK_BEDROCK, SliceSize);
+ switch (m_Height)
+ {
+ case 1:
+ {
+ // Just the bedrock layer
+ break;
+ }
+ case 2:
+ {
+ // Bedrock + 1 dirt layer:
+ memset(a_BlockData + SliceSize, E_BLOCK_GRASS, SliceSize);
+ break;
+ }
+ case 3:
+ {
+ // Bedrock + 2 dirt layers:
+ memset(a_BlockData + SliceSize, E_BLOCK_DIRT, SliceSize);
+ memset(a_BlockData + 2 * SliceSize, E_BLOCK_GRASS, SliceSize);
+ break;
+ }
+ case 4:
+ {
+ // Bedrock + 3 dirt layers:
+ memset(a_BlockData + SliceSize, E_BLOCK_DIRT, 2 * SliceSize);
+ memset(a_BlockData + 3 * SliceSize, E_BLOCK_GRASS, SliceSize);
+ break;
+ }
+ default:
+ {
+ // Bedrock + stone layers + 3 dirt layers:
+ memset(a_BlockData + SliceSize, E_BLOCK_STONE, SliceSize * (m_Height - 4));
+ memset(a_BlockData + SliceSize * (m_Height - 3), E_BLOCK_DIRT, SliceSize * 2);
+ memset(a_BlockData + SliceSize * (m_Height - 1), E_BLOCK_GRASS, SliceSize);
+ break;
+ }
+ }
+ memset(a_BlockData + SliceSize * m_Height, E_BLOCK_AIR, cChunk::c_NumBlocks - SliceSize * m_Height);
+
+ SliceSize /= 2; // Nibbles from now on
+ char * Meta = a_BlockData + cChunk::c_NumBlocks;
+ memset(Meta, 0, cChunk::c_NumBlocks / 2);
+
+ char * SkyLight = Meta + cChunk::c_NumBlocks / 2;
+ memset(SkyLight, 0, m_Height * SliceSize);
+ memset(SkyLight + m_Height * SliceSize, 0xff, cChunk::c_NumBlocks / 2 - m_Height * SliceSize);
+
+ char * BlockLight = SkyLight + cChunk::c_NumBlocks / 2;
+ memset(BlockLight, 0, cChunk::c_NumBlocks / 2);
+}
+
+
+
+
+
+void cWGFlat::PostGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ // Nothing needed yet, just don't call the parent
+}
+
+
+
+
diff --git a/source/WGFlat.h b/source/WGFlat.h
new file mode 100644
index 000000000..79a2053c5
--- /dev/null
+++ b/source/WGFlat.h
@@ -0,0 +1,35 @@
+
+// WGFlat.h
+
+// Interfaces to the cWGFlat class representing the flat world generator
+
+
+
+
+
+#pragma once
+
+#include "cWorldGenerator.h"
+
+
+
+
+
+class cWGFlat :
+ public cWorldGenerator
+{
+ typedef cWorldGenerator super;
+
+protected:
+ int m_Height;
+
+ virtual void GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities) override;
+ virtual void PostGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
+
+public:
+ cWGFlat(cWorld * a_World);
+} ;
+
+
+
+
diff --git a/source/cChunkGenerator.cpp b/source/cChunkGenerator.cpp
index e6296baa6..7dde581c2 100644
--- a/source/cChunkGenerator.cpp
+++ b/source/cChunkGenerator.cpp
@@ -5,13 +5,7 @@
#include "cWorld.h"
#include "cWorldGenerator.h"
#include "cWorldGenerator_Test.h"
-
-
-
-
-
-typedef std::pair<int, int> ChunkCoord;
-typedef std::list< ChunkCoord > ChunkCoordList;
+#include "WGFlat.h"
@@ -51,10 +45,14 @@ bool cChunkGenerator::Start(cWorld * a_World, const AString & a_WorldGeneratorNa
{
m_World = a_World;
- if (a_WorldGeneratorName.compare("Test") == 0 )
+ if (NoCaseCompare(a_WorldGeneratorName, "Test") == 0 )
{
m_pWorldGenerator = new cWorldGenerator_Test(a_World);
}
+ else if (NoCaseCompare(a_WorldGeneratorName, "flat") == 0)
+ {
+ m_pWorldGenerator = new cWGFlat(a_World);
+ }
else // Default
{
m_pWorldGenerator = new cWorldGenerator(a_World);
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 62c952ba1..91fbe7f64 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -184,6 +184,7 @@ cWorld::cWorld( const AString & a_WorldName )
{
LOG("cWorld::cWorld(%s)", a_WorldName.c_str());
m_WorldName = a_WorldName;
+ m_IniFileName = m_WorldName + "/world.ini";
cMakeDir::MakeDir(m_WorldName.c_str());
@@ -197,7 +198,7 @@ cWorld::cWorld( const AString & a_WorldName )
AString GeneratorName;
AString StorageSchema("Default");
- cIniFile IniFile( m_WorldName + "/world.ini");
+ cIniFile IniFile(m_IniFileName);
if( IniFile.ReadFile() )
{
m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX );
@@ -219,7 +220,7 @@ cWorld::cWorld( const AString & a_WorldName )
IniFile.SetValue("Storage", "Schema", StorageSchema);
if( !IniFile.WriteFile() )
{
- LOG("WARNING: Could not write to %s/world.ini", a_WorldName.c_str());
+ LOG("WARNING: Could not write to %s", m_IniFileName.c_str());
}
}
LOGINFO("Seed: %i", m_WorldSeed );
@@ -302,6 +303,7 @@ cWorld::cWorld( const AString & a_WorldName )
g_BlockTransparent[ E_BLOCK_RED_ROSE ] = true;
g_BlockTransparent[ E_BLOCK_RED_MUSHROOM ] = true;
g_BlockTransparent[ E_BLOCK_BROWN_MUSHROOM ] = true;
+ g_BlockTransparent[ E_BLOCK_SNOW ] = true;
// TODO: Any other transparent blocks?
diff --git a/source/cWorld.h b/source/cWorld.h
index fa00a78bc..bdf2ae2c5 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -187,6 +187,7 @@ public:
unsigned int GetWorldSeed(void) const { return m_WorldSeed; } //tolua_export
const AString & GetName(void) const { return m_WorldName; } //tolua_export
+ const AString & GetIniFileName(void) const {return m_IniFileName; }
inline static void AbsoluteToRelative( int & a_X, int & a_Y, int & a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
{
@@ -299,6 +300,7 @@ private:
cChunkSender m_ChunkSender;
AString m_WorldName;
+ AString m_IniFileName;
cWorld(const AString & a_WorldName);
~cWorld();