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