From f721ed0e3c6be33670fe330c029a2d4c3353f635 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Wed, 31 May 2017 19:17:09 +0500 Subject: 2017-05-31 --- src/world/Section.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/world/Section.cpp') diff --git a/src/world/Section.cpp b/src/world/Section.cpp index 5c42ea5..6147295 100644 --- a/src/world/Section.cpp +++ b/src/world/Section.cpp @@ -36,6 +36,7 @@ Block &Section::GetBlock(Vector pos) { while (m_dataBlocks != nullptr) { parseWaiter.wait(parseLocker); } + LOG(WARNING)<<"Successfully waited for block render!"; } return m_blocks[pos.GetY() * 256 + pos.GetZ() * 16 + pos.GetX()]; } @@ -45,13 +46,13 @@ void Section::Parse() { return; long long *longArray = reinterpret_cast(m_dataBlocks); - for (int i = 0; i < m_dataBlocksLen / 8; i++) + for (size_t i = 0; i < m_dataBlocksLen / 8; i++) endswap(&longArray[i]); std::vector blocks; blocks.reserve(4096); int bitPos = 0; unsigned short t = 0; - for (int i = 0; i < m_dataBlocksLen; i++) { + for (size_t i = 0; i < m_dataBlocksLen; i++) { for (int j = 0; j < 8; j++) { t |= (m_dataBlocks[i] & 0x01) ? 0x80 : 0x00; t >>= 1; @@ -77,7 +78,7 @@ void Section::Parse() { } for (int i = 0; i < 4096; i++) { unsigned short blockId = m_palette.size() > 0 ? m_palette[blocks[i]] : blocks[i]; - Block block(blockId, 0, light[i]); + Block block(blockId>>4, blockId>>4 & 0xF); m_blocks.push_back(block); } if ((light.size() + blocks.size()) / 2 != 4096) { @@ -90,7 +91,17 @@ void Section::Parse() { m_dataLight = nullptr; delete[] m_dataSkyLight; m_dataSkyLight = nullptr; + parseWaiter.notify_all(); + /*static std::map totalBlocks; + for (int x=0;x<16;x++) + for (int y=0;y<16;y++) + for (int z=0;z<16;z++) + totalBlocks[GetBlock(Vector(x,y,z))]++; + LOG(ERROR)<<"Logging chunk"; + for (auto& it:totalBlocks){ + LOG(WARNING)<