summaryrefslogtreecommitdiffstats
path: root/src/world
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-28 16:16:05 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-28 16:16:05 +0200
commitd93c2073896e63aca5a859fe7182ba24dbe84cd3 (patch)
tree6144aaf7e01854fe245011ca4f4735974366febb /src/world
parent2017-05-26 (diff)
downloadAltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.gz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.bz2
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.lz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.xz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.zst
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.zip
Diffstat (limited to '')
-rw-r--r--src/world/Block.cpp4
-rw-r--r--src/world/Block.hpp4
-rw-r--r--src/world/Section.cpp2
-rw-r--r--src/world/World.cpp20
-rw-r--r--src/world/World.hpp18
5 files changed, 13 insertions, 35 deletions
diff --git a/src/world/Block.cpp b/src/world/Block.cpp
index 3cf09db..54b7e5e 100644
--- a/src/world/Block.cpp
+++ b/src/world/Block.cpp
@@ -2,9 +2,7 @@
Block::~Block() {}
-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) {}
+Block::Block(unsigned short id, unsigned short state, unsigned char light) : id(id), state(state) {}
Block::Block() : id(0), state(0) {}
diff --git a/src/world/Block.hpp b/src/world/Block.hpp
index ae952c9..1a53868 100644
--- a/src/world/Block.hpp
+++ b/src/world/Block.hpp
@@ -3,9 +3,7 @@
struct Block {
Block();
- Block(unsigned short idAndState, unsigned char light);
-
- Block(unsigned short id, unsigned char state, unsigned char light);
+ Block(unsigned short id, unsigned short state = 0, unsigned char light = 0);
~Block();
diff --git a/src/world/Section.cpp b/src/world/Section.cpp
index ac34fba..5c42ea5 100644
--- a/src/world/Section.cpp
+++ b/src/world/Section.cpp
@@ -77,7 +77,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, light[i]);
+ Block block(blockId, 0, light[i]);
m_blocks.push_back(block);
}
if ((light.size() + blocks.size()) / 2 != 4096) {
diff --git a/src/world/World.cpp b/src/world/World.cpp
index af76fd5..d13d01d 100644
--- a/src/world/World.cpp
+++ b/src/world/World.cpp
@@ -84,27 +84,9 @@ Section World::ParseSection(byte *data, size_t &dataLen) {
}
World::~World() {
- isContinue = false;
- m_parseSectionWaiter.notify_all();
- m_sectionParseThread.join();
-}
-
-void World::SectionParsingThread() {
- while (isContinue) {
- std::unique_lock<std::mutex> sectionParseLocker(m_parseSectionMutex);
- m_parseSectionWaiter.wait(sectionParseLocker);
- while (m_sectionToParse.size() == 0 && isContinue) {
- m_parseSectionWaiter.wait(sectionParseLocker);
- }
- while (m_sectionToParse.size() > 0) {
- auto it = m_sectionToParse.front();
- m_sectionToParse.pop();
- it->second.Parse();
- }
- }
}
World::World() {
- m_sectionParseThread = std::thread(&World::SectionParsingThread, this);
+
}
diff --git a/src/world/World.hpp b/src/world/World.hpp
index 7b7ea60..cef9eea 100644
--- a/src/world/World.hpp
+++ b/src/world/World.hpp
@@ -11,22 +11,22 @@
class World {
//utility vars
- World(const World& other);
- World&operator=(const World &other);
- bool isContinue=true;
- std::mutex m_parseSectionMutex;
- std::condition_variable m_parseSectionWaiter;
- std::thread m_sectionParseThread;
- std::queue<std::map<Vector,Section>::iterator> m_sectionToParse;
- //utility methods
- void SectionParsingThread();
+ World(const World &other);
+
+ World &operator=(const World &other);
+
//game vars
int m_dimension = 0;
+
//game methods
Section ParseSection(byte *data, size_t &dataLen);
+
public:
World();
+
~World();
+
void ParseChunkData(Packet packet);
+
std::map<Vector, Section> m_sections;
}; \ No newline at end of file