From 8ac4fe6d5ba5091923c7fdf1fa88724d827706fa Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Fri, 26 May 2017 19:11:17 +0500 Subject: 2017-05-26 --- src/core/AssetManager.cpp | 70 ++++++++++++++++++ src/core/AssetManager.hpp | 33 +++++++++ src/core/Core.cpp | 9 +-- src/core/Core.hpp | 3 +- src/gamestate/GameState.cpp | 2 +- src/graphics/AssetManager.cpp | 146 -------------------------------------- src/graphics/AssetManager.hpp | 52 -------------- src/graphics/AssetManager_old.cpp | 146 ++++++++++++++++++++++++++++++++++++++ src/graphics/AssetManager_old.hpp | 53 ++++++++++++++ src/graphics/Display.cpp | 6 +- src/graphics/Shader.cpp | 11 +-- src/graphics/Shader.hpp | 1 - src/graphics/Texture.cpp | 10 +-- src/main.cpp | 15 +++- src/nbt/Nbt.hpp | 1 - src/network/Network.cpp | 1 - src/world/Block.cpp | 17 +++-- src/world/Block.hpp | 10 +-- src/world/Section.cpp | 1 - src/world/World.cpp | 17 ++--- 20 files changed, 357 insertions(+), 247 deletions(-) create mode 100644 src/core/AssetManager.cpp create mode 100644 src/core/AssetManager.hpp delete mode 100644 src/graphics/AssetManager.cpp delete mode 100644 src/graphics/AssetManager.hpp create mode 100644 src/graphics/AssetManager_old.cpp create mode 100644 src/graphics/AssetManager_old.hpp (limited to 'src') diff --git a/src/core/AssetManager.cpp b/src/core/AssetManager.cpp new file mode 100644 index 0000000..9913c18 --- /dev/null +++ b/src/core/AssetManager.cpp @@ -0,0 +1,70 @@ +#include +#include +#include "AssetManager.hpp" + +namespace fs = std::experimental::filesystem; + +const fs::path pathToAssets = "./assets/"; +const fs::path pathToAssetsList = "./items.json"; +const fs::path pathToTextureIndex = "./textures.json"; + +AssetManager::AssetManager() { + for (auto &it:fs::recursive_directory_iterator(pathToAssets)) { + + } + LoadIds(); + LoadTextureResources(); +} + +void AssetManager::LoadIds() { + std::ifstream in(pathToAssetsList); + nlohmann::json index; + in >> index; + for (auto &it:index) { + int id = it["type"].get(); + int state = it["meta"].get(); + std::string blockName = it["text_type"].get(); + assetIds[blockName] = Block(id, state, 0); + } + LOG(INFO) << "Loaded " << assetIds.size() << " ids"; +} + +AssetManager::~AssetManager() { + delete textureAtlas; +} + +//TODO: This function must be replaced with runtime texture atlas generating +void AssetManager::LoadTextureResources() { + std::ifstream in(pathToTextureIndex); + nlohmann::json index; + in >> index; + std::string filename = index["meta"]["image"].get(); + for (auto &it:index["frames"]) { + auto frame = it["frame"]; + TextureCoord coord; + coord.x = frame["x"].get(); + coord.y = frame["y"].get(); + coord.w = frame["w"].get(); + coord.h = frame["h"].get(); + std::string assetName = it["filename"].get(); + assetName.insert(0,"minecraft/textures/"); + assetName.erase(assetName.length()-4); + LOG(ERROR)<texture; +} + +TextureCoord AssetManager::GetTextureByAssetName(std::string AssetName) { + return TextureCoord{0, 0, 0, 0}; +} + +std::string AssetManager::GetTextureAssetNameByBlockId(unsigned short BlockId, unsigned char BlockSide) { + +} + +const GLuint AssetManager::GetTextureAtlas() { + return textureAtlas->texture; +} diff --git a/src/core/AssetManager.hpp b/src/core/AssetManager.hpp new file mode 100644 index 0000000..23b2ba6 --- /dev/null +++ b/src/core/AssetManager.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "../world/Block.hpp" +#include "../graphics/Texture.hpp" + +struct TextureCoord{ + unsigned int x,y,w,h; +}; + +class AssetManager { + Texture *textureAtlas; + std::map assetIds; + std::map assetTextures; +public: + AssetManager(); + + ~AssetManager(); + + void LoadTextureResources(); + + TextureCoord GetTextureByAssetName(std::string AssetName); + + std::string GetTextureAssetNameByBlockId(unsigned short BlockId, unsigned char BlockSide = 0); + + const GLuint GetTextureAtlas(); + + void LoadIds(); +}; diff --git a/src/core/Core.cpp b/src/core/Core.cpp index 54a16a4..7814c32 100644 --- a/src/core/Core.cpp +++ b/src/core/Core.cpp @@ -108,6 +108,7 @@ Core::Core() { gameState = new GameState(client); std::thread loop = std::thread(&Core::UpdateGameState,this); std::swap(loop,gameStateLoopThread); + assetManager = new AssetManager; LOG(INFO) << "Core is initialized"; } @@ -291,13 +292,8 @@ void Core::RenderWorld(World &Target) { glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); glUniform1i(blockLoc, block.id); - std::string textureName = AssetManager::GetAssetNameByBlockId(block.id); - if (textureName.find("air") != std::string::npos) - continue; - Texture &texture1 = *(AssetManager::GetAsset(textureName).data.texture); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, texture1.texture); + //glBindTexture(GL_TEXTURE_2D, texture1.texture); glUniform1i(glGetUniformLocation(shader->Program, "blockTexture"), 0); glDrawArrays(GL_TRIANGLES, 0, 36); @@ -316,7 +312,6 @@ void Core::SetMouseCapture(bool IsCaptured) { } void Core::PrepareToWorldRendering() { - glGenBuffers(1, &VBO); glGenBuffers(1, &VBO2); glGenVertexArrays(1, &VAO); diff --git a/src/core/Core.hpp b/src/core/Core.hpp index a877613..1c2bbc5 100644 --- a/src/core/Core.hpp +++ b/src/core/Core.hpp @@ -10,12 +10,13 @@ #include "../gui/Gui.hpp" #include "../graphics/Camera3D.hpp" #include "../graphics/Shader.hpp" -#include "../graphics/AssetManager.hpp" +#include "AssetManager.hpp" class Core { GameState *gameState; NetworkClient *client; sf::Window *window; + AssetManager *assetManager; bool isMouseCaptured = false, isRunning = true; enum { MainMenu, diff --git a/src/gamestate/GameState.cpp b/src/gamestate/GameState.cpp index aaeecb1..7b6734f 100644 --- a/src/gamestate/GameState.cpp +++ b/src/gamestate/GameState.cpp @@ -40,7 +40,7 @@ void GameState::Update() { break; case 0x0D: g_Difficulty = packet.GetField(0).GetUByte(); - std::cout << "Difficulty now is " << (int) g_Difficulty << std::endl; + LOG(INFO) << "Difficulty now is " << (int) g_Difficulty; break; case 0x43: g_SpawnPosition = packet.GetField(0).GetPosition(); diff --git a/src/graphics/AssetManager.cpp b/src/graphics/AssetManager.cpp deleted file mode 100644 index 93462c3..0000000 --- a/src/graphics/AssetManager.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "AssetManager.hpp" - -const std::string pathToAssets = "./assets/"; -const std::string pathToObjects = pathToAssets + "objects/"; -const std::string pathToIndexFile = pathToAssets + "indexes/1.11.json"; -const std::string pathToAssetsMc = "./assetsMc/"; -const std::map assetTypeFileExtensions{ - std::make_pair(Asset::AssetType::Texture, ".png"), - std::make_pair(Asset::AssetType::Lang, ".lang"), - std::make_pair(Asset::AssetType::Sound, ".ogg"), -}; - -AssetManager::AssetManager() { - return; - std::ifstream indexFile(pathToIndexFile); - if (!indexFile) { - std::cerr << "Can't open file " << pathToIndexFile << std::endl; - } - nlohmann::json json = nlohmann::json::parse(indexFile)["objects"]; - for (auto it = json.begin(); it != json.end(); ++it) { - size_t fileNameExtensionPos = -1; - std::string name = it.key(); - Asset::AssetType type = Asset::Unknown; - for (auto &it:assetTypeFileExtensions) { - if ((fileNameExtensionPos = name.find(it.second)) != std::string::npos) { - type = it.first; - name = name.substr(0, fileNameExtensionPos); - break; - } - } - std::string hash = it.value()["hash"].get(); - size_t size = it.value()["size"].get(); - Asset asset{name, hash, Asset::AssetData(), size, type}; - this->assets[name] = asset; - } -} - -AssetManager::~AssetManager() { - -} - -Asset &AssetManager::GetAsset(std::string AssetName) { - if (instance().assets.find(AssetName) == instance().assets.end() || !instance().assets[AssetName].isParsed()) - LoadAsset(AssetName); - return instance().assets[AssetName]; -} - -void AssetManager::LoadAsset(std::string AssetName) { - if (instance().assets.find(AssetName) != instance().assets.end() && instance().assets[AssetName].isParsed()) - return; - std::string AssetFileName = GetPathToAsset(AssetName); - Asset &asset = instance().assets[AssetName]; - - - if (asset.type == Asset::Texture) { - asset.data.texture = new Texture(AssetFileName,GL_CLAMP_TO_BORDER,GL_NEAREST); - //asset.data.texture.loadFromFile((asset.name + assetTypeFileExtensions.at(asset.type))); - } -} - -std::string AssetManager::GetPathToAsset(std::string AssetName) { - if (instance().assets.find(AssetName) != instance().assets.end()){ - auto it = instance().assets.find(AssetName); - return pathToObjects + std::string(instance().assets[AssetName].hash.c_str(), 2) + "/" + - instance().assets[AssetName].hash; - } - - instance().assets[AssetName].hash=""; - instance().assets[AssetName].type=Asset::AssetType::Texture; - instance().assets[AssetName].name=AssetName; - instance().assets[AssetName].size=0; - return pathToAssetsMc + "" + instance().assets[AssetName].name + - assetTypeFileExtensions.at(instance().assets[AssetName].type); -} - -std::string AssetManager::GetAssetNameByBlockId(unsigned short id) { - std::string assetBase = "minecraft/textures/blocks/"; - std::string textureName; - switch (id){ - case 0: - textureName="air"; - break; - case 1: - textureName="stone"; - break; - case 2: - textureName="grass"; - break; - case 3: - textureName="dirt"; - break; - case 4: - textureName="cobblestone"; - break; - case 16: - textureName="coal_ore"; - break; - case 17: - textureName="log_oak"; - break; - case 31: - textureName="air"; - break; - default: - //std::cout<data.texture != nullptr; - break; - case Sound: - return false; - break; - case Model: - return false; - break; - case Lang: - return false; - break; - } -} - -Asset::~Asset() { - switch (type) { - case Unknown: - break; - case Texture: - delete this->data.texture; - break; - case Sound: - break; - case Model: - break; - case Lang: - break; - } -} diff --git a/src/graphics/AssetManager.hpp b/src/graphics/AssetManager.hpp deleted file mode 100644 index e723398..0000000 --- a/src/graphics/AssetManager.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "Texture.hpp" - -struct Asset { - std::string name = ""; - std::string hash = ""; - union AssetData{ - Texture *texture; - } data; - size_t size = 0; - enum AssetType { - Unknown, - Texture, - Sound, - Model, - Lang, - } type = Unknown; - bool isParsed(); - ~Asset(); -}; - -class AssetManager { - AssetManager(); - - ~AssetManager(); - - AssetManager(const AssetManager &); - - AssetManager &operator=(const AssetManager &); - - std::map assets; - - static AssetManager &instance() { - static AssetManager assetManager; - return assetManager; - } - - static std::string GetPathToAsset(std::string AssetName); -public: - - static Asset &GetAsset(std::string AssetName); - - static void LoadAsset(std::string AssetName); - - static std::string GetAssetNameByBlockId(unsigned short id); -}; - diff --git a/src/graphics/AssetManager_old.cpp b/src/graphics/AssetManager_old.cpp new file mode 100644 index 0000000..ef856ca --- /dev/null +++ b/src/graphics/AssetManager_old.cpp @@ -0,0 +1,146 @@ +#include "AssetManager_old.hpp" + +const std::string pathToAssets = "./assets/"; +const std::string pathToObjects = pathToAssets + "objects/"; +const std::string pathToIndexFile = pathToAssets + "indexes/1.11.json"; +const std::string pathToAssetsMc = "./assets/"; +const std::map assetTypeFileExtensions{ + std::make_pair(Asset::AssetType::Texture, ".png"), + std::make_pair(Asset::AssetType::Lang, ".lang"), + std::make_pair(Asset::AssetType::Sound, ".ogg"), +}; + +AssetManager_old::AssetManager_old() { + return; + std::ifstream indexFile(pathToIndexFile); + if (!indexFile) { + std::cerr << "Can't open file " << pathToIndexFile << std::endl; + } + nlohmann::json json = nlohmann::json::parse(indexFile)["objects"]; + for (auto it = json.begin(); it != json.end(); ++it) { + size_t fileNameExtensionPos = -1; + std::string name = it.key(); + Asset::AssetType type = Asset::Unknown; + for (auto &it:assetTypeFileExtensions) { + if ((fileNameExtensionPos = name.find(it.second)) != std::string::npos) { + type = it.first; + name = name.substr(0, fileNameExtensionPos); + break; + } + } + std::string hash = it.value()["hash"].get(); + size_t size = it.value()["size"].get(); + Asset asset{name, hash, Asset::AssetData(), size, type}; + this->assets[name] = asset; + } +} + +AssetManager_old::~AssetManager_old() { + +} + +Asset &AssetManager_old::GetAsset(std::string AssetName) { + if (instance().assets.find(AssetName) == instance().assets.end() || !instance().assets[AssetName].isParsed()) + LoadAsset(AssetName); + return instance().assets[AssetName]; +} + +void AssetManager_old::LoadAsset(std::string AssetName) { + if (instance().assets.find(AssetName) != instance().assets.end() && instance().assets[AssetName].isParsed()) + return; + std::string AssetFileName = GetPathToAsset(AssetName); + Asset &asset = instance().assets[AssetName]; + + + if (asset.type == Asset::Texture) { + asset.data.texture = new Texture(AssetFileName,GL_CLAMP_TO_BORDER,GL_NEAREST); + //asset.data.texture.loadFromFile((asset.name + assetTypeFileExtensions.at(asset.type))); + } +} + +std::string AssetManager_old::GetPathToAsset(std::string AssetName) { + if (instance().assets.find(AssetName) != instance().assets.end()){ + auto it = instance().assets.find(AssetName); + return pathToObjects + std::string(instance().assets[AssetName].hash.c_str(), 2) + "/" + + instance().assets[AssetName].hash; + } + + instance().assets[AssetName].hash=""; + instance().assets[AssetName].type=Asset::AssetType::Texture; + instance().assets[AssetName].name=AssetName; + instance().assets[AssetName].size=0; + return pathToAssetsMc + "" + instance().assets[AssetName].name + + assetTypeFileExtensions.at(instance().assets[AssetName].type); +} + +std::string AssetManager_old::GetAssetNameByBlockId(unsigned short id) { + std::string assetBase = "minecraft/textures/blocks/"; + std::string textureName; + switch (id){ + case 0: + textureName="air"; + break; + case 1: + textureName="stone"; + break; + case 2: + textureName="grass"; + break; + case 3: + textureName="dirt"; + break; + case 4: + textureName="cobblestone"; + break; + case 16: + textureName="coal_ore"; + break; + case 17: + textureName="log_oak"; + break; + case 31: + textureName="air"; + break; + default: + //std::cout<data.texture != nullptr; + break; + case Sound: + return false; + break; + case Model: + return false; + break; + case Lang: + return false; + break; + } +} + +Asset::~Asset() { + switch (type) { + case Unknown: + break; + case Texture: + delete this->data.texture; + break; + case Sound: + break; + case Model: + break; + case Lang: + break; + } +} diff --git a/src/graphics/AssetManager_old.hpp b/src/graphics/AssetManager_old.hpp new file mode 100644 index 0000000..23a11a7 --- /dev/null +++ b/src/graphics/AssetManager_old.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "Texture.hpp" + +struct Asset { + std::string name = ""; + std::string hash = ""; + union AssetData{ + Texture *texture; + } data; + size_t size = 0; + enum AssetType { + Unknown, + Texture, + Sound, + Model, + Lang, + } type = Unknown; + bool isParsed(); + ~Asset(); +}; + +class AssetManager_old { + AssetManager_old(); + + ~AssetManager_old(); + + AssetManager_old(const AssetManager_old &); + + AssetManager_old &operator=(const AssetManager_old &); + + std::map assets; + + static AssetManager_old &instance() { + static AssetManager_old assetManager; + return assetManager; + } + + static std::string GetPathToAsset(std::string AssetName); +public: + + static Asset &GetAsset(std::string AssetName); + + static void LoadAsset(std::string AssetName); + + static std::string GetAssetNameByBlockId(unsigned short id); +}; + diff --git a/src/graphics/Display.cpp b/src/graphics/Display.cpp index 1a44fbc..63498fa 100644 --- a/src/graphics/Display.cpp +++ b/src/graphics/Display.cpp @@ -1,6 +1,6 @@ #include #include "Display.hpp" -#include "AssetManager.hpp" +#include "AssetManager_old.hpp" /*GLfloat vertices[] = { -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, @@ -329,10 +329,10 @@ void Display::MainLoop() { glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); glUniform1i(blockLoc, block.id); - std::string textureName = AssetManager::GetAssetNameByBlockId(block.id); + std::string textureName = AssetManager_old::GetAssetNameByBlockId(block.id); if (textureName.find("air") != std::string::npos) continue; - Texture &texture1 = *(AssetManager::GetAsset(textureName).data.texture); + Texture &texture1 = *(AssetManager_old::GetAsset(textureName).data.texture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture1.texture); diff --git a/src/graphics/Shader.cpp b/src/graphics/Shader.cpp index c84e169..9bb08ba 100644 --- a/src/graphics/Shader.cpp +++ b/src/graphics/Shader.cpp @@ -1,3 +1,4 @@ +#include #include "Shader.hpp" Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { @@ -27,7 +28,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { fragmentCode = fShaderStream.str(); } catch (std::ifstream::failure e) { - std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl; + LOG(ERROR) << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ"; } const GLchar *vShaderCode = vertexCode.c_str(); const GLchar *fShaderCode = fragmentCode.c_str(); @@ -46,7 +47,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { glGetShaderiv(vertex, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(vertex, 512, NULL, infoLog); - std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; + LOG(ERROR) << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog; }; // Вершинный шейдер @@ -57,7 +58,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { glGetShaderiv(fragment, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(fragment, 512, NULL, infoLog); - std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl; + LOG(ERROR) << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog; }; // Шейдерная программа @@ -69,7 +70,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { glGetProgramiv(this->Program, GL_LINK_STATUS, &success); if (!success) { glGetProgramInfoLog(this->Program, 512, NULL, infoLog); - std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl; + LOG(ERROR) << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog; } // Удаляем шейдеры, поскольку они уже в программу и нам больше не нужны. @@ -86,5 +87,5 @@ void Shader::Reload() { const GLchar *fragmentPath = fragment; this->~Shader(); new(this) Shader(vertexPath, fragmentPath); - std::cout<<"Shader is realoded!"< #include #include -#include #include diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp index 0104530..bd5c53f 100644 --- a/src/graphics/Texture.cpp +++ b/src/graphics/Texture.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "Texture.hpp" Texture::Texture(std::string filename, GLenum textureWrapping, GLenum textureFiltering) { @@ -10,17 +10,17 @@ Texture::Texture(std::string filename, GLenum textureWrapping, GLenum textureFil glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureWrapping); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureWrapping); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,textureFiltering); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureFiltering); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); //Image load sf::Image image; if (!image.loadFromFile(filename)) { - std::cout << "Can't open image " << filename << std::endl; + LOG(ERROR) << "Can't open image " << filename; throw 201; } - if (image.getPixelsPtr()==nullptr){ - std::cout<<"Image data is corrupted!"< #include -#include #include #include #include "../utility/utility.h" diff --git a/src/network/Network.cpp b/src/network/Network.cpp index 03ee6c6..ac84494 100644 --- a/src/network/Network.cpp +++ b/src/network/Network.cpp @@ -1,4 +1,3 @@ -#include #include "Network.hpp" #include "../packet/PacketBuilder.hpp" 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 #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 #include +#include #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: "<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<second.Parse(); - /*std::cout << "Parsed chunk" << it->first.GetX() << "x" << it->first.GetY() << "x" << it->first.GetZ() - << std::endl;*/ } } } -- cgit v1.2.3