From d46f3a7180afdb5213afc80c97ae5fc8db43248a Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sun, 23 Apr 2017 18:39:59 +0500 Subject: 2017-04-23 --- World.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'World.cpp') diff --git a/World.cpp b/World.cpp index 4a750ab..c19f88c 100644 --- a/World.cpp +++ b/World.cpp @@ -5,7 +5,6 @@ void World::ParseChunkData(Packet packet) { int chunkX = packet.GetField(0).GetInt(); int chunkZ = packet.GetField(1).GetInt(); - std::cout << "Parsing chunk " << chunkX << "x" << chunkZ << std::endl; bool isGroundContinuous = packet.GetField(2).GetBool(); std::bitset<16> bitmask(packet.GetField(3).GetVarInt()); int entities = packet.GetField(5).GetVarInt(); @@ -23,7 +22,7 @@ void World::ParseChunkData(Packet packet) { if (bitmask[i]) { size_t len = 0; m_sections[PositionI(chunkX, chunkZ, i)] = ParseSection(content, len); - m_sectionToParse.push(m_sections.find(PositionI(chunkX,chunkZ,i))); + m_sectionToParse.push(m_sections.find(PositionI(chunkX, chunkZ, i))); m_parseSectionWaiter.notify_one(); content += len; } @@ -80,27 +79,29 @@ Section World::ParseSection(byte *data, size_t &dataLen) { } World::~World() { - isContinue=false; + isContinue = false; m_parseSectionWaiter.notify_all(); m_sectionParseThread.join(); } void World::SectionParsingThread() { - while (isContinue){ + while (isContinue) { std::unique_lock sectionParseLocker(m_parseSectionMutex); m_parseSectionWaiter.wait(sectionParseLocker); - while (!m_sectionToParse.size()==0 && isContinue) { + while (m_sectionToParse.size() == 0 && isContinue) { m_parseSectionWaiter.wait(sectionParseLocker); } - while (m_sectionToParse.size()>0){ + while (m_sectionToParse.size() > 0) { auto it = m_sectionToParse.front(); m_sectionToParse.pop(); it->second.Parse(); + /*std::cout << "Parsed chunk" << it->first.GetX() << "x" << it->first.GetY() << "x" << it->first.GetZ() + << std::endl;*/ } } } World::World() { - m_sectionParseThread = std::thread(&World::SectionParsingThread,this); + m_sectionParseThread = std::thread(&World::SectionParsingThread, this); } -- cgit v1.2.3