summaryrefslogtreecommitdiffstats
path: root/src/world
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-26 16:11:17 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-26 16:11:17 +0200
commit8ac4fe6d5ba5091923c7fdf1fa88724d827706fa (patch)
treea4ce203f671f9b8311d09dd36f1f80ae65799a56 /src/world
parent2017-05-21 (diff)
downloadAltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar
AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.gz
AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.bz2
AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.lz
AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.xz
AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.zst
AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.zip
Diffstat (limited to '')
-rw-r--r--src/world/Block.cpp17
-rw-r--r--src/world/Block.hpp10
-rw-r--r--src/world/Section.cpp1
-rw-r--r--src/world/World.cpp17
4 files changed, 24 insertions, 21 deletions
diff --git a/src/world/Block.cpp b/src/world/Block.cpp
index 64e5330..3cf09db 100644
--- a/src/world/Block.cpp
+++ b/src/world/Block.cpp
@@ -2,9 +2,18 @@
Block::~Block() {}
-Block::Block(unsigned short idAndState, unsigned char light) : id(idAndState >> 4), state(idAndState & 0x0F),
- light(light) {}
+Block::Block(unsigned short idAndState, unsigned char light) : id(idAndState >> 4), state(idAndState & 0x0F) {}
-Block::Block(unsigned short id, unsigned char state, unsigned char light) : id(id), state(state), light(light) {}
+Block::Block(unsigned short id, unsigned char state, unsigned char light) : id(id), state(state) {}
-Block::Block() : id(0), state(0), light(0) {}
+Block::Block() : id(0), state(0) {}
+
+bool operator<(const Block &lhs, const Block &rhs) {
+ if (lhs.id < rhs.id)
+ return true;
+ if (lhs.id == rhs.id) {
+ if (lhs.state != rhs.state)
+ return lhs.state < rhs.state;
+ }
+ return false;
+}
diff --git a/src/world/Block.hpp b/src/world/Block.hpp
index 7c780c1..ae952c9 100644
--- a/src/world/Block.hpp
+++ b/src/world/Block.hpp
@@ -1,15 +1,17 @@
#pragma once
struct Block {
+ Block();
+
Block(unsigned short idAndState, unsigned char light);
Block(unsigned short id, unsigned char state, unsigned char light);
- Block();
-
~Block();
unsigned short id:13;
unsigned char state:4;
- unsigned char light:4;
-}; \ No newline at end of file
+ //unsigned char light:4;
+};
+
+bool operator<(const Block &lhs, const Block &rhs); \ No newline at end of file
diff --git a/src/world/Section.cpp b/src/world/Section.cpp
index f53c987..ac34fba 100644
--- a/src/world/Section.cpp
+++ b/src/world/Section.cpp
@@ -1,4 +1,3 @@
-#include <iostream>
#include "Section.hpp"
Section::Section(byte *dataBlocks, size_t dataBlocksLength, byte *dataLight, byte *dataSky, byte bitsPerBlock,
diff --git a/src/world/World.cpp b/src/world/World.cpp
index adbb3e1..af76fd5 100644
--- a/src/world/World.cpp
+++ b/src/world/World.cpp
@@ -1,5 +1,5 @@
-#include <iostream>
#include <bitset>
+#include <easylogging++.h>
#include "World.hpp"
void World::ParseChunkData(Packet packet) {
@@ -22,22 +22,17 @@ void World::ParseChunkData(Packet packet) {
if (bitmask[i]) {
size_t len = 0;
Vector chunkPosition = Vector(chunkX, i, chunkZ);
- if (!m_sections.insert(std::make_pair(chunkPosition,ParseSection(content,len))).second)
- std::cout<<"Chunk not created: "<<chunkPosition<<std::endl;
+ if (!m_sections.insert(std::make_pair(chunkPosition, ParseSection(content, len))).second)
+ LOG(ERROR) << "Chunk not created: " << chunkPosition;
auto sectionIter = m_sections.find(chunkPosition);
- if (sectionIter==m_sections.end())
- std::cout<<"Created chunk not found: "<<chunkPosition<<std::endl;
+ if (sectionIter == m_sections.end())
+ LOG(ERROR)<< "Created chunk not found: " << chunkPosition;
else
sectionIter->second.Parse();
- /*m_sections[chunkPosition] = ParseSection(content, len);
- m_sections[chunkPosition].Parse();*/
- /*m_sectionToParse.push(m_sections.find(Vector(chunkX, i, chunkZ)));
- m_parseSectionWaiter.notify_one();*/
content += len;
}
}
delete[] contentOrigPtr;
- //std::cout<<m_sections.size()<<std::endl;
}
Section World::ParseSection(byte *data, size_t &dataLen) {
@@ -105,8 +100,6 @@ void World::SectionParsingThread() {
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;*/
}
}
}