diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-06-21 16:26:25 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-06-21 16:26:25 +0200 |
commit | f5aa7827af55342a1ec714d366944b3e3f3129b2 (patch) | |
tree | 4f4885d2ae0f46004a22e7d4dc34f80c11ecee0c /src/world | |
parent | 2017-06-20 (diff) | |
download | AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.tar AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.tar.gz AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.tar.bz2 AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.tar.lz AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.tar.xz AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.tar.zst AltCraft-f5aa7827af55342a1ec714d366944b3e3f3129b2.zip |
Diffstat (limited to '')
-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) | 17 | ||||
-rw-r--r-- | include/world/World.hpp (renamed from src/world/World.hpp) | 16 | ||||
-rw-r--r-- | src/world/Block.cpp | 2 | ||||
-rw-r--r-- | src/world/Collision.cpp | 2 | ||||
-rw-r--r-- | src/world/GameState.cpp (renamed from src/gamestate/GameState.cpp) | 2 | ||||
-rw-r--r-- | src/world/Section.cpp | 16 | ||||
-rw-r--r-- | src/world/World.cpp | 8 |
9 files changed, 37 insertions, 26 deletions
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 657fc13..139b5b5 100644 --- a/src/world/Section.hpp +++ b/include/world/Section.hpp @@ -3,10 +3,12 @@ #include <vector> #include <map> #include <condition_variable> + #include <easylogging++.h> -#include "Block.hpp" -#include "../utility/Vector.hpp" -#include "../utility/utility.h" + +#include <world/Block.hpp> +#include <Vector.hpp> +#include <Utility.hpp> const int SECTION_WIDTH = 16; const int SECTION_LENGTH = 16; @@ -24,11 +26,13 @@ class Section { Section(); + Vector worldPosition; + public: void Parse(); - Section(byte *dataBlocks, size_t dataBlocksLength, byte *dataLight, byte *dataSky, byte bitsPerBlock, - std::vector<unsigned short> palette); + Section(Vector position, byte *dataBlocks, size_t dataBlocksLength, byte *dataLight, byte *dataSky, byte bitsPerBlock, + std::vector<unsigned short> palette); ~Section(); @@ -36,8 +40,9 @@ public: Section &operator=(Section other); - friend void swap(Section &a, Section& b); + friend void swap(Section &a, Section &b); Section(const Section &other); + Vector GetPosition(); };
\ No newline at end of file diff --git a/src/world/World.hpp b/include/world/World.hpp index e315baf..6e5eedb 100644 --- a/src/world/World.hpp +++ b/include/world/World.hpp @@ -1,16 +1,14 @@ #pragma once #include <map> -#include <thread> -#include <mutex> -#include <condition_variable> -#include <queue> #include <bitset> + #include <easylogging++.h> -#include "Block.hpp" -#include "Section.hpp" -#include "../network/Packet.hpp" -#include "Collision.hpp" + +#include <world/Block.hpp> +#include <world/Section.hpp> +#include <network/Packet.hpp> +#include <world/Collision.hpp> class World { //utility vars @@ -22,7 +20,7 @@ class World { int dimension = 0; //game methods - Section ParseSection(StreamInput *data); + Section ParseSection(StreamInput *data, Vector position); public: World(); diff --git a/src/world/Block.cpp b/src/world/Block.cpp index e88068a..74ac406 100644 --- a/src/world/Block.cpp +++ b/src/world/Block.cpp @@ -1,4 +1,4 @@ -#include "Block.hpp" +#include <world/Block.hpp> Block::~Block() {} diff --git a/src/world/Collision.cpp b/src/world/Collision.cpp index 4f2c837..8fc562b 100644 --- a/src/world/Collision.cpp +++ b/src/world/Collision.cpp @@ -1,4 +1,4 @@ -#include "Collision.hpp" +#include <world/Collision.hpp> bool TestCollision(AABB first, AABB second) { double firstXl = first.x; diff --git a/src/gamestate/GameState.cpp b/src/world/GameState.cpp index 316d5f1..b484b06 100644 --- a/src/gamestate/GameState.cpp +++ b/src/world/GameState.cpp @@ -1,4 +1,4 @@ -#include "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 8f94ad7..a338e49 100644 --- a/src/world/Section.cpp +++ b/src/world/Section.cpp @@ -1,8 +1,11 @@ -#include "Section.hpp" +#include <world/Section.hpp> -Section::Section(byte *dataBlocks, size_t dataBlocksLength, byte *dataLight, byte *dataSky, byte bitsPerBlock, +Section::Section(Vector position, byte *dataBlocks, size_t dataBlocksLength, byte *dataLight, byte *dataSky, + byte bitsPerBlock, std::vector<unsigned short> palette) { + worldPosition = position; + m_dataBlocksLen = dataBlocksLength; m_dataBlocks = new byte[m_dataBlocksLen]; std::copy(dataBlocks, dataBlocks + m_dataBlocksLen, m_dataBlocks); @@ -97,7 +100,7 @@ void Section::Parse() { } Section &Section::operator=(Section other) { - std::swap(*this,other); + std::swap(*this, other); return *this; } @@ -113,6 +116,7 @@ void swap(Section &a, Section &b) { } Section::Section(const Section &other) { + worldPosition = other.worldPosition; m_dataBlocksLen = other.m_dataBlocksLen; m_dataBlocks = new byte[m_dataBlocksLen]; std::copy(other.m_dataBlocks, other.m_dataBlocks + m_dataBlocksLen, m_dataBlocks); @@ -127,4 +131,8 @@ Section::Section(const Section &other) { m_palette = other.m_palette; m_bitsPerBlock = other.m_bitsPerBlock; -}
\ No newline at end of file +} + +Vector Section::GetPosition() { + return worldPosition; +} diff --git a/src/world/World.cpp b/src/world/World.cpp index 394598b..abcfebf 100644 --- a/src/world/World.cpp +++ b/src/world/World.cpp @@ -1,4 +1,4 @@ -#include "World.hpp" +#include <world/World.hpp> void World::ParseChunkData(std::shared_ptr<PacketChunkData> packet) { StreamBuffer chunkData(packet->Data.data(), packet->Data.size()); @@ -6,7 +6,7 @@ void World::ParseChunkData(std::shared_ptr<PacketChunkData> packet) { for (int i = 0; i < 16; i++) { if (bitmask[i]) { Vector chunkPosition = Vector(packet->ChunkX, i, packet->ChunkZ); - Section section = ParseSection(&chunkData); + Section section = ParseSection(&chunkData, chunkPosition); auto it = sections.find(chunkPosition); if (it == sections.end()) { sections.insert(std::make_pair(chunkPosition, section)); @@ -19,7 +19,7 @@ void World::ParseChunkData(std::shared_ptr<PacketChunkData> packet) { } } -Section World::ParseSection(StreamInput *data) { +Section World::ParseSection(StreamInput *data, Vector position) { unsigned char bitsPerBlock = data->ReadUByte(); int paletteLength = data->ReadVarInt(); std::vector<unsigned short> palette; @@ -32,7 +32,7 @@ Section World::ParseSection(StreamInput *data) { std::vector<unsigned char> skyLight; if (dimension == 0) skyLight = data->ReadByteArray(4096 / 2); - return Section(dataArray.data(), dataArray.size(), blockLight.data(), + return Section(position, dataArray.data(), dataArray.size(), blockLight.data(), (skyLight.size() > 0 ? skyLight.data() : nullptr), bitsPerBlock, palette); } |