summaryrefslogtreecommitdiffstats
path: root/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'World.cpp')
-rw-r--r--World.cpp15
1 files changed, 8 insertions, 7 deletions
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<std::mutex> 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);
}