diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-08-21 00:23:23 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-08-26 20:56:44 +0200 |
commit | 447d929da18b656227c77d9c00958bcf52afeeb2 (patch) | |
tree | 9614d84d6164f79be0061495a684d76b583f1f13 /src/ChunkData.cpp | |
parent | Leashes work in 1.12.1 (diff) | |
download | cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.gz cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.bz2 cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.lz cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.xz cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.zst cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.zip |
Diffstat (limited to 'src/ChunkData.cpp')
-rw-r--r-- | src/ChunkData.cpp | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index c2b09bafb..310945f17 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -422,6 +422,129 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const +void cChunkData::FillBlockTypes(BLOCKTYPE a_Value) +{ + // If needed, allocate any missing sections + if (a_Value != 0x00) + { + for (auto & Section : m_Sections) + { + if (Section == nullptr) + { + Section = Allocate(); + std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), 0x00); + std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), 0x00); + std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), 0xff); + } + } + } + + for (auto Section : m_Sections) + { + if (Section != nullptr) + { + std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), a_Value); + } + } +} + + + + + +void cChunkData::FillMetas(NIBBLETYPE a_Value) +{ + // If needed, allocate any missing sections + if (a_Value != 0x00) + { + for (auto & Section : m_Sections) + { + if (Section == nullptr) + { + Section = Allocate(); + std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), 0x00); + std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), 0x00); + std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), 0xff); + } + } + } + + NIBBLETYPE NewMeta = static_cast<NIBBLETYPE>((a_Value << 4) | a_Value); + for (auto Section : m_Sections) + { + if (Section != nullptr) + { + std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), NewMeta); + } + } +} + + + + + +void cChunkData::FillBlockLight(NIBBLETYPE a_Value) +{ + // If needed, allocate any missing sections + if (a_Value != 0x00) + { + for (auto & Section : m_Sections) + { + if (Section == nullptr) + { + Section = Allocate(); + std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), 0x00); + std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), 0x00); + std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), 0xff); + } + } + } + + NIBBLETYPE NewLight = static_cast<NIBBLETYPE>((a_Value << 4) | a_Value); + for (auto Section : m_Sections) + { + if (Section != nullptr) + { + std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), NewLight); + } + } +} + + + + + +void cChunkData::FillSkyLight(NIBBLETYPE a_Value) +{ + // If needed, allocate any missing sections + if (a_Value != 0x0f) + { + for (auto & Section : m_Sections) + { + if (Section == nullptr) + { + Section = Allocate(); + std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), 0x00); + std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), 0x00); + std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), 0x00); + } + } + } + + NIBBLETYPE NewSkyLight = static_cast<NIBBLETYPE>((a_Value << 4) | a_Value); + for (auto Section : m_Sections) + { + if (Section != nullptr) + { + std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), NewSkyLight); + } + } +} + + + + + void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) { ASSERT(a_Src != nullptr); |