Some kind of 'template' world generator that right now just generates an all dirt world. You can use this to test new algorithms
git-svn-id: http://mc-server.googlecode.com/svn/trunk@127 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
eb942797b8
commit
0d8ecbeca1
@ -282,6 +282,7 @@
|
||||
<ClCompile Include="..\source\cWindow.cpp" />
|
||||
<ClCompile Include="..\source\cWolf.cpp" />
|
||||
<ClCompile Include="..\source\cWorldGenerator.cpp" />
|
||||
<ClCompile Include="..\source\cWorldGenerator_Test.cpp" />
|
||||
<ClCompile Include="..\source\cZombie.cpp" />
|
||||
<ClCompile Include="..\source\cZombiepigman.cpp" />
|
||||
<ClCompile Include="..\Source\ManualBindings.cpp" />
|
||||
@ -433,6 +434,7 @@
|
||||
<ClInclude Include="..\source\cWindowOwner.h" />
|
||||
<ClInclude Include="..\source\cWolf.h" />
|
||||
<ClInclude Include="..\source\cWorldGenerator.h" />
|
||||
<ClInclude Include="..\source\cWorldGenerator_Test.h" />
|
||||
<ClInclude Include="..\source\cZombie.h" />
|
||||
<ClInclude Include="..\source\cZombiepigman.h" />
|
||||
<ClInclude Include="..\source\Endianness.h" />
|
||||
|
@ -427,6 +427,9 @@
|
||||
<Filter Include="!LuaPlugins">
|
||||
<UniqueIdentifier>{4b86e1cf-ea3c-40b6-82b2-82fa9e6eb35e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="cWorldGenerator\cWorldGenerator_Test">
|
||||
<UniqueIdentifier>{c86f4c53-af06-4b42-97dd-ffb7035041ce}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\source\cServer.cpp">
|
||||
@ -850,6 +853,12 @@
|
||||
<ClCompile Include="..\source\cWorldGenerator.cpp">
|
||||
<Filter>cWorldGenerator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\cSandSimulator.cpp" />
|
||||
<ClCompile Include="..\source\cSimulator.cpp" />
|
||||
<ClCompile Include="..\source\cSimulatorManager.cpp" />
|
||||
<ClCompile Include="..\source\cWorldGenerator_Test.cpp">
|
||||
<Filter>cWorldGenerator\cWorldGenerator_Test</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\source\cServer.h">
|
||||
@ -1308,6 +1317,12 @@
|
||||
<ClInclude Include="..\source\cWorldGenerator.h">
|
||||
<Filter>cWorldGenerator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\cSandSimulator.h" />
|
||||
<ClInclude Include="..\source\cSimulator.h" />
|
||||
<ClInclude Include="..\source\cSimulatorManager.h" />
|
||||
<ClInclude Include="..\source\cWorldGenerator_Test.h">
|
||||
<Filter>cWorldGenerator\cWorldGenerator_Test</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\source\AllToLua.pkg">
|
||||
@ -1317,18 +1332,6 @@
|
||||
<None Include="..\source\cNoise.inc">
|
||||
<Filter>cNoise</Filter>
|
||||
</None>
|
||||
<None Include="..\Plugins\ChatLog.lua">
|
||||
<Filter>!LuaPlugins</Filter>
|
||||
</None>
|
||||
<None Include="..\Plugins\Core.lua">
|
||||
<Filter>!LuaPlugins</Filter>
|
||||
</None>
|
||||
<None Include="..\Plugins\Fire.lua">
|
||||
<Filter>!LuaPlugins</Filter>
|
||||
</None>
|
||||
<None Include="..\Plugins\MagicCarpet.lua">
|
||||
<Filter>!LuaPlugins</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MCServer.rc" />
|
||||
|
6
makefile
6
makefile
@ -113,6 +113,7 @@ MCServer : \
|
||||
build/cWindow.o\
|
||||
build/cWorld.o\
|
||||
build/cWorldGenerator.o\
|
||||
build/cWorldGenerator_Test.o\
|
||||
build/main.o\
|
||||
build/ManualBindings.o\
|
||||
build/Matrix4f.o\
|
||||
@ -315,6 +316,7 @@ MCServer : \
|
||||
build/cWindow.o\
|
||||
build/cWorld.o\
|
||||
build/cWorldGenerator.o\
|
||||
build/cWorldGenerator_Test.o\
|
||||
build/main.o\
|
||||
build/ManualBindings.o\
|
||||
build/Matrix4f.o\
|
||||
@ -520,6 +522,7 @@ clean :
|
||||
build/cWindow.o\
|
||||
build/cWorld.o\
|
||||
build/cWorldGenerator.o\
|
||||
build/cWorldGenerator_Test.o\
|
||||
build/main.o\
|
||||
build/ManualBindings.o\
|
||||
build/Matrix4f.o\
|
||||
@ -881,6 +884,9 @@ build/cWorld.o : source/cWorld.cpp
|
||||
build/cWorldGenerator.o : source/cWorldGenerator.cpp
|
||||
$(CC) $(CC_OPTIONS) source/cWorldGenerator.cpp -c $(INCLUDE) -o build/cWorldGenerator.o
|
||||
|
||||
# Item # 40 -- cWorldGenerator_Test --
|
||||
build/cWorldGenerator_Test.o : source/cWorldGenerator_Test.cpp
|
||||
$(CC) $(CC_OPTIONS) source/cWorldGenerator_Test.cpp -c $(INCLUDE) -o build/cWorldGenerator_Test.o
|
||||
|
||||
# Item # 41 -- main --
|
||||
build/main.o : source/main.cpp
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
@ -133,8 +134,7 @@ void cChunk::Initialize()
|
||||
// Clear memory
|
||||
memset( m_BlockData, 0x00, c_BlockDataSize );
|
||||
|
||||
cWorldGenerator Generator;
|
||||
Generator.GenerateChunk( this );
|
||||
m_World->GetWorldGenerator()->GenerateChunk( this );
|
||||
|
||||
CalculateHeightmap();
|
||||
CalculateLighting();
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "cMakeDir.h"
|
||||
#include "cChunkGenerator.h"
|
||||
#include "MersenneTwister.h"
|
||||
#include "cWorldGenerator_Test.h"
|
||||
|
||||
|
||||
#include "packets/cPacket_TimeUpdate.h"
|
||||
@ -141,6 +142,7 @@ cWorld::cWorld( const char* a_WorldName )
|
||||
, m_SpawnMonsterTime( 0.f )
|
||||
, m_RSList ( 0 )
|
||||
, m_Weather ( 0 )
|
||||
, m_WorldGenerator( 0 )
|
||||
{
|
||||
LOG("cWorld::cWorld(%s)", a_WorldName);
|
||||
m_pState->WorldName = a_WorldName;
|
||||
@ -154,6 +156,8 @@ cWorld::cWorld( const char* a_WorldName )
|
||||
m_WorldSeed = r1.randInt();
|
||||
m_GameMode = 0;
|
||||
|
||||
std::string WorldGeneratorName;
|
||||
|
||||
cIniFile IniFile( m_pState->WorldName + "/world.ini");
|
||||
if( IniFile.ReadFile() )
|
||||
{
|
||||
@ -162,6 +166,7 @@ cWorld::cWorld( const char* a_WorldName )
|
||||
m_SpawnZ = IniFile.GetValueF("SpawnPosition", "Z", m_SpawnZ );
|
||||
m_WorldSeed = IniFile.GetValueI("Seed", "Seed", m_WorldSeed );
|
||||
m_GameMode = IniFile.GetValueI("GameMode", "GameMode", m_GameMode );
|
||||
WorldGeneratorName = IniFile.GetValue("Generator", "GeneratorName", "Default");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -170,6 +175,7 @@ cWorld::cWorld( const char* a_WorldName )
|
||||
IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ );
|
||||
IniFile.SetValueI("Seed", "Seed", m_WorldSeed );
|
||||
IniFile.SetValueI("GameMode", "GameMode", m_GameMode );
|
||||
IniFile.SetValue("Generator", "GeneratorName", "Default" );
|
||||
if( !IniFile.WriteFile() )
|
||||
{
|
||||
LOG("WARNING: Could not write to %s/world.ini", a_WorldName);
|
||||
@ -177,6 +183,11 @@ cWorld::cWorld( const char* a_WorldName )
|
||||
}
|
||||
LOGINFO("Seed: %i", m_WorldSeed );
|
||||
|
||||
if( WorldGeneratorName.compare("Test") == 0 )
|
||||
m_WorldGenerator = new cWorldGenerator_Test();
|
||||
else // Default
|
||||
m_WorldGenerator = new cWorldGenerator();
|
||||
|
||||
cIniFile GenSettings("terrain.ini");
|
||||
if( GenSettings.ReadFile() )
|
||||
{
|
||||
@ -224,20 +235,15 @@ cWorld::cWorld( const char* a_WorldName )
|
||||
m_ChunksCriticalSection = new cCriticalSection();
|
||||
|
||||
//Simulators:
|
||||
m_SimulatorManager = new cSimulatorManager();
|
||||
|
||||
m_WaterSimulator = new cWaterSimulator( this );
|
||||
m_SimulatorManager->RegisterSimulator(m_WaterSimulator, 6);
|
||||
|
||||
m_LavaSimulator = new cLavaSimulator( this );
|
||||
m_SimulatorManager->RegisterSimulator(m_LavaSimulator, 12);
|
||||
|
||||
m_SandSimulator = new cSandSimulator(this);
|
||||
|
||||
m_SimulatorManager = new cSimulatorManager();
|
||||
m_SimulatorManager->RegisterSimulator(m_WaterSimulator, 6);
|
||||
m_SimulatorManager->RegisterSimulator(m_LavaSimulator, 12);
|
||||
m_SimulatorManager->RegisterSimulator(m_SandSimulator, 1);
|
||||
|
||||
|
||||
|
||||
memset( g_BlockLightValue, 0x0, 128 );
|
||||
memset( g_BlockSpreadLightFalloff, 0xf, 128 ); // 0xf means total falloff
|
||||
memset( g_BlockTransparent, 0x0, 128 );
|
||||
|
@ -27,6 +27,7 @@ class cClientHandle;
|
||||
class cChunk;
|
||||
class cEntity;
|
||||
class cBlockEntity;
|
||||
class cWorldGenerator;
|
||||
|
||||
|
||||
class cWorld //tolua_export
|
||||
@ -154,7 +155,7 @@ public:
|
||||
void SetWeather ( int ); //tolua_export
|
||||
int GetWeather() { return m_Weather; }; //tolua_export
|
||||
|
||||
|
||||
cWorldGenerator* GetWorldGenerator() { return m_WorldGenerator; }
|
||||
private:
|
||||
friend class cRoot;
|
||||
cWorld( const char* a_WorldName );
|
||||
@ -184,10 +185,11 @@ private:
|
||||
cWaterSimulator* m_WaterSimulator;
|
||||
cLavaSimulator* m_LavaSimulator;
|
||||
|
||||
|
||||
cCriticalSection* m_ClientHandleCriticalSection;
|
||||
cCriticalSection* m_EntitiesCriticalSection;
|
||||
cCriticalSection* m_ChunksCriticalSection;
|
||||
|
||||
cWorldGenerator* m_WorldGenerator;
|
||||
|
||||
std::string m_Description;
|
||||
unsigned int m_MaxPlayers;
|
||||
|
25
source/cWorldGenerator_Test.cpp
Normal file
25
source/cWorldGenerator_Test.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "cWorldGenerator_Test.h"
|
||||
#include "cChunk.h"
|
||||
#include "BlockID.h"
|
||||
|
||||
void cWorldGenerator_Test::GenerateTerrain( cChunk* a_Chunk )
|
||||
{
|
||||
char* BlockType = a_Chunk->pGetType();
|
||||
|
||||
for(int x = 0; x < 16; x++)
|
||||
{
|
||||
for(int z = 0; z < 16; z++)
|
||||
{
|
||||
for( int y = 1; y < 128; ++y )
|
||||
{
|
||||
unsigned int idx = cChunk::MakeIndex(x, y, z);
|
||||
BlockType[idx] = E_BLOCK_DIRT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cWorldGenerator_Test::GenerateFoliage( cChunk* a_Chunk )
|
||||
{
|
||||
(void)a_Chunk;
|
||||
}
|
10
source/cWorldGenerator_Test.h
Normal file
10
source/cWorldGenerator_Test.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "cWorldGenerator.h"
|
||||
|
||||
class cWorldGenerator_Test : public cWorldGenerator
|
||||
{
|
||||
protected:
|
||||
virtual void GenerateTerrain( cChunk* a_Chunk );
|
||||
virtual void GenerateFoliage( cChunk* a_Chunk );
|
||||
};
|
Loading…
Reference in New Issue
Block a user