summaryrefslogtreecommitdiffstats
path: root/src/world
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-31 16:17:09 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-31 16:17:09 +0200
commitf721ed0e3c6be33670fe330c029a2d4c3353f635 (patch)
tree5afad5a292171d546d9ded16de6151a014883d84 /src/world
parent2017-05-28 (diff)
downloadAltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar
AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.gz
AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.bz2
AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.lz
AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.xz
AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.tar.zst
AltCraft-f721ed0e3c6be33670fe330c029a2d4c3353f635.zip
Diffstat (limited to '')
-rw-r--r--src/world/Block.cpp2
-rw-r--r--src/world/Block.hpp2
-rw-r--r--src/world/Section.cpp17
-rw-r--r--src/world/Section.hpp1
-rw-r--r--src/world/World.cpp8
-rw-r--r--src/world/World.hpp2
6 files changed, 22 insertions, 10 deletions
diff --git a/src/world/Block.cpp b/src/world/Block.cpp
index 54b7e5e..74423e0 100644
--- a/src/world/Block.cpp
+++ b/src/world/Block.cpp
@@ -2,7 +2,7 @@
Block::~Block() {}
-Block::Block(unsigned short id, unsigned short state, unsigned char light) : id(id), state(state) {}
+Block::Block(unsigned short id, unsigned short state) : id(id), state(state) {}
Block::Block() : id(0), state(0) {}
diff --git a/src/world/Block.hpp b/src/world/Block.hpp
index 1a53868..50268f3 100644
--- a/src/world/Block.hpp
+++ b/src/world/Block.hpp
@@ -3,7 +3,7 @@
struct Block {
Block();
- Block(unsigned short id, unsigned short state = 0, unsigned char light = 0);
+ Block(unsigned short id, unsigned short state);
~Block();
diff --git a/src/world/Section.cpp b/src/world/Section.cpp
index 5c42ea5..6147295 100644
--- a/src/world/Section.cpp
+++ b/src/world/Section.cpp
@@ -36,6 +36,7 @@ Block &Section::GetBlock(Vector pos) {
while (m_dataBlocks != nullptr) {
parseWaiter.wait(parseLocker);
}
+ LOG(WARNING)<<"Successfully waited for block render!";
}
return m_blocks[pos.GetY() * 256 + pos.GetZ() * 16 + pos.GetX()];
}
@@ -45,13 +46,13 @@ void Section::Parse() {
return;
long long *longArray = reinterpret_cast<long long *>(m_dataBlocks);
- for (int i = 0; i < m_dataBlocksLen / 8; i++)
+ for (size_t i = 0; i < m_dataBlocksLen / 8; i++)
endswap(&longArray[i]);
std::vector<unsigned short> blocks;
blocks.reserve(4096);
int bitPos = 0;
unsigned short t = 0;
- for (int i = 0; i < m_dataBlocksLen; i++) {
+ 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;
@@ -77,7 +78,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, 0, light[i]);
+ Block block(blockId>>4, blockId>>4 & 0xF);
m_blocks.push_back(block);
}
if ((light.size() + blocks.size()) / 2 != 4096) {
@@ -90,7 +91,17 @@ void Section::Parse() {
m_dataLight = nullptr;
delete[] m_dataSkyLight;
m_dataSkyLight = nullptr;
+
parseWaiter.notify_all();
+ /*static std::map<Block,int> totalBlocks;
+ for (int x=0;x<16;x++)
+ for (int y=0;y<16;y++)
+ for (int z=0;z<16;z++)
+ totalBlocks[GetBlock(Vector(x,y,z))]++;
+ LOG(ERROR)<<"Logging chunk";
+ for (auto& it:totalBlocks){
+ LOG(WARNING)<<it.first.id<<":"<<(int)it.first.state<<" = "<<it.second;
+ }*/
}
Section &Section::operator=(Section other) {
diff --git a/src/world/Section.hpp b/src/world/Section.hpp
index 3065cbd..36fc91a 100644
--- a/src/world/Section.hpp
+++ b/src/world/Section.hpp
@@ -3,6 +3,7 @@
#include <vector>
#include <map>
#include <condition_variable>
+#include <easylogging++.h>
#include "Block.hpp"
#include "../packet/Field.hpp"
diff --git a/src/world/World.cpp b/src/world/World.cpp
index d13d01d..121b904 100644
--- a/src/world/World.cpp
+++ b/src/world/World.cpp
@@ -1,5 +1,3 @@
-#include <bitset>
-#include <easylogging++.h>
#include "World.hpp"
void World::ParseChunkData(Packet packet) {
@@ -43,7 +41,7 @@ Section World::ParseSection(byte *data, size_t &dataLen) {
data += fBitsPerBlock.GetLength();
dataLen += fBitsPerBlock.GetLength();
- Field fPaletteLength = FieldParser::Parse(VarInt, data);
+ Field fPaletteLength = FieldParser::Parse(VarIntType, data);
int paletteLength = fPaletteLength.GetVarInt();
data += fPaletteLength.GetLength();
dataLen += fPaletteLength.GetLength();
@@ -52,7 +50,7 @@ Section World::ParseSection(byte *data, size_t &dataLen) {
if (paletteLength > 0) {
for (unsigned char i = 0; i < paletteLength; i++) {
endswap(&i);
- Field f = FieldParser::Parse(VarInt, data);
+ Field f = FieldParser::Parse(VarIntType, data);
data += f.GetLength();
dataLen += f.GetLength();
palette.push_back(f.GetVarInt());
@@ -60,7 +58,7 @@ Section World::ParseSection(byte *data, size_t &dataLen) {
}
}
- Field fDataLength = FieldParser::Parse(VarInt, data);
+ Field fDataLength = FieldParser::Parse(VarIntType, data);
data += fDataLength.GetLength();
dataLen += fDataLength.GetLength();
diff --git a/src/world/World.hpp b/src/world/World.hpp
index cef9eea..b33499c 100644
--- a/src/world/World.hpp
+++ b/src/world/World.hpp
@@ -5,6 +5,8 @@
#include <mutex>
#include <condition_variable>
#include <queue>
+#include <bitset>
+#include <easylogging++.h>
#include "Block.hpp"
#include "../packet/Packet.hpp"
#include "Section.hpp"