fix compiler warnings (GCC + Clang)
This commit is contained in:
parent
6c3d2d0907
commit
3d22de761f
@ -107,6 +107,7 @@ target_compile_options(
|
|||||||
-Wwrite-strings
|
-Wwrite-strings
|
||||||
-Wno-unused-parameter
|
-Wno-unused-parameter
|
||||||
-Wno-sign-compare
|
-Wno-sign-compare
|
||||||
|
-Wno-unknown-pragmas
|
||||||
$<$<CONFIG:Debug>:-Og>
|
$<$<CONFIG:Debug>:-Og>
|
||||||
>)
|
>)
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int is_box(int c) {
|
inline int is_box(int c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'B':
|
case 'B':
|
||||||
case 'b':
|
case 'b':
|
||||||
@ -21,7 +21,7 @@ namespace {
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
double power(double base, int64_t power) {
|
inline double power(double base, int64_t power) {
|
||||||
double result = 1.0;
|
double result = 1.0;
|
||||||
for (int64_t i = 0; i < power; i++) {
|
for (int64_t i = 0; i < power; i++) {
|
||||||
result *= base;
|
result *= base;
|
||||||
|
|||||||
@ -30,7 +30,6 @@ class TomlReader : BasicParser<char> {
|
|||||||
// todo: extract common part
|
// todo: extract common part
|
||||||
std::string parseMultilineString() {
|
std::string parseMultilineString() {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
char next = peek();
|
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
while (hasNext()) {
|
while (hasNext()) {
|
||||||
|
|||||||
@ -68,7 +68,7 @@ static model::Mesh build_mesh(
|
|||||||
const glm::vec2* uvs = nullptr;
|
const glm::vec2* uvs = nullptr;
|
||||||
const glm::vec3* normals = nullptr;
|
const glm::vec3* normals = nullptr;
|
||||||
|
|
||||||
int coordsIndex, uvsIndex, normalsIndex;
|
int coordsIndex = 0, uvsIndex = 0, normalsIndex = 0;
|
||||||
|
|
||||||
for (int i = 0; i < attrs.size(); i++) {
|
for (int i = 0; i < attrs.size(); i++) {
|
||||||
const auto& attr = attrs[i];
|
const auto& attr = attrs[i];
|
||||||
@ -204,7 +204,7 @@ File vec3::load(
|
|||||||
// Header
|
// Header
|
||||||
reader.checkMagic("\0\0VEC3\0\0", 8);
|
reader.checkMagic("\0\0VEC3\0\0", 8);
|
||||||
int version = reader.getInt16();
|
int version = reader.getInt16();
|
||||||
int reserved = reader.getInt16();
|
[[maybe_unused]] int reserved = reader.getInt16();
|
||||||
if (version > VERSION) {
|
if (version > VERSION) {
|
||||||
throw std::runtime_error("unsupported VEC3 version");
|
throw std::runtime_error("unsupported VEC3 version");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,13 +41,13 @@ static void process_blocks_data(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (def->dataStruct == nullptr) {
|
if (def->dataStruct == nullptr) {
|
||||||
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE};
|
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE, {}};
|
||||||
report.issues.push_back(issue);
|
report.issues.push_back(issue);
|
||||||
report.dataLoss.push_back(name + ": discard data");
|
report.dataLoss.push_back(name + ": discard data");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (layout != *def->dataStruct) {
|
if (layout != *def->dataStruct) {
|
||||||
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE};
|
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE, {}};
|
||||||
report.issues.push_back(issue);
|
report.issues.push_back(issue);
|
||||||
report.dataLayoutsUpdated = true;
|
report.dataLayoutsUpdated = true;
|
||||||
}
|
}
|
||||||
@ -111,10 +111,10 @@ static void build_issues(
|
|||||||
) {
|
) {
|
||||||
auto type = report.getContentType();
|
auto type = report.getContentType();
|
||||||
if (report.hasContentReorder()) {
|
if (report.hasContentReorder()) {
|
||||||
issues.push_back(ContentIssue {ContentIssueType::REORDER, type});
|
issues.push_back(ContentIssue {ContentIssueType::REORDER, {type}});
|
||||||
}
|
}
|
||||||
if (report.hasMissingContent()) {
|
if (report.hasMissingContent()) {
|
||||||
issues.push_back(ContentIssue {ContentIssueType::MISSING, type});
|
issues.push_back(ContentIssue {ContentIssueType::MISSING, {type}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ void ContentReport::buildIssues() {
|
|||||||
for (int layer = REGION_LAYER_VOXELS;
|
for (int layer = REGION_LAYER_VOXELS;
|
||||||
layer < REGION_LAYERS_COUNT;
|
layer < REGION_LAYERS_COUNT;
|
||||||
layer++) {
|
layer++) {
|
||||||
ContentIssue issue {ContentIssueType::REGION_FORMAT_UPDATE};
|
ContentIssue issue {ContentIssueType::REGION_FORMAT_UPDATE, {}};
|
||||||
issue.regionLayer = static_cast<RegionLayerIndex>(layer);
|
issue.regionLayer = static_cast<RegionLayerIndex>(layer);
|
||||||
issues.push_back(issue);
|
issues.push_back(issue);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -245,11 +245,11 @@ namespace data {
|
|||||||
return totalSize;
|
return totalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const auto begin() const {
|
[[nodiscard]] auto begin() const {
|
||||||
return fields.begin();
|
return fields.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const auto end() const {
|
[[nodiscard]] auto end() const {
|
||||||
return fields.end();
|
return fields.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -310,7 +310,6 @@ void Hud::updateWorldGenDebug() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Hud::update(bool visible) {
|
void Hud::update(bool visible) {
|
||||||
const auto& level = frontend.getLevel();
|
|
||||||
const auto& chunks = *player.chunks;
|
const auto& chunks = *player.chunks;
|
||||||
const auto& menu = gui.getMenu();
|
const auto& menu = gui.getMenu();
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,6 @@ bool menus::call(Engine& engine, runnable func) {
|
|||||||
if (engine.isHeadless()) {
|
if (engine.isHeadless()) {
|
||||||
throw std::runtime_error("menus::call(...) in headless mode");
|
throw std::runtime_error("menus::call(...) in headless mode");
|
||||||
}
|
}
|
||||||
auto gui = engine.getGUI();
|
|
||||||
try {
|
try {
|
||||||
func();
|
func();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -154,7 +154,6 @@ void LevelScreen::saveDecorations() {
|
|||||||
void LevelScreen::saveWorldPreview() {
|
void LevelScreen::saveWorldPreview() {
|
||||||
try {
|
try {
|
||||||
logger.info() << "saving world preview";
|
logger.info() << "saving world preview";
|
||||||
const auto& paths = engine.getPaths();
|
|
||||||
auto player = playerController->getPlayer();
|
auto player = playerController->getPlayer();
|
||||||
auto& settings = engine.getSettings();
|
auto& settings = engine.getSettings();
|
||||||
int previewSize = settings.ui.worldPreviewSize.get();
|
int previewSize = settings.ui.worldPreviewSize.get();
|
||||||
|
|||||||
@ -153,7 +153,6 @@ static inline void draw_text(
|
|||||||
}
|
}
|
||||||
batch.texture(font.getPage(0));
|
batch.texture(font.getPage(0));
|
||||||
for (size_t i = 0; i < text.length(); i++) {
|
for (size_t i = 0; i < text.length(); i++) {
|
||||||
uint c = text[i];
|
|
||||||
size_t styleIndex = styles->map.at(
|
size_t styleIndex = styles->map.at(
|
||||||
std::min(styles->map.size() - 1, i + styleMapOffset)
|
std::min(styles->map.size() - 1, i + styleMapOffset)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -329,8 +329,6 @@ void BlocksRenderer::blockCube(
|
|||||||
bool lights,
|
bool lights,
|
||||||
bool ao
|
bool ao
|
||||||
) {
|
) {
|
||||||
ubyte group = block.drawGroup;
|
|
||||||
|
|
||||||
glm::ivec3 X(1, 0, 0);
|
glm::ivec3 X(1, 0, 0);
|
||||||
glm::ivec3 Y(0, 1, 0);
|
glm::ivec3 Y(0, 1, 0);
|
||||||
glm::ivec3 Z(0, 0, 1);
|
glm::ivec3 Z(0, 0, 1);
|
||||||
@ -557,7 +555,7 @@ SortingMeshData BlocksRenderer::renderTranslucent(
|
|||||||
y + 0.5f,
|
y + 0.5f,
|
||||||
z + chunk->z * CHUNK_D + 0.5f
|
z + chunk->z * CHUNK_D + 0.5f
|
||||||
),
|
),
|
||||||
util::Buffer<float>(indexSize * CHUNK_VERTEX_SIZE)};
|
util::Buffer<float>(indexSize * CHUNK_VERTEX_SIZE), 0};
|
||||||
|
|
||||||
totalSize += entry.vertexData.size();
|
totalSize += entry.vertexData.size();
|
||||||
|
|
||||||
@ -593,7 +591,8 @@ SortingMeshData BlocksRenderer::renderTranslucent(
|
|||||||
sortingMesh.entries.size() > 1) {
|
sortingMesh.entries.size() > 1) {
|
||||||
SortingMeshEntry newEntry {
|
SortingMeshEntry newEntry {
|
||||||
sortingMesh.entries[0].position,
|
sortingMesh.entries[0].position,
|
||||||
util::Buffer<float>(totalSize)
|
util::Buffer<float>(totalSize),
|
||||||
|
0
|
||||||
};
|
};
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
for (const auto& entry : sortingMesh.entries) {
|
for (const auto& entry : sortingMesh.entries) {
|
||||||
@ -643,7 +642,7 @@ void BlocksRenderer::build(const Chunk* chunk, const Chunks* chunks) {
|
|||||||
vertexOffset = 0;
|
vertexOffset = 0;
|
||||||
indexOffset = indexSize = 0;
|
indexOffset = indexSize = 0;
|
||||||
|
|
||||||
sortingMesh = std::move(renderTranslucent(voxels, beginEnds));
|
sortingMesh = renderTranslucent(voxels, beginEnds);
|
||||||
|
|
||||||
overflow = false;
|
overflow = false;
|
||||||
vertexOffset = 0;
|
vertexOffset = 0;
|
||||||
|
|||||||
@ -19,7 +19,6 @@ static debug::Logger logger("chunks-render");
|
|||||||
size_t ChunksRenderer::visibleChunks = 0;
|
size_t ChunksRenderer::visibleChunks = 0;
|
||||||
|
|
||||||
class RendererWorker : public util::Worker<std::shared_ptr<Chunk>, RendererResult> {
|
class RendererWorker : public util::Worker<std::shared_ptr<Chunk>, RendererResult> {
|
||||||
const Level& level;
|
|
||||||
const Chunks& chunks;
|
const Chunks& chunks;
|
||||||
BlocksRenderer renderer;
|
BlocksRenderer renderer;
|
||||||
public:
|
public:
|
||||||
@ -29,8 +28,7 @@ public:
|
|||||||
const ContentGfxCache& cache,
|
const ContentGfxCache& cache,
|
||||||
const EngineSettings& settings
|
const EngineSettings& settings
|
||||||
)
|
)
|
||||||
: level(level),
|
: chunks(chunks),
|
||||||
chunks(chunks),
|
|
||||||
renderer(
|
renderer(
|
||||||
settings.graphics.denseRender.get()
|
settings.graphics.denseRender.get()
|
||||||
? settings.graphics.chunkMaxVerticesDense.get()
|
? settings.graphics.chunkMaxVerticesDense.get()
|
||||||
@ -45,7 +43,7 @@ public:
|
|||||||
renderer.build(chunk.get(), &chunks);
|
renderer.build(chunk.get(), &chunks);
|
||||||
if (renderer.isCancelled()) {
|
if (renderer.isCancelled()) {
|
||||||
return RendererResult {
|
return RendererResult {
|
||||||
glm::ivec2(chunk->x, chunk->z), true, MeshData()};
|
glm::ivec2(chunk->x, chunk->z), true, ChunkMeshData {}};
|
||||||
}
|
}
|
||||||
auto meshData = renderer.createMesh();
|
auto meshData = renderer.createMesh();
|
||||||
return RendererResult {
|
return RendererResult {
|
||||||
@ -61,8 +59,7 @@ ChunksRenderer::ChunksRenderer(
|
|||||||
const ContentGfxCache& cache,
|
const ContentGfxCache& cache,
|
||||||
const EngineSettings& settings
|
const EngineSettings& settings
|
||||||
)
|
)
|
||||||
: level(*level),
|
: chunks(chunks),
|
||||||
chunks(chunks),
|
|
||||||
assets(assets),
|
assets(assets),
|
||||||
frustum(frustum),
|
frustum(frustum),
|
||||||
settings(settings),
|
settings(settings),
|
||||||
|
|||||||
@ -42,7 +42,6 @@ struct RendererResult {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ChunksRenderer {
|
class ChunksRenderer {
|
||||||
const Level& level;
|
|
||||||
const Chunks& chunks;
|
const Chunks& chunks;
|
||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
const Frustum& frustum;
|
const Frustum& frustum;
|
||||||
|
|||||||
@ -40,11 +40,10 @@ Decorator::Decorator(
|
|||||||
const Assets& assets,
|
const Assets& assets,
|
||||||
Player& player
|
Player& player
|
||||||
)
|
)
|
||||||
: engine(engine),
|
: level(*controller.getLevel()),
|
||||||
level(*controller.getLevel()),
|
|
||||||
renderer(renderer),
|
|
||||||
assets(assets),
|
assets(assets),
|
||||||
player(player) {
|
player(player),
|
||||||
|
renderer(renderer) {
|
||||||
controller.getBlocksController()->listenBlockInteraction(
|
controller.getBlocksController()->listenBlockInteraction(
|
||||||
[this](auto player, const auto& pos, const auto& def, BlockInteraction type) {
|
[this](auto player, const auto& pos, const auto& def, BlockInteraction type) {
|
||||||
if (type == BlockInteraction::placing && def.particles) {
|
if (type == BlockInteraction::placing && def.particles) {
|
||||||
|
|||||||
@ -18,11 +18,10 @@ class Block;
|
|||||||
class Engine;
|
class Engine;
|
||||||
class LevelController;
|
class LevelController;
|
||||||
class WorldRenderer;
|
class WorldRenderer;
|
||||||
class Weather;
|
struct Weather;
|
||||||
struct WeatherPreset;
|
struct WeatherPreset;
|
||||||
|
|
||||||
class Decorator {
|
class Decorator {
|
||||||
Engine& engine;
|
|
||||||
const Level& level;
|
const Level& level;
|
||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
Player& player;
|
Player& player;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ Emitter::Emitter(
|
|||||||
)
|
)
|
||||||
: level(level),
|
: level(level),
|
||||||
origin(std::move(origin)),
|
origin(std::move(origin)),
|
||||||
prototype({this, 0, {}, preset.velocity, preset.lifetime, region}),
|
prototype({this, 0, {}, preset.velocity, preset.lifetime, region, 0, 0}),
|
||||||
texture(texture),
|
texture(texture),
|
||||||
count(count),
|
count(count),
|
||||||
preset(std::move(preset)) {
|
preset(std::move(preset)) {
|
||||||
|
|||||||
@ -51,11 +51,10 @@ ModelBatch::ModelBatch(
|
|||||||
const Chunks& chunks,
|
const Chunks& chunks,
|
||||||
const EngineSettings& settings
|
const EngineSettings& settings
|
||||||
)
|
)
|
||||||
: batch(std::make_unique<MainBatch>(capacity)),
|
: assets(assets),
|
||||||
assets(assets),
|
|
||||||
chunks(chunks),
|
chunks(chunks),
|
||||||
settings(settings) {
|
settings(settings),
|
||||||
}
|
batch(std::make_unique<MainBatch>(capacity)) {}
|
||||||
|
|
||||||
ModelBatch::~ModelBatch() = default;
|
ModelBatch::~ModelBatch() = default;
|
||||||
|
|
||||||
|
|||||||
@ -21,11 +21,10 @@ ParticlesRenderer::ParticlesRenderer(
|
|||||||
const Chunks& chunks,
|
const Chunks& chunks,
|
||||||
const GraphicsSettings* settings
|
const GraphicsSettings* settings
|
||||||
)
|
)
|
||||||
: batch(std::make_unique<MainBatch>(4096)),
|
: chunks(chunks),
|
||||||
level(level),
|
|
||||||
chunks(chunks),
|
|
||||||
assets(assets),
|
assets(assets),
|
||||||
settings(settings) {
|
settings(settings),
|
||||||
|
batch(std::make_unique<MainBatch>(4096)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticlesRenderer::~ParticlesRenderer() = default;
|
ParticlesRenderer::~ParticlesRenderer() = default;
|
||||||
@ -171,7 +170,6 @@ void ParticlesRenderer::render(const Camera& camera, float delta) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto texture = emitter.getTexture();
|
auto texture = emitter.getTexture();
|
||||||
const auto& found = particles.find(texture);
|
|
||||||
std::vector<Particle>* vec;
|
std::vector<Particle>* vec;
|
||||||
vec = &particles[texture];
|
vec = &particles[texture];
|
||||||
emitter.update(delta, camera.position, *vec);
|
emitter.update(delta, camera.position, *vec);
|
||||||
|
|||||||
@ -16,7 +16,6 @@ class Level;
|
|||||||
struct GraphicsSettings;
|
struct GraphicsSettings;
|
||||||
|
|
||||||
class ParticlesRenderer {
|
class ParticlesRenderer {
|
||||||
const Level& level;
|
|
||||||
const Chunks& chunks;
|
const Chunks& chunks;
|
||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
const GraphicsSettings* settings;
|
const GraphicsSettings* settings;
|
||||||
|
|||||||
@ -18,15 +18,13 @@
|
|||||||
|
|
||||||
PrecipitationRenderer::PrecipitationRenderer(
|
PrecipitationRenderer::PrecipitationRenderer(
|
||||||
const Assets& assets,
|
const Assets& assets,
|
||||||
const Level& level,
|
const Level&,
|
||||||
const Chunks& chunks,
|
const Chunks& chunks,
|
||||||
const GraphicsSettings* settings
|
const GraphicsSettings*
|
||||||
)
|
)
|
||||||
: batch(std::make_unique<MainBatch>(4096)),
|
: batch(std::make_unique<MainBatch>(4096)),
|
||||||
level(level),
|
|
||||||
chunks(chunks),
|
chunks(chunks),
|
||||||
assets(assets),
|
assets(assets) {
|
||||||
settings(settings) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrecipitationRenderer::~PrecipitationRenderer() = default;
|
PrecipitationRenderer::~PrecipitationRenderer() = default;
|
||||||
|
|||||||
@ -12,10 +12,8 @@ struct WeatherPreset;
|
|||||||
|
|
||||||
class PrecipitationRenderer {
|
class PrecipitationRenderer {
|
||||||
std::unique_ptr<MainBatch> batch;
|
std::unique_ptr<MainBatch> batch;
|
||||||
const Level& level;
|
|
||||||
const Chunks& chunks;
|
const Chunks& chunks;
|
||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
const GraphicsSettings* settings;
|
|
||||||
float timer = 0.0f;
|
float timer = 0.0f;
|
||||||
|
|
||||||
int getHeightAt(int x, int z);
|
int getHeightAt(int x, int z);
|
||||||
|
|||||||
@ -72,10 +72,6 @@ WorldRenderer::WorldRenderer(
|
|||||||
modelBatch(std::make_unique<ModelBatch>(
|
modelBatch(std::make_unique<ModelBatch>(
|
||||||
MODEL_BATCH_CAPACITY, assets, *player.chunks, engine.getSettings()
|
MODEL_BATCH_CAPACITY, assets, *player.chunks, engine.getSettings()
|
||||||
)),
|
)),
|
||||||
particles(std::make_unique<ParticlesRenderer>(
|
|
||||||
assets, level, *player.chunks, &engine.getSettings().graphics
|
|
||||||
)),
|
|
||||||
texts(std::make_unique<TextsRenderer>(*batch3d, assets, *frustumCulling)),
|
|
||||||
guides(std::make_unique<GuidesRenderer>()),
|
guides(std::make_unique<GuidesRenderer>()),
|
||||||
chunks(std::make_unique<ChunksRenderer>(
|
chunks(std::make_unique<ChunksRenderer>(
|
||||||
&level,
|
&level,
|
||||||
@ -85,6 +81,10 @@ WorldRenderer::WorldRenderer(
|
|||||||
frontend.getContentGfxCache(),
|
frontend.getContentGfxCache(),
|
||||||
engine.getSettings()
|
engine.getSettings()
|
||||||
)),
|
)),
|
||||||
|
particles(std::make_unique<ParticlesRenderer>(
|
||||||
|
assets, level, *player.chunks, &engine.getSettings().graphics
|
||||||
|
)),
|
||||||
|
texts(std::make_unique<TextsRenderer>(*batch3d, assets, *frustumCulling)),
|
||||||
blockWraps(
|
blockWraps(
|
||||||
std::make_unique<BlockWrapsRenderer>(assets, level, *player.chunks)
|
std::make_unique<BlockWrapsRenderer>(assets, level, *player.chunks)
|
||||||
),
|
),
|
||||||
|
|||||||
@ -43,10 +43,10 @@ class WorldRenderer {
|
|||||||
std::unique_ptr<Frustum> frustumCulling;
|
std::unique_ptr<Frustum> frustumCulling;
|
||||||
std::unique_ptr<LineBatch> lineBatch;
|
std::unique_ptr<LineBatch> lineBatch;
|
||||||
std::unique_ptr<Batch3D> batch3d;
|
std::unique_ptr<Batch3D> batch3d;
|
||||||
std::unique_ptr<ChunksRenderer> chunks;
|
|
||||||
std::unique_ptr<GuidesRenderer> guides;
|
|
||||||
std::unique_ptr<Skybox> skybox;
|
|
||||||
std::unique_ptr<ModelBatch> modelBatch;
|
std::unique_ptr<ModelBatch> modelBatch;
|
||||||
|
std::unique_ptr<GuidesRenderer> guides;
|
||||||
|
std::unique_ptr<ChunksRenderer> chunks;
|
||||||
|
std::unique_ptr<Skybox> skybox;
|
||||||
Weather weather {};
|
Weather weather {};
|
||||||
|
|
||||||
float timer = 0.0f;
|
float timer = 0.0f;
|
||||||
@ -73,8 +73,8 @@ class WorldRenderer {
|
|||||||
float fogFactor
|
float fogFactor
|
||||||
);
|
);
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<TextsRenderer> texts;
|
|
||||||
std::unique_ptr<ParticlesRenderer> particles;
|
std::unique_ptr<ParticlesRenderer> particles;
|
||||||
|
std::unique_ptr<TextsRenderer> texts;
|
||||||
std::unique_ptr<BlockWrapsRenderer> blockWraps;
|
std::unique_ptr<BlockWrapsRenderer> blockWraps;
|
||||||
std::unique_ptr<PrecipitationRenderer> precipitation;
|
std::unique_ptr<PrecipitationRenderer> precipitation;
|
||||||
|
|
||||||
|
|||||||
@ -7,9 +7,9 @@ namespace gui {
|
|||||||
|
|
||||||
class InputBindBox : public Panel {
|
class InputBindBox : public Panel {
|
||||||
protected:
|
protected:
|
||||||
|
Binding& binding;
|
||||||
glm::vec4 focusedColor {0.1f, 0.15f, 0.35f, 0.75f};
|
glm::vec4 focusedColor {0.1f, 0.15f, 0.35f, 0.75f};
|
||||||
std::shared_ptr<Label> label;
|
std::shared_ptr<Label> label;
|
||||||
Binding& binding;
|
|
||||||
public:
|
public:
|
||||||
InputBindBox(Binding& binding, glm::vec4 padding=glm::vec4(6.0f));
|
InputBindBox(Binding& binding, glm::vec4 padding=glm::vec4(6.0f));
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Assets;
|
class Assets;
|
||||||
class ItemDef;
|
struct ItemDef;
|
||||||
class Batch2D;
|
class Batch2D;
|
||||||
class DrawContext;
|
class DrawContext;
|
||||||
class Content;
|
class Content;
|
||||||
|
|||||||
@ -61,7 +61,6 @@ void LabelCache::update(std::wstring_view text, bool multiline, bool wrap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (font != nullptr) {
|
if (font != nullptr) {
|
||||||
int lineHeight = font->getLineHeight();
|
|
||||||
int maxWidth = 0;
|
int maxWidth = 0;
|
||||||
for (int i = 0; i < lines.size() - 1; i++) {
|
for (int i = 0; i < lines.size() - 1; i++) {
|
||||||
const auto& next = lines[i + 1];
|
const auto& next = lines[i + 1];
|
||||||
|
|||||||
@ -603,7 +603,6 @@ void TextBox::onFocus(GUI* gui) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::reposition() {
|
void TextBox::reposition() {
|
||||||
auto size = getSize();
|
|
||||||
UINode::reposition();
|
UINode::reposition();
|
||||||
refreshLabel();
|
refreshLabel();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ void guiutil::alert(
|
|||||||
|
|
||||||
auto menuPtr = engine.getGUI()->getMenu();
|
auto menuPtr = engine.getGUI()->getMenu();
|
||||||
auto& menu = *menuPtr;
|
auto& menu = *menuPtr;
|
||||||
runnable on_hidden_final = [on_hidden, &menu, &engine]() {
|
runnable on_hidden_final = [on_hidden, &menu]() {
|
||||||
menu.removePage("<alert>");
|
menu.removePage("<alert>");
|
||||||
if (on_hidden) {
|
if (on_hidden) {
|
||||||
on_hidden();
|
on_hidden();
|
||||||
@ -103,7 +103,7 @@ void guiutil::confirm(
|
|||||||
|
|
||||||
auto menu = engine.getGUI()->getMenu();
|
auto menu = engine.getGUI()->getMenu();
|
||||||
|
|
||||||
runnable on_confirm_final = [on_confirm, menu, &engine]() {
|
runnable on_confirm_final = [on_confirm, menu]() {
|
||||||
menu->removePage("<confirm>");
|
menu->removePage("<confirm>");
|
||||||
if (on_confirm) {
|
if (on_confirm) {
|
||||||
on_confirm();
|
on_confirm();
|
||||||
@ -112,7 +112,7 @@ void guiutil::confirm(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
runnable on_deny_final = [on_deny, menu, &engine]() {
|
runnable on_deny_final = [on_deny, menu]() {
|
||||||
menu->removePage("<confirm>");
|
menu->removePage("<confirm>");
|
||||||
if (on_deny) {
|
if (on_deny) {
|
||||||
on_deny();
|
on_deny();
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
class memory_buffer : public std::streambuf {
|
class memory_buffer : public std::streambuf {
|
||||||
public:
|
public:
|
||||||
explicit memory_buffer(size_t initial_size = 64)
|
explicit memory_buffer(size_t initial_size = 64)
|
||||||
: capacity(initial_size),
|
: buffer(std::make_unique<char[]>(initial_size)),
|
||||||
buffer(std::make_unique<char[]>(initial_size)) {
|
capacity(initial_size) {
|
||||||
setp(buffer.get(), buffer.get() + initial_size);
|
setp(buffer.get(), buffer.get() + initial_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,8 +59,6 @@ path path::normalized() const {
|
|||||||
}
|
}
|
||||||
parts.push(std::move(token));
|
parts.push(std::move(token));
|
||||||
}
|
}
|
||||||
bool started = false;
|
|
||||||
|
|
||||||
path = "";
|
path = "";
|
||||||
while (!parts.empty()) {
|
while (!parts.empty()) {
|
||||||
const auto& token = parts.top();
|
const auto& token = parts.top();
|
||||||
|
|||||||
@ -217,8 +217,7 @@ PlayerController::PlayerController(
|
|||||||
Player& player,
|
Player& player,
|
||||||
BlocksController& blocksController
|
BlocksController& blocksController
|
||||||
)
|
)
|
||||||
: settings(settings),
|
: level(level),
|
||||||
level(level),
|
|
||||||
player(player),
|
player(player),
|
||||||
camControl(player, settings.camera),
|
camControl(player, settings.camera),
|
||||||
blocksController(blocksController) {
|
blocksController(blocksController) {
|
||||||
|
|||||||
@ -47,7 +47,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class PlayerController {
|
class PlayerController {
|
||||||
const EngineSettings& settings;
|
|
||||||
Level& level;
|
Level& level;
|
||||||
Player& player;
|
Player& player;
|
||||||
PlayerInput input {};
|
PlayerInput input {};
|
||||||
|
|||||||
@ -145,7 +145,7 @@ static int get_axis(lua::State* L) {
|
|||||||
}
|
}
|
||||||
auto z = lua::tointeger(L, 3);
|
auto z = lua::tointeger(L, 3);
|
||||||
|
|
||||||
glm::ivec3 defAxis;
|
glm::ivec3 defAxis {};
|
||||||
defAxis[n] = 1;
|
defAxis[n] = 1;
|
||||||
|
|
||||||
auto vox = blocks_agent::get(*level->chunks, x, y, z);
|
auto vox = blocks_agent::get(*level->chunks, x, y, z);
|
||||||
@ -562,6 +562,7 @@ static int set_field(
|
|||||||
return lua::pushinteger(L,
|
return lua::pushinteger(L,
|
||||||
dataStruct.setUnicode(dst, value.asString(), field));
|
dataStruct.setUnicode(dst, value.asString(), field));
|
||||||
}
|
}
|
||||||
|
[[fallthrough]];
|
||||||
case data::FieldType::I8:
|
case data::FieldType::I8:
|
||||||
case data::FieldType::I16:
|
case data::FieldType::I16:
|
||||||
case data::FieldType::I32:
|
case data::FieldType::I32:
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
||||||
static int l_save_fragment(lua::State* L) {
|
static int l_save_fragment(lua::State* L) {
|
||||||
const auto& paths = engine->getPaths();
|
|
||||||
auto fragment = lua::touserdata<lua::LuaVoxelFragment>(L, 1);
|
auto fragment = lua::touserdata<lua::LuaVoxelFragment>(L, 1);
|
||||||
auto file = lua::require_string(L, 2);
|
auto file = lua::require_string(L, 2);
|
||||||
auto map = fragment->getFragment()->serialize();
|
auto map = fragment->getFragment()->serialize();
|
||||||
@ -55,13 +54,11 @@ static int l_get_generators(lua::State* L) {
|
|||||||
|
|
||||||
lua::createtable(L, 0, 0);
|
lua::createtable(L, 0, 0);
|
||||||
|
|
||||||
int i = 1;
|
|
||||||
for (const auto& pack : packs) {
|
for (const auto& pack : packs) {
|
||||||
auto pairs = ContentLoader::scanContent(pack, ContentType::GENERATOR);
|
auto pairs = ContentLoader::scanContent(pack, ContentType::GENERATOR);
|
||||||
for (const auto& [name, caption] : pairs) {
|
for (const auto& [name, caption] : pairs) {
|
||||||
lua::pushstring(L, caption);
|
lua::pushstring(L, caption);
|
||||||
lua::setfield(L, name);
|
lua::setfield(L, name);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@ -783,7 +783,7 @@ static int l_gui_escape_markup(lua::State* L) {
|
|||||||
auto lang = lua::require_string(L, 1);
|
auto lang = lua::require_string(L, 1);
|
||||||
std::string text = lua::require_string(L, 2);
|
std::string text = lua::require_string(L, 2);
|
||||||
if (std::strcmp(lang, "md") == 0) {
|
if (std::strcmp(lang, "md") == 0) {
|
||||||
text = std::move(markdown::escape<char>(text));
|
text = markdown::escape<char>(text);
|
||||||
}
|
}
|
||||||
return lua::pushstring(L, text);
|
return lua::pushstring(L, text);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -227,7 +227,6 @@ static int l_has_data(lua::State* L, ItemStack& stack) {
|
|||||||
static int l_set_data(lua::State* L, ItemStack& stack) {
|
static int l_set_data(lua::State* L, ItemStack& stack) {
|
||||||
auto key = lua::require_string(L, 3);
|
auto key = lua::require_string(L, 3);
|
||||||
auto value = lua::tovalue(L, 4);
|
auto value = lua::tovalue(L, 4);
|
||||||
auto& fields = stack.getFields();
|
|
||||||
stack.setField(key, std::move(value));
|
stack.setField(key, std::move(value));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -235,7 +235,7 @@ static int l_pack_assemble(lua::State* L) {
|
|||||||
auto manager = engine->createPacksManager(worldFolder);
|
auto manager = engine->createPacksManager(worldFolder);
|
||||||
manager.scan();
|
manager.scan();
|
||||||
try {
|
try {
|
||||||
ids = std::move(manager.assemble(ids));
|
ids = manager.assemble(ids);
|
||||||
} catch (const contentpack_error& err) {
|
} catch (const contentpack_error& err) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
std::string(err.what()) + " [" + err.getPackId() + "]"
|
std::string(err.what()) + " [" + err.getPackId() + "]"
|
||||||
|
|||||||
@ -59,7 +59,6 @@ static int l_get_origin(lua::State* L) {
|
|||||||
static int l_set_origin(lua::State* L) {
|
static int l_set_origin(lua::State* L) {
|
||||||
u64id_t id = lua::touinteger(L, 1);
|
u64id_t id = lua::touinteger(L, 1);
|
||||||
if (auto emitter = renderer->particles->getEmitter(id)) {
|
if (auto emitter = renderer->particles->getEmitter(id)) {
|
||||||
EmitterOrigin origin;
|
|
||||||
if (lua::istable(L, 2)) {
|
if (lua::istable(L, 2)) {
|
||||||
emitter->setOrigin(lua::tovec3(L, 2));
|
emitter->setOrigin(lua::tovec3(L, 2));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -149,9 +149,7 @@ static int l_get_chunk_data(lua::State* L) {
|
|||||||
static void integrate_chunk_client(Chunk& chunk) {
|
static void integrate_chunk_client(Chunk& chunk) {
|
||||||
int x = chunk.x;
|
int x = chunk.x;
|
||||||
int z = chunk.z;
|
int z = chunk.z;
|
||||||
auto chunksController = controller->getChunksController();
|
|
||||||
|
|
||||||
Lighting& lighting = *chunksController->lighting;
|
|
||||||
chunk.flags.loadedLights = false;
|
chunk.flags.loadedLights = false;
|
||||||
chunk.flags.lighted = false;
|
chunk.flags.lighted = false;
|
||||||
chunk.lightmap.clear();
|
chunk.lightmap.clear();
|
||||||
|
|||||||
@ -50,7 +50,6 @@ const float* LuaHeightmap::getValues() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int l_dump(lua::State* L) {
|
static int l_dump(lua::State* L) {
|
||||||
const auto& paths = scripting::engine->getPaths();
|
|
||||||
if (auto heightmap = touserdata<LuaHeightmap>(L, 1)) {
|
if (auto heightmap = touserdata<LuaHeightmap>(L, 1)) {
|
||||||
io::path file = require_string(L, 2);
|
io::path file = require_string(L, 2);
|
||||||
uint w = heightmap->getWidth();
|
uint w = heightmap->getWidth();
|
||||||
|
|||||||
@ -16,8 +16,8 @@ enum class InterpolationType {
|
|||||||
std::optional<InterpolationType> InterpolationType_from(std::string_view str);
|
std::optional<InterpolationType> InterpolationType_from(std::string_view str);
|
||||||
|
|
||||||
class Heightmap {
|
class Heightmap {
|
||||||
std::vector<float> buffer;
|
|
||||||
uint width, height;
|
uint width, height;
|
||||||
|
std::vector<float> buffer;
|
||||||
public:
|
public:
|
||||||
Heightmap(uint width, uint height)
|
Heightmap(uint width, uint height)
|
||||||
: width(width), height(height) {
|
: width(width), height(height) {
|
||||||
|
|||||||
@ -85,7 +85,8 @@ public:
|
|||||||
OnReject onReject,
|
OnReject onReject,
|
||||||
long maxSize
|
long maxSize
|
||||||
) override {
|
) override {
|
||||||
Request request {RequestType::GET, url, onResponse, onReject, maxSize};
|
Request request {
|
||||||
|
RequestType::GET, url, onResponse, onReject, maxSize, false, ""};
|
||||||
processRequest(std::move(request));
|
processRequest(std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +97,8 @@ public:
|
|||||||
OnReject onReject=nullptr,
|
OnReject onReject=nullptr,
|
||||||
long maxSize=0
|
long maxSize=0
|
||||||
) override {
|
) override {
|
||||||
Request request {RequestType::POST, url, onResponse, onReject, maxSize};
|
Request request {
|
||||||
|
RequestType::POST, url, onResponse, onReject, maxSize, false, ""};
|
||||||
request.data = data;
|
request.data = data;
|
||||||
processRequest(std::move(request));
|
processRequest(std::move(request));
|
||||||
}
|
}
|
||||||
@ -288,7 +290,6 @@ static std::string to_string(const sockaddr_in& addr, bool port=true) {
|
|||||||
|
|
||||||
class SocketConnection : public Connection {
|
class SocketConnection : public Connection {
|
||||||
SOCKET descriptor;
|
SOCKET descriptor;
|
||||||
bool open = true;
|
|
||||||
sockaddr_in addr;
|
sockaddr_in addr;
|
||||||
size_t totalUpload = 0;
|
size_t totalUpload = 0;
|
||||||
size_t totalDownload = 0;
|
size_t totalDownload = 0;
|
||||||
@ -453,7 +454,8 @@ public:
|
|||||||
throw std::runtime_error(gai_strerror(res));
|
throw std::runtime_error(gai_strerror(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
sockaddr_in serverAddress = *(sockaddr_in*)addrinfo->ai_addr;
|
sockaddr_in serverAddress;
|
||||||
|
std::memcpy(&serverAddress, addrinfo->ai_addr, sizeof(sockaddr_in));
|
||||||
serverAddress.sin_port = htons(port);
|
serverAddress.sin_port = htons(port);
|
||||||
freeaddrinfo(addrinfo);
|
freeaddrinfo(addrinfo);
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
#include "stringutil.hpp"
|
#include "stringutil.hpp"
|
||||||
#include "typedefs.hpp"
|
#include "typedefs.hpp"
|
||||||
|
#include "debug/Logger.hpp"
|
||||||
|
|
||||||
|
static debug::Logger logger("platform");
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -103,6 +106,9 @@ void platform::open_folder(const std::filesystem::path& folder) {
|
|||||||
ShellExecuteW(NULL, L"open", folder.wstring().c_str(), NULL, NULL, SW_SHOWDEFAULT);
|
ShellExecuteW(NULL, L"open", folder.wstring().c_str(), NULL, NULL, SW_SHOWDEFAULT);
|
||||||
#else
|
#else
|
||||||
auto cmd = "xdg-open " + util::quote(folder.u8string());
|
auto cmd = "xdg-open " + util::quote(folder.u8string());
|
||||||
system(cmd.c_str());
|
if (int res = system(cmd.c_str())) {
|
||||||
|
logger.warning() << "'" << cmd << "' returned code " << res;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,8 +21,7 @@ Level::Level(
|
|||||||
const Content& content,
|
const Content& content,
|
||||||
EngineSettings& settings
|
EngineSettings& settings
|
||||||
)
|
)
|
||||||
: settings(settings),
|
: world(std::move(worldPtr)),
|
||||||
world(std::move(worldPtr)),
|
|
||||||
content(content),
|
content(content),
|
||||||
chunks(std::make_unique<GlobalChunks>(*this)),
|
chunks(std::make_unique<GlobalChunks>(*this)),
|
||||||
physics(std::make_unique<PhysicsSolver>(glm::vec3(0, -22.6f, 0))),
|
physics(std::make_unique<PhysicsSolver>(glm::vec3(0, -22.6f, 0))),
|
||||||
|
|||||||
@ -20,7 +20,6 @@ struct EngineSettings;
|
|||||||
|
|
||||||
/// @brief A level, contains chunks and objects
|
/// @brief A level, contains chunks and objects
|
||||||
class Level {
|
class Level {
|
||||||
const EngineSettings& settings;
|
|
||||||
std::unique_ptr<World> world;
|
std::unique_ptr<World> world;
|
||||||
public:
|
public:
|
||||||
const Content& content;
|
const Content& content;
|
||||||
|
|||||||
@ -54,7 +54,6 @@ void WorldConverter::addRegionsTasks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldConverter::createUpgradeTasks() {
|
void WorldConverter::createUpgradeTasks() {
|
||||||
const auto& regions = wfile->getRegions();
|
|
||||||
for (auto& issue : report->getIssues()) {
|
for (auto& issue : report->getIssues()) {
|
||||||
if (issue.issueType != ContentIssueType::REGION_FORMAT_UPDATE) {
|
if (issue.issueType != ContentIssueType::REGION_FORMAT_UPDATE) {
|
||||||
continue;
|
continue;
|
||||||
@ -83,7 +82,6 @@ void WorldConverter::createConvertTasks() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto& regions = wfile->getRegions();
|
|
||||||
for (auto& issue : report->getIssues()) {
|
for (auto& issue : report->getIssues()) {
|
||||||
switch (issue.issueType) {
|
switch (issue.issueType) {
|
||||||
case ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE:
|
case ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE:
|
||||||
@ -97,13 +95,13 @@ void WorldConverter::createConvertTasks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.push(ConvertTask {ConvertTaskType::PLAYER, wfile->getPlayerFile()});
|
tasks.push(ConvertTask {
|
||||||
|
ConvertTaskType::PLAYER, wfile->getPlayerFile(), 0, 0, {}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldConverter::createBlockFieldsConvertTasks() {
|
void WorldConverter::createBlockFieldsConvertTasks() {
|
||||||
// blocks data conversion requires correct block indices
|
// blocks data conversion requires correct block indices
|
||||||
// so it must be done AFTER voxels conversion
|
// so it must be done AFTER voxels conversion
|
||||||
const auto& regions = wfile->getRegions();
|
|
||||||
for (auto& issue : report->getIssues()) {
|
for (auto& issue : report->getIssues()) {
|
||||||
switch (issue.issueType) {
|
switch (issue.issueType) {
|
||||||
case ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE:
|
case ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE:
|
||||||
|
|||||||
@ -43,7 +43,7 @@ util::Buffer<ubyte> compatibility::convert_region_2to3(
|
|||||||
const util::Buffer<ubyte>& src, RegionLayerIndex layer
|
const util::Buffer<ubyte>& src, RegionLayerIndex layer
|
||||||
) {
|
) {
|
||||||
const size_t REGION_CHUNKS = 1024;
|
const size_t REGION_CHUNKS = 1024;
|
||||||
const size_t HEADER_SIZE = 10;
|
// const size_t HEADER_SIZE = 10;
|
||||||
const size_t OFFSET_TABLE_SIZE = REGION_CHUNKS * sizeof(uint32_t);
|
const size_t OFFSET_TABLE_SIZE = REGION_CHUNKS * sizeof(uint32_t);
|
||||||
const ubyte COMPRESS_NONE = 0;
|
const ubyte COMPRESS_NONE = 0;
|
||||||
const ubyte COMPRESS_EXTRLE8 = 1;
|
const ubyte COMPRESS_EXTRLE8 = 1;
|
||||||
@ -61,7 +61,6 @@ util::Buffer<ubyte> compatibility::convert_region_2to3(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t offsets[REGION_CHUNKS] {};
|
uint32_t offsets[REGION_CHUNKS] {};
|
||||||
size_t chunkIndex = 0;
|
|
||||||
|
|
||||||
auto tablePtr = reinterpret_cast<const uint32_t*>(
|
auto tablePtr = reinterpret_cast<const uint32_t*>(
|
||||||
ptr + src.size() - OFFSET_TABLE_SIZE
|
ptr + src.size() - OFFSET_TABLE_SIZE
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
VoxelStructure::VoxelStructure(
|
VoxelStructure::VoxelStructure(
|
||||||
VoxelStructureMeta meta,
|
VoxelStructureMeta meta,
|
||||||
std::unique_ptr<VoxelFragment> structure
|
std::unique_ptr<VoxelFragment> structure
|
||||||
) : fragments({std::move(structure)}), meta(std::move(meta)) {}
|
) : meta(std::move(meta)), fragments({std::move(structure)}) {}
|
||||||
|
|
||||||
GeneratorDef::GeneratorDef(std::string name)
|
GeneratorDef::GeneratorDef(std::string name)
|
||||||
: name(std::move(name)), caption(util::id_to_caption(name)) {
|
: name(std::move(name)), caption(util::id_to_caption(name)) {
|
||||||
|
|||||||
@ -437,7 +437,6 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ) {
|
|||||||
|
|
||||||
std::memset(voxels, 0, sizeof(voxel) * CHUNK_VOL);
|
std::memset(voxels, 0, sizeof(voxel) * CHUNK_VOL);
|
||||||
|
|
||||||
const auto& indices = content.getIndices()->blocks;
|
|
||||||
const auto& biomes = prototype.biomes.get();
|
const auto& biomes = prototype.biomes.get();
|
||||||
for (uint z = 0; z < CHUNK_D; z++) {
|
for (uint z = 0; z < CHUNK_D; z++) {
|
||||||
for (uint x = 0; x < CHUNK_W; x++) {
|
for (uint x = 0; x < CHUNK_W; x++) {
|
||||||
@ -456,6 +455,7 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ) {
|
|||||||
generatePlacements(prototype, voxels, chunkX, chunkZ);
|
generatePlacements(prototype, voxels, chunkX, chunkZ);
|
||||||
generatePlants(prototype, values, voxels, chunkX, chunkZ, biomes);
|
generatePlants(prototype, values, voxels, chunkX, chunkZ, biomes);
|
||||||
|
|
||||||
|
[[maybe_unused]] const auto& indices = content.getIndices()->blocks;
|
||||||
for (uint i = 0; i < CHUNK_VOL; i++) {
|
for (uint i = 0; i < CHUNK_VOL; i++) {
|
||||||
blockid_t& id = voxels[i].id;
|
blockid_t& id = voxels[i].id;
|
||||||
if (id == BLOCK_STRUCT_AIR) {
|
if (id == BLOCK_STRUCT_AIR) {
|
||||||
@ -609,3 +609,7 @@ WorldGenDebugInfo WorldGenerator::createDebugInfo() const {
|
|||||||
std::move(values)
|
std::move(values)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t WorldGenerator::getSeed() const {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|||||||
@ -134,4 +134,6 @@ public:
|
|||||||
void generate(voxel* voxels, int x, int z);
|
void generate(voxel* voxels, int x, int z);
|
||||||
|
|
||||||
WorldGenDebugInfo createDebugInfo() const;
|
WorldGenDebugInfo createDebugInfo() const;
|
||||||
|
|
||||||
|
uint64_t getSeed() const;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user