diff --git a/src/logic/scripting/lua/libgeneration.cpp b/src/logic/scripting/lua/libgeneration.cpp index 106ddbb1..b7c6eff7 100644 --- a/src/logic/scripting/lua/libgeneration.cpp +++ b/src/logic/scripting/lua/libgeneration.cpp @@ -4,7 +4,7 @@ #include "files/util.hpp" #include "coders/binary_json.hpp" #include "world/Level.hpp" -#include "world/generator/Structure.hpp" +#include "world/generator/VoxelStructure.hpp" using namespace scripting; @@ -17,7 +17,7 @@ static int l_save_structure(lua::State* L) { } bool saveEntities = lua::toboolean(L, 4); - auto structure = Structure::create(level, pointA, pointB, saveEntities); + auto structure = VoxelStructure::create(level, pointA, pointB, saveEntities); auto map = structure->serialize(); auto bytes = json::to_binary(map.get()); diff --git a/src/world/generator/Structure.cpp b/src/world/generator/VoxelStructure.cpp similarity index 90% rename from src/world/generator/Structure.cpp rename to src/world/generator/VoxelStructure.cpp index bf5426c7..64b22621 100644 --- a/src/world/generator/Structure.cpp +++ b/src/world/generator/VoxelStructure.cpp @@ -1,4 +1,4 @@ -#include "Structure.hpp" +#include "VoxelStructure.hpp" #include #include @@ -11,7 +11,7 @@ #include "voxels/VoxelsVolume.hpp" #include "world/Level.hpp" -std::unique_ptr Structure::create( +std::unique_ptr VoxelStructure::create( Level* level, const glm::ivec3& a, const glm::ivec3& b, bool entities ) { auto start = glm::min(a, b); @@ -43,11 +43,11 @@ std::unique_ptr Structure::create( voxels[i].id = index; } - return std::make_unique( + return std::make_unique( size, std::move(voxels), std::move(blockNames)); } -std::unique_ptr Structure::serialize() const { +std::unique_ptr VoxelStructure::serialize() const { auto root = std::make_unique(); root->put("version", STRUCTURE_FORMAT_VERSION); root->put("size", dynamic::to_value(size)); @@ -64,7 +64,7 @@ std::unique_ptr Structure::serialize() const { return root; } -void Structure::deserialize(dynamic::Map* src) { +void VoxelStructure::deserialize(dynamic::Map* src) { size = glm::ivec3(); dynamic::get_vec(src, "size", size); voxels.resize(size.x*size.y*size.z); diff --git a/src/world/generator/Structure.hpp b/src/world/generator/VoxelStructure.hpp similarity index 84% rename from src/world/generator/Structure.hpp rename to src/world/generator/VoxelStructure.hpp index 2e932c61..635175f2 100644 --- a/src/world/generator/Structure.hpp +++ b/src/world/generator/VoxelStructure.hpp @@ -11,7 +11,7 @@ inline constexpr int STRUCTURE_FORMAT_VERSION = 1; class Level; class Content; -struct Structure : public Serializable { +struct VoxelStructure : public Serializable { glm::ivec3 size; /// @brief Structure voxels indexed different to world content @@ -19,9 +19,9 @@ struct Structure : public Serializable { /// @brief Block names are used for indexing std::vector blockNames; - Structure() : size() {} + VoxelStructure() : size() {} - Structure( + VoxelStructure( glm::ivec3 size, std::vector voxels, std::vector blockNames @@ -33,6 +33,6 @@ struct Structure : public Serializable { std::unique_ptr serialize() const override; void deserialize(dynamic::Map* src) override; - static std::unique_ptr create( + static std::unique_ptr create( Level* level, const glm::ivec3& a, const glm::ivec3& b, bool entities); }; diff --git a/src/world/generator/WorldGenerator.cpp b/src/world/generator/WorldGenerator.cpp index 3e0216a4..a6a1fe7e 100644 --- a/src/world/generator/WorldGenerator.cpp +++ b/src/world/generator/WorldGenerator.cpp @@ -13,7 +13,7 @@ static debug::Logger logger("world-generator"); -static inline constexpr uint MAX_PARAMETERS = 16; +static inline constexpr uint MAX_PARAMETERS = 8; static inline constexpr uint MAX_CHUNK_PROTOTYPE_LEVELS = 8; WorldGenerator::WorldGenerator( @@ -136,7 +136,8 @@ void WorldGenerator::generateHeightmap( void WorldGenerator::update(int centerX, int centerY, int loadDistance) { surroundMap.setCenter(centerX, centerY); - surroundMap.resize(loadDistance + 1 /* additional safety padding */); + // 1 is safety padding preventing ChunksController rounding problem + surroundMap.resize(loadDistance + 1); surroundMap.setCenter(centerX, centerY); }