diff options
author | madmaxoft <github@xoft.cz> | 2014-01-10 22:22:54 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-01-10 22:22:54 +0100 |
commit | cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8 (patch) | |
tree | b6795602eb6f64625b2734c6e3a302a5374e145d /src/World.cpp | |
parent | Fixed generator adding values to ini file. (diff) | |
download | cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.tar cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.tar.gz cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.tar.bz2 cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.tar.lz cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.tar.xz cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.tar.zst cuberite-cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/World.cpp | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/src/World.cpp b/src/World.cpp index 39300d419..1cf82d641 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -10,6 +10,7 @@ #include "Root.h" #include "inifile/iniFile.h" #include "ChunkMap.h" +#include "Generating/ChunkDesc.h" #include "OSSupport/Timer.h" // Entities (except mobs): @@ -238,6 +239,7 @@ cWorld::cWorld(const AString & a_WorldName) : m_SkyDarkness(0), m_Weather(eWeather_Sunny), m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :) + m_GeneratorCallbacks(*this), m_TickThread(*this) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); @@ -583,7 +585,7 @@ void cWorld::Start(void) m_Lighting.Start(this); m_Storage.Start(this, m_StorageSchema); - m_Generator.Start(this, IniFile); + m_Generator.Start(m_GeneratorCallbacks, m_GeneratorCallbacks, IniFile); m_ChunkSender.Start(this); m_TickThread.Start(); @@ -2843,3 +2845,77 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cWorld::cChunkGeneratorCallbacks: + +cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) : + m_World(&a_World) +{ +} + + + + + +void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc) +{ + cChunkDef::BlockNibbles BlockMetas; + a_ChunkDesc.CompressBlockMetas(BlockMetas); + + m_World->SetChunkData( + a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), + a_ChunkDesc.GetBlockTypes(), BlockMetas, + NULL, NULL, // We don't have lighting, chunk will be lighted when needed + &a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(), + a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(), + true + ); + + // Save the chunk right after generating, so that we don't have to generate it again on next run + m_World->GetStorage().QueueSaveChunk(a_ChunkDesc.GetChunkX(), 0, a_ChunkDesc.GetChunkZ()); +} + + + + + +bool cWorld::cChunkGeneratorCallbacks::IsChunkValid(int a_ChunkX, int a_ChunkZ) +{ + return m_World->IsChunkValid(a_ChunkX, a_ChunkZ); +} + + + + + +bool cWorld::cChunkGeneratorCallbacks::HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) +{ + return m_World->HasChunkAnyClients(a_ChunkX, a_ChunkZ); +} + + + + + +void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) +{ + cPluginManager::Get()->CallHookChunkGenerating( + m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc + ); +} + + + + + +void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) +{ + cPluginManager::Get()->CallHookChunkGenerated( + m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc + ); +} + + + + + |