diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-31 16:17:09 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-31 16:17:09 +0200 |
commit | f721ed0e3c6be33670fe330c029a2d4c3353f635 (patch) | |
tree | 5afad5a292171d546d9ded16de6151a014883d84 /src/world/Section.cpp | |
parent | 2017-05-28 (diff) | |
download | AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.gz AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.bz2 AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.lz AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.xz AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.zst AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.zip |
Diffstat (limited to '')
-rw-r--r-- | src/world/Section.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
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<long long *>(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<unsigned short> 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<Block,int> 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)<<it.first.id<<":"<<(int)it.first.state<<" = "<<it.second; + }*/ } Section &Section::operator=(Section other) { |