summaryrefslogtreecommitdiffstats
path: root/src/world
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/GameState.hpp (renamed from src/world/GameState.hpp)0
-rw-r--r--include/world/Block.hpp (renamed from src/world/Block.hpp)0
-rw-r--r--include/world/Collision.hpp (renamed from src/world/Collision.hpp)0
-rw-r--r--include/world/Section.hpp (renamed from src/world/Section.hpp)3
-rw-r--r--include/world/World.hpp (renamed from src/world/World.hpp)0
-rw-r--r--src/world/GameState.cpp2
-rw-r--r--src/world/Section.cpp50
7 files changed, 19 insertions, 36 deletions
diff --git a/src/world/GameState.hpp b/include/GameState.hpp
index 6741882..6741882 100644
--- a/src/world/GameState.hpp
+++ b/include/GameState.hpp
diff --git a/src/world/Block.hpp b/include/world/Block.hpp
index 2f823fe..2f823fe 100644
--- a/src/world/Block.hpp
+++ b/include/world/Block.hpp
diff --git a/src/world/Collision.hpp b/include/world/Collision.hpp
index b88fbf7..b88fbf7 100644
--- a/src/world/Collision.hpp
+++ b/include/world/Collision.hpp
diff --git a/src/world/Section.hpp b/include/world/Section.hpp
index 2df0cfe..139b5b5 100644
--- a/src/world/Section.hpp
+++ b/include/world/Section.hpp
@@ -3,7 +3,6 @@
#include <vector>
#include <map>
#include <condition_variable>
-#include <functional>
#include <easylogging++.h>
@@ -46,6 +45,4 @@ public:
Section(const Section &other);
Vector GetPosition();
-
- size_t GetHash();
}; \ No newline at end of file
diff --git a/src/world/World.hpp b/include/world/World.hpp
index 6b09f1f..6b09f1f 100644
--- a/src/world/World.hpp
+++ b/include/world/World.hpp
diff --git a/src/world/GameState.cpp b/src/world/GameState.cpp
index d3a6bd3..79e2f1b 100644
--- a/src/world/GameState.cpp
+++ b/src/world/GameState.cpp
@@ -1,4 +1,4 @@
-#include <world/GameState.hpp>
+#include <GameState.hpp>
GameState::GameState(NetworkClient *Net, bool &quit) : nc(Net), isRunning(quit) {
Front = glm::vec3(0.0f, 0.0f, -1.0f);
diff --git a/src/world/Section.cpp b/src/world/Section.cpp
index ff2a4fb..d97d163 100644
--- a/src/world/Section.cpp
+++ b/src/world/Section.cpp
@@ -36,10 +36,8 @@ Block &Section::GetBlock(Vector pos) {
return m_blocks[pos.GetY() * 256 + pos.GetZ() * 16 + pos.GetX()];
}
-double totalParsingTime = 0;
-
void Section::Parse() {
- if (!m_blocks.empty())
+ if (m_dataBlocks == nullptr)
return;
long long *longArray = reinterpret_cast<long long *>(m_dataBlocks);
@@ -47,28 +45,23 @@ void Section::Parse() {
endswap(&longArray[i]);
std::vector<unsigned short> blocks;
blocks.reserve(4096);
- {
- auto begin = std::chrono::steady_clock::now();
- int bitPos = 0;
- unsigned short t = 0;
- 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;
- m_dataBlocks[i] >>= 1;
- bitPos++;
- if (bitPos >= m_bitsPerBlock) {
- bitPos = 0;
- t >>= m_bitsPerBlock - 1;
- blocks.push_back(t);
- t = 0;
- }
+ int bitPos = 0;
+ unsigned short t = 0;
+ 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;
+ m_dataBlocks[i] >>= 1;
+ bitPos++;
+ if (bitPos >= m_bitsPerBlock) {
+ bitPos = 0;
+ t >>= m_bitsPerBlock - 1;
+ blocks.push_back(t);
+ t = 0;
}
}
- auto end = std::chrono::steady_clock::now();
- std::chrono::duration<double, std::milli> time = end - begin;
- totalParsingTime += time.count();
}
+
std::vector<byte> light;
light.reserve(4096);
for (int i = 0; i < 2048; i++) {
@@ -83,6 +76,9 @@ void Section::Parse() {
Block block(blockId >> 4, blockId & 0xF);
m_blocks.push_back(block);
}
+ if ((light.size() + blocks.size()) / 2 != 4096) {
+ throw 118;
+ }
delete[] m_dataBlocks;
m_dataBlocksLen = 0;
m_dataBlocks = nullptr;
@@ -135,13 +131,3 @@ Section::Section(const Section &other) {
Vector Section::GetPosition() {
return worldPosition;
}
-
-size_t Section::GetHash() {
- if (m_blocks.empty()) return 0;
-
- unsigned char *from = reinterpret_cast<unsigned char *>(m_blocks.data());
- size_t length = m_blocks.size() * sizeof(Block);
-
- std::string str(from, from + length);
- return std::hash<std::string>{}(str);
-} \ No newline at end of file