From 3de0187a87d5ec1276606c81bf35c887d0d412ff Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 21:29:42 +0300 Subject: [PATCH 01/12] feat: removing world missing content from UI --- res/layouts/reports/missing_content.xml | 1 + res/layouts/reports/missing_content.xml.lua | 14 ++++++++ res/texts/en_US.txt | 1 + src/frontend/menu.cpp | 4 ++- src/graphics/ui/gui_util.cpp | 1 + src/logic/EngineController.cpp | 40 +++++++++++++++++---- src/logic/EngineController.hpp | 10 +++++- src/logic/scripting/lua/libs/libapp.cpp | 31 ++++++++++++++++ src/logic/scripting/scripting.cpp | 8 ++++- src/logic/scripting/scripting.hpp | 2 +- src/world/files/WorldFiles.cpp | 20 +++++++++++ src/world/files/WorldFiles.hpp | 6 ++++ 12 files changed, 127 insertions(+), 11 deletions(-) diff --git a/res/layouts/reports/missing_content.xml b/res/layouts/reports/missing_content.xml index cd8cacb4f..36cbd78e0 100644 --- a/res/layouts/reports/missing_content.xml +++ b/res/layouts/reports/missing_content.xml @@ -3,5 +3,6 @@ + diff --git a/res/layouts/reports/missing_content.xml.lua b/res/layouts/reports/missing_content.xml.lua index 8ea78a1c1..50ac29c2d 100644 --- a/res/layouts/reports/missing_content.xml.lua +++ b/res/layouts/reports/missing_content.xml.lua @@ -1,4 +1,18 @@ +content_report = nil + +function delete_content() + local units = {} + for i, entry in ipairs(content_report.content) do + table.insert(units, entry.name) + end + local request = { + units = units + } + app.delete_world_content(content_report.world, request, true) +end + function on_open(report) + content_report = report for i, entry in ipairs(report.content) do document.content_panel:add(gui.template("content_entry", entry)) end diff --git a/res/texts/en_US.txt b/res/texts/en_US.txt index 294758a7e..f2312fb34 100644 --- a/res/texts/en_US.txt +++ b/res/texts/en_US.txt @@ -11,6 +11,7 @@ error.dependency-version-not-met=Dependency pack version is not met. world.delete-confirm=Do you want to delete world forever? world.generators.default=Default world.generators.flat=Flat +world.delete-content-confirm=Delete missing content from the world __**(irreversible)**__? editor.info.tooltip=CTRL+S - Save\nCTRL+R - Run\nCTRL+Z - Undo\nCTRL+Y - Redo devtools.traceback=Traceback (most recent call first) diff --git a/src/frontend/menu.cpp b/src/frontend/menu.cpp index ab06b42dc..66431f92b 100644 --- a/src/frontend/menu.cpp +++ b/src/frontend/menu.cpp @@ -79,7 +79,9 @@ UiDocument* menus::show( auto documentPtr = UiDocument::read( engine.getGUI(), - scripting::get_root_environment(), + scripting::create_doc_environment( + scripting::get_root_environment(), fullname, true + ), fullname, file, "core:layouts/" + name diff --git a/src/graphics/ui/gui_util.cpp b/src/graphics/ui/gui_util.cpp index 13364b0ed..86c28864c 100644 --- a/src/graphics/ui/gui_util.cpp +++ b/src/graphics/ui/gui_util.cpp @@ -125,6 +125,7 @@ void guiutil::confirm( label->setSize(glm::vec2(600, 50)); label->setMultiline(true); label->setTextWrapping(true); + label->setMarkup("md"); panel->add(label); auto subpanel = std::make_shared(gui, glm::vec2(600, 53)); diff --git a/src/logic/EngineController.cpp b/src/logic/EngineController.cpp index 51b32e0c4..4d62f6cec 100644 --- a/src/logic/EngineController.cpp +++ b/src/logic/EngineController.cpp @@ -55,6 +55,32 @@ void EngineController::deleteWorld(const std::string& name) { ); } +void EngineController::deleteWorldContent( + const std::string& name, ContentRemovalRequest request, bool loadWorld +) { + io::path folder = engine.getPaths().getWorldFolderByName(name); + auto deletion = [this, folder, loadWorld, request=std::move(request)]() { + logger.info() << "deleting content from the world"; + WorldFiles worldFiles(folder); + worldFiles.deleteContent(std::move(request)); + if (loadWorld) { + openWorld(folder.name(), true); + } + }; + + if (engine.isHeadless()) { + deletion(); + return; + } + + guiutil::confirm( + engine, + langs::get(L"delete-content-confirm", L"world") + L" (" + + util::str2wstr_utf8(folder.string()) + L")", + deletion + ); +} + std::shared_ptr create_converter( Engine& engine, const std::shared_ptr& worldFiles, @@ -174,20 +200,20 @@ static dv::value create_missing_content_report( } void EngineController::onMissingContent( + const std::string& worldName, const std::shared_ptr& report ) { + auto fullReport = create_missing_content_report(report); + fullReport["world"] = worldName; + if (engine.isHeadless()) { throw std::runtime_error( "missing content: " + - util::quote(json::stringify(create_missing_content_report(report), true, " ")) + util::quote(json::stringify(std::move(fullReport), true, " ")) ); } else { engine.setScreen(std::make_shared(engine)); - menus::show( - engine, - "reports/missing_content", - {create_missing_content_report(report)} - ); + menus::show(engine, "reports/missing_content", {std::move(fullReport)}); } } @@ -234,7 +260,7 @@ void EngineController::openWorld(const std::string& name, bool confirmConvert) { return; } if (report->hasMissingContent()) { - onMissingContent(report); + onMissingContent(name, report); return; } diff --git a/src/logic/EngineController.hpp b/src/logic/EngineController.hpp index a40f3476f..147ba482f 100644 --- a/src/logic/EngineController.hpp +++ b/src/logic/EngineController.hpp @@ -9,12 +9,16 @@ class Engine; class World; class ContentReport; class LevelController; +struct ContentRemovalRequest; class EngineController { Engine& engine; int64_t localPlayer = -1; - void onMissingContent(const std::shared_ptr& report); + void onMissingContent( + const std::string& worldName, + const std::shared_ptr& report + ); public: EngineController(Engine& engine); @@ -27,6 +31,10 @@ public: /// @param name world name void deleteWorld(const std::string& name); + void deleteWorldContent( + const std::string& name, ContentRemovalRequest request, bool loadWorld + ); + void reconfigPacks( LevelController* controller, const std::vector& packsToAdd, diff --git a/src/logic/scripting/lua/libs/libapp.cpp b/src/logic/scripting/lua/libs/libapp.cpp index d8a63c720..0cb38a808 100644 --- a/src/logic/scripting/lua/libs/libapp.cpp +++ b/src/logic/scripting/lua/libs/libapp.cpp @@ -19,6 +19,7 @@ #include "util/stringutil.hpp" #include "window/Window.hpp" #include "world/Level.hpp" +#include "world/files/WorldFiles.hpp" #include #include @@ -327,6 +328,35 @@ static int l_delete_world(lua::State* L) { return 0; } +static ContentRemovalRequest parse_content_removal_request(lua::State* L, int idx) { + ContentRemovalRequest request; + if (!lua::istable(L, idx)) { + throw std::runtime_error("table expected as argument"); + } + if (!lua::getfield(L, "units", idx)) { + throw std::runtime_error("table with 'units' field expected"); + } + if (!lua::istable(L, -1)) { + throw std::runtime_error("'units' field must be a table"); + } + int len = lua::objlen(L, -1); + for (int i = 0; i < len; i++) { + lua::rawgeti(L, i + 1); + request.units.emplace_back(lua::require_lstring(L, -1)); + lua::pop(L); + } + return request; +} + +static int l_delete_world_content(lua::State* L) { + auto name = lua::require_string(L, 1); + auto controller = engine->getController(); + auto request = parse_content_removal_request(L, 2); + bool loadWorld = lua::toboolean(L, 3); + controller->deleteWorldContent(name, request, loadWorld); + return 0; +} + /// @brief Get engine version /// @return major, minor, [patch] static int l_get_version(lua::State* L) { @@ -538,6 +568,7 @@ const luaL_Reg applib[] = { {"save_world", lua::wrap}, {"close_world", lua::wrap}, {"delete_world", lua::wrap}, + {"delete_world_content", lua::wrap}, /// other {"get_version", lua::wrap}, {"create_memory_device", lua::wrap}, diff --git a/src/logic/scripting/scripting.cpp b/src/logic/scripting/scripting.cpp index 6bca06cfa..64037775b 100644 --- a/src/logic/scripting/scripting.cpp +++ b/src/logic/scripting/scripting.cpp @@ -216,7 +216,7 @@ std::unique_ptr scripting::start_app_script(const io::path& script) { } [[nodiscard]] scriptenv scripting::create_doc_environment( - const scriptenv& parent, const std::string& name + const scriptenv& parent, const std::string& name, bool app ) { auto L = lua::get_main_state(); int id = lua::create_environment(L, *parent); @@ -226,6 +226,12 @@ std::unique_ptr scripting::start_app_script(const io::path& script) { lua::pushstring(L, name); lua::setfield(L, "DOC_NAME"); + if (app) { + if (lua::getregistry(L, "app")) { + lua::setfield(L, "app"); + } + } + if (lua::getglobal(L, "Document")) { if (lua::getfield(L, "new")) { lua::pushstring(L, name); diff --git a/src/logic/scripting/scripting.hpp b/src/logic/scripting/scripting.hpp index b4c00a622..65f8836e9 100644 --- a/src/logic/scripting/scripting.hpp +++ b/src/logic/scripting/scripting.hpp @@ -65,7 +65,7 @@ namespace scripting { scriptenv create_pack_environment(const ContentPack& pack); scriptenv create_environment(const scriptenv& parent); scriptenv create_doc_environment( - const scriptenv& parent, const std::string& name + const scriptenv& parent, const std::string& name, bool app = false ); void process_post_runnables(); diff --git a/src/world/files/WorldFiles.cpp b/src/world/files/WorldFiles.cpp index 8e471772a..c06df4160 100644 --- a/src/world/files/WorldFiles.cpp +++ b/src/world/files/WorldFiles.cpp @@ -235,3 +235,23 @@ void WorldFiles::removeIndices(const std::vector& packs) { io::path WorldFiles::getFolder() const { return directory; } + +static void replace_all( + dv::value& list, const std::string& unit, const std::string& placeholder +) { + for (uint i = 0; i < list.size(); i++) { + auto& name = list[i].asString(); + if (name == unit) { + list[i] = placeholder; + } + } +} + +void WorldFiles::deleteContent(const ContentRemovalRequest& request) { + auto root = io::read_json(getIndicesFile()); + for (const auto& unit : request.units) { + replace_all(root["blocks"], unit, CORE_AIR); + replace_all(root["items"], unit, CORE_EMPTY); + } + io::write_json(getIndicesFile(), root); +} diff --git a/src/world/files/WorldFiles.hpp b/src/world/files/WorldFiles.hpp index f14c3c33c..31f859e2d 100644 --- a/src/world/files/WorldFiles.hpp +++ b/src/world/files/WorldFiles.hpp @@ -23,6 +23,10 @@ class World; struct WorldInfo; struct DebugSettings; +struct ContentRemovalRequest { + std::vector units; +}; + class WorldFiles { io::path directory; WorldRegions regions; @@ -77,5 +81,7 @@ public: return doWriteLights; } + void deleteContent(const ContentRemovalRequest& request); + static const inline std::string WORLD_FILE = "world.json"; }; From 8268118735d7e9082c1531fdadc5ed8371bfb39f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 21:35:38 +0300 Subject: [PATCH 02/12] update ru_RU.txt --- res/layouts/reports/missing_content.xml | 2 +- res/texts/ru_RU.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/res/layouts/reports/missing_content.xml b/res/layouts/reports/missing_content.xml index 36cbd78e0..76b0872fe 100644 --- a/res/layouts/reports/missing_content.xml +++ b/res/layouts/reports/missing_content.xml @@ -3,6 +3,6 @@ - + diff --git a/res/texts/ru_RU.txt b/res/texts/ru_RU.txt index 295d467af..b11c89365 100644 --- a/res/texts/ru_RU.txt +++ b/res/texts/ru_RU.txt @@ -81,6 +81,8 @@ world.upgrade-request=Формат мира устарел! Конвертиро world.convert-with-loss=Конвертировать мир с потерями? world.convert-block-layouts=Есть изменения в полях блоков! Конвертировать мир? world.delete-confirm=Удалить мир безвозвратно? +world.Delete Content=Удалить контент +world.delete-content-confirm=Удалить отсутствующий контент из мира __**(безвозвратно)**__? # Настройки settings.Ambient=Фон From ecc4c1794ef7fee0bd1135bb21f79afa2572bebb Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 22:01:43 +0300 Subject: [PATCH 03/12] replace 'units' with 'blocks', 'items' for some reason --- res/layouts/reports/missing_content.xml.lua | 13 ++++++-- src/logic/scripting/lua/libs/libapp.cpp | 35 ++++++++++++++------- src/world/files/WorldFiles.cpp | 4 ++- src/world/files/WorldFiles.hpp | 3 +- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/res/layouts/reports/missing_content.xml.lua b/res/layouts/reports/missing_content.xml.lua index 50ac29c2d..0add26f42 100644 --- a/res/layouts/reports/missing_content.xml.lua +++ b/res/layouts/reports/missing_content.xml.lua @@ -1,12 +1,19 @@ content_report = nil function delete_content() - local units = {} + local blocks = {} + local items = {} for i, entry in ipairs(content_report.content) do - table.insert(units, entry.name) + local type = entry.type + if type == "block" then + table.insert(blocks, entry.name) + elseif type == "item" then + table.insert(items, entry.name) + end end local request = { - units = units + blocks = blocks, + items = items } app.delete_world_content(content_report.world, request, true) end diff --git a/src/logic/scripting/lua/libs/libapp.cpp b/src/logic/scripting/lua/libs/libapp.cpp index 0cb38a808..c046567e1 100644 --- a/src/logic/scripting/lua/libs/libapp.cpp +++ b/src/logic/scripting/lua/libs/libapp.cpp @@ -328,21 +328,34 @@ static int l_delete_world(lua::State* L) { return 0; } -static ContentRemovalRequest parse_content_removal_request(lua::State* L, int idx) { +static ContentRemovalRequest parse_content_removal_request( + lua::State* L, int idx +) { ContentRemovalRequest request; if (!lua::istable(L, idx)) { throw std::runtime_error("table expected as argument"); } - if (!lua::getfield(L, "units", idx)) { - throw std::runtime_error("table with 'units' field expected"); - } - if (!lua::istable(L, -1)) { - throw std::runtime_error("'units' field must be a table"); - } - int len = lua::objlen(L, -1); - for (int i = 0; i < len; i++) { - lua::rawgeti(L, i + 1); - request.units.emplace_back(lua::require_lstring(L, -1)); + lua::pushnil(L); + while (lua::next(L, idx)) { + auto key = lua::require_lstring(L, -2); + int len = lua::objlen(L, -1); + + for (int i = 0; i < len; i++) { + lua::rawgeti(L, i + 1); + auto value = lua::require_lstring(L, -1); + + if (key == "blocks") { + request.blocks.emplace_back(value); + } else if (key == "items") { + request.items.emplace_back(value); + } else { + throw std::runtime_error( + "invalid key in content removal request: " + + std::string(key) + ); + } + lua::pop(L); + } lua::pop(L); } return request; diff --git a/src/world/files/WorldFiles.cpp b/src/world/files/WorldFiles.cpp index c06df4160..ea4f70c02 100644 --- a/src/world/files/WorldFiles.cpp +++ b/src/world/files/WorldFiles.cpp @@ -249,8 +249,10 @@ static void replace_all( void WorldFiles::deleteContent(const ContentRemovalRequest& request) { auto root = io::read_json(getIndicesFile()); - for (const auto& unit : request.units) { + for (const auto& unit : request.blocks) { replace_all(root["blocks"], unit, CORE_AIR); + } + for (const auto& unit : request.items) { replace_all(root["items"], unit, CORE_EMPTY); } io::write_json(getIndicesFile(), root); diff --git a/src/world/files/WorldFiles.hpp b/src/world/files/WorldFiles.hpp index 31f859e2d..b0d70c159 100644 --- a/src/world/files/WorldFiles.hpp +++ b/src/world/files/WorldFiles.hpp @@ -24,7 +24,8 @@ struct WorldInfo; struct DebugSettings; struct ContentRemovalRequest { - std::vector units; + std::vector blocks; + std::vector items; }; class WorldFiles { From 24718a29933dee7d357c592353b1c132a6e26956 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 22:08:44 +0300 Subject: [PATCH 04/12] reverting it because voices are not reasom This reverts commit ecc4c1794ef7fee0bd1135bb21f79afa2572bebb. --- res/layouts/reports/missing_content.xml.lua | 13 ++------ src/logic/scripting/lua/libs/libapp.cpp | 35 +++++++-------------- src/world/files/WorldFiles.cpp | 4 +-- src/world/files/WorldFiles.hpp | 3 +- 4 files changed, 16 insertions(+), 39 deletions(-) diff --git a/res/layouts/reports/missing_content.xml.lua b/res/layouts/reports/missing_content.xml.lua index 0add26f42..50ac29c2d 100644 --- a/res/layouts/reports/missing_content.xml.lua +++ b/res/layouts/reports/missing_content.xml.lua @@ -1,19 +1,12 @@ content_report = nil function delete_content() - local blocks = {} - local items = {} + local units = {} for i, entry in ipairs(content_report.content) do - local type = entry.type - if type == "block" then - table.insert(blocks, entry.name) - elseif type == "item" then - table.insert(items, entry.name) - end + table.insert(units, entry.name) end local request = { - blocks = blocks, - items = items + units = units } app.delete_world_content(content_report.world, request, true) end diff --git a/src/logic/scripting/lua/libs/libapp.cpp b/src/logic/scripting/lua/libs/libapp.cpp index c046567e1..0cb38a808 100644 --- a/src/logic/scripting/lua/libs/libapp.cpp +++ b/src/logic/scripting/lua/libs/libapp.cpp @@ -328,34 +328,21 @@ static int l_delete_world(lua::State* L) { return 0; } -static ContentRemovalRequest parse_content_removal_request( - lua::State* L, int idx -) { +static ContentRemovalRequest parse_content_removal_request(lua::State* L, int idx) { ContentRemovalRequest request; if (!lua::istable(L, idx)) { throw std::runtime_error("table expected as argument"); } - lua::pushnil(L); - while (lua::next(L, idx)) { - auto key = lua::require_lstring(L, -2); - int len = lua::objlen(L, -1); - - for (int i = 0; i < len; i++) { - lua::rawgeti(L, i + 1); - auto value = lua::require_lstring(L, -1); - - if (key == "blocks") { - request.blocks.emplace_back(value); - } else if (key == "items") { - request.items.emplace_back(value); - } else { - throw std::runtime_error( - "invalid key in content removal request: " + - std::string(key) - ); - } - lua::pop(L); - } + if (!lua::getfield(L, "units", idx)) { + throw std::runtime_error("table with 'units' field expected"); + } + if (!lua::istable(L, -1)) { + throw std::runtime_error("'units' field must be a table"); + } + int len = lua::objlen(L, -1); + for (int i = 0; i < len; i++) { + lua::rawgeti(L, i + 1); + request.units.emplace_back(lua::require_lstring(L, -1)); lua::pop(L); } return request; diff --git a/src/world/files/WorldFiles.cpp b/src/world/files/WorldFiles.cpp index ea4f70c02..c06df4160 100644 --- a/src/world/files/WorldFiles.cpp +++ b/src/world/files/WorldFiles.cpp @@ -249,10 +249,8 @@ static void replace_all( void WorldFiles::deleteContent(const ContentRemovalRequest& request) { auto root = io::read_json(getIndicesFile()); - for (const auto& unit : request.blocks) { + for (const auto& unit : request.units) { replace_all(root["blocks"], unit, CORE_AIR); - } - for (const auto& unit : request.items) { replace_all(root["items"], unit, CORE_EMPTY); } io::write_json(getIndicesFile(), root); diff --git a/src/world/files/WorldFiles.hpp b/src/world/files/WorldFiles.hpp index b0d70c159..31f859e2d 100644 --- a/src/world/files/WorldFiles.hpp +++ b/src/world/files/WorldFiles.hpp @@ -24,8 +24,7 @@ struct WorldInfo; struct DebugSettings; struct ContentRemovalRequest { - std::vector blocks; - std::vector items; + std::vector units; }; class WorldFiles { From 1bb66ebf1fc0114b92f5cd321a50255fdd5fb68f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 22:26:03 +0300 Subject: [PATCH 05/12] fix audio streams cleanup --- src/audio/audio.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp index ee35abeeb..1fa8a1966 100644 --- a/src/audio/audio.cpp +++ b/src/audio/audio.cpp @@ -349,7 +349,8 @@ void remove_lower_priority_speaker(int priority) { for (auto it = speakers.begin(); it != speakers.end();) { if (it->second->getPriority() < priority && it->second->isPaused()) { it->second->stop(); - it = speakers.erase(it); + streams.erase(it->first); + speakers.erase(it); return; } it++; @@ -357,7 +358,8 @@ void remove_lower_priority_speaker(int priority) { for (auto it = speakers.begin(); it != speakers.end();) { if (it->second->getPriority() < priority) { it->second->stop(); - it = speakers.erase(it); + streams.erase(it->first); + speakers.erase(it); return; } it++; @@ -445,6 +447,7 @@ speakerid_t audio::play_stream( int channel ) { std::shared_ptr stream(open_stream(file, false)); + stream->setStopOnEnd(true); return play(stream, position, relative, volume, pitch, loop, channel); } @@ -520,8 +523,8 @@ void audio::update(double delta) { if (speaker->isStopped()) { auto foundStream = streams.find(it->first); if (foundStream == streams.end() || - (!speaker->isManuallyStopped() && - foundStream->second->isStopOnEnd())) { + speaker->isManuallyStopped() || + foundStream->second->isStopOnEnd()) { streams.erase(it->first); it = speakers.erase(it); } else { From 498868a8d5c6c07e4bc6376471b96cbef3b66132 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 22:45:30 +0300 Subject: [PATCH 06/12] cleanup --- src/audio/AL/ALAudio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/audio/AL/ALAudio.cpp b/src/audio/AL/ALAudio.cpp index c3ec5b24f..1aaeb8f1a 100644 --- a/src/audio/AL/ALAudio.cpp +++ b/src/audio/AL/ALAudio.cpp @@ -275,8 +275,7 @@ void ALStream::update(double delta) { unqueueBuffers(alsource); uint preloaded = enqueueBuffers(alsource); - // alspeaker->stopped is assigned to false at ALSpeaker::play(...) - if (speaker->isStopped() && !alspeaker->manuallyStopped) { //TODO: -V560 false-positive? + if (speaker->isStopped()) { if (preloaded) { speaker->play(); } else if (isStopOnEnd()){ From c641a18d32b32c1412ff52fab6655354463b2547 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 4 Nov 2026 12:43:42 +0300 Subject: [PATCH 07/12] fix lighting settings based chunk meshes rebuilding --- src/frontend/screens/LevelScreen.cpp | 18 +++++++++++++++++- src/graphics/render/BlocksRenderer.cpp | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/frontend/screens/LevelScreen.cpp b/src/frontend/screens/LevelScreen.cpp index d03416a0b..2f29e8b7d 100644 --- a/src/frontend/screens/LevelScreen.cpp +++ b/src/frontend/screens/LevelScreen.cpp @@ -89,9 +89,25 @@ LevelScreen::LevelScreen( resetChunks(false); frontend->getContentGfxCache().refresh(); })); - keepAlive(settings.graphics.shadowsQuality.observe([=](int quality) { + auto graphics = &settings.graphics; + auto shadowsMeshing = std::make_shared( + graphics->shadowsQuality.get() > 0 && graphics->advancedRender.get() + ); + auto updateShadowsMeshing = [=]() { + bool enabled = + graphics->shadowsQuality.get() > 0 && graphics->advancedRender.get(); + if (enabled == *shadowsMeshing) { + return; + } + *shadowsMeshing = enabled; resetChunks(false); frontend->getContentGfxCache().refresh(); + }; + keepAlive(settings.graphics.shadowsQuality.observe([=](int) { + updateShadowsMeshing(); + })); + keepAlive(settings.graphics.advancedRender.observe([=](bool) { + updateShadowsMeshing(); })); keepAlive(settings.camera.fov.observe([=](double value) { player->fpCamera->setFov(glm::radians(value)); diff --git a/src/graphics/render/BlocksRenderer.cpp b/src/graphics/render/BlocksRenderer.cpp index 14ac0ab15..7fbb09e82 100644 --- a/src/graphics/render/BlocksRenderer.cpp +++ b/src/graphics/render/BlocksRenderer.cpp @@ -696,7 +696,8 @@ SortingMeshData BlocksRenderer::renderTranslucent( void BlocksRenderer::build( const Chunk* chunk, const VoxelsRenderVolume& volume ) { - directionalLightFactor = settings.graphics.shadowsQuality.get() > 0.0f + directionalLightFactor = settings.graphics.shadowsQuality.get() > 0 && + settings.graphics.advancedRender.get() ? 0.0f : DEFAULT_DIRECTIONAL_LIGHT_FACTOR; From f4d4209e48fe5c3cc2989e0c8cd7d755c2912fe7 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 4 Nov 2026 15:58:55 +0300 Subject: [PATCH 08/12] fix reverb room rolloff factor minimum value --- src/graphics/render/Decorator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/render/Decorator.cpp b/src/graphics/render/Decorator.cpp index 26a2b302e..dfe86b289 100644 --- a/src/graphics/render/Decorator.cpp +++ b/src/graphics/render/Decorator.cpp @@ -159,7 +159,7 @@ void Decorator::updateAcoustics(const Camera& camera) { acoustics.reverbReflectionsDelay = minDistance / speedOfSound; acoustics.reverbLateReflectionsDelay = averageDistance / speedOfSound; acoustics.reverbDecayTime = decayTime; - acoustics.reverbRoomRolloff = escapeRatio * 1.5f; + acoustics.reverbRoomRolloff = 0.1f + escapeRatio * 1.5f; acoustics.reverbAbsorption = averageAbsorption; audio::set_acoustics(std::move(acoustics)); From 9be7cfa72425533641c05b3736bcdc8129db56bb Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 5 Nov 2026 03:35:32 +0300 Subject: [PATCH 09/12] fix fatal errors caused by incorrect interval event callbacks timing --- src/graphics/ui/elements/Container.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/ui/elements/Container.cpp b/src/graphics/ui/elements/Container.cpp index 727d46b07..0a0c00cdd 100644 --- a/src/graphics/ui/elements/Container.cpp +++ b/src/graphics/ui/elements/Container.cpp @@ -99,7 +99,7 @@ void Container::act(float delta) { intervalEvents[i].timer += delta; if (intervalEvents[i].timer > intervalEvents[i].interval) { auto callback = intervalEvents[i].callback; - callback(); + gui.postRunnable(callback); IntervalEvent& event = intervalEvents[i]; if (event.repeat == 0) { continue; From 67c913041e0d185b5e70dc1dc2f9cec4250af9a5 Mon Sep 17 00:00:00 2001 From: ostermine Date: Thu, 5 Nov 2026 13:46:49 +0300 Subject: [PATCH 10/12] fix headless tick rate: schedule ticks by deadlines ServerMainloop slept the rest of the tick and then restarted counting from the moment it woke up, so every sleep overshoot made the tick longer. With a coarse timer (a VirtualBox guest of a Windows host) --tps 20 gave 12-17 ticks per second. Ticks now follow absolute deadlines on steady_clock; after falling more than 5 ticks behind the schedule is reset instead of running a burst of ticks. The time of a tick is its scheduled time, so delta is exactly 1 / tps while the loop keeps up, as in test mode. With the wake-up time deltas jitter around 1 / tps, and the world tick clock, which calls on_world_tick at most once per update, skipped every few ticks. --- src/engine/ServerMainloop.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/engine/ServerMainloop.cpp b/src/engine/ServerMainloop.cpp index 9790723a9..6a0342c0f 100644 --- a/src/engine/ServerMainloop.cpp +++ b/src/engine/ServerMainloop.cpp @@ -35,16 +35,16 @@ void ServerMainloop::run() { double targetDelta = 1.0 / static_cast(coreParams.tps); double delta = targetDelta; - auto begin = system_clock::now(); - auto startupTime = begin; + const auto tickDuration = + duration_cast(duration(targetDelta)); + auto startupTime = steady_clock::now(); + auto nextTick = startupTime; while (!engine.isQuitSignal() && !engine.getAppScripts().isFinished()) { if (coreParams.testMode) { time.step(delta); } else { - auto now = system_clock::now(); - time.update( - duration_cast(now - startupTime).count() / 1e6); + time.update(duration(nextTick - startupTime).count()); delta = time.getDelta(); } if (controller) { @@ -55,13 +55,15 @@ void ServerMainloop::run() { engine.postUpdate(); if (!coreParams.testMode) { - auto end = system_clock::now(); - int64_t millis = targetDelta * 1000 - - duration_cast(end - begin).count() / 1000; - if (millis > 0) { - platform::sleep(millis); + nextTick += tickDuration; + auto now = steady_clock::now(); + if (nextTick > now) { + platform::sleep( + duration_cast(nextTick - now).count() + ); + } else if (now - nextTick > tickDuration * 5) { + nextTick = now; } - begin = system_clock::now(); } } logger.info() << "script finished"; From 457891594361f8a315a4c05e303010a4bb9a0c9c Mon Sep 17 00:00:00 2001 From: ostermine Date: Fri, 6 Nov 2026 03:49:26 +0300 Subject: [PATCH 11/12] fix math.random seed being the same on every launch stdlib.lua runs from scripting::initialize before the main loop starts, so time.uptime() is still 0 there and math.randomseed(time.uptime() * 1536227939) is math.randomseed(0). math.random() gave the same sequence on every launch, and so did the random seed placeholder of the "New World" page: every world created without typing a seed got the same seed. Seed from time.precise_utc_time() instead. --- res/scripts/stdlib.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 97d4e0342..d21fc10c3 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -410,7 +410,7 @@ require("core:io_stream").wrap_bytearray = require "core:internal/stream_provide network.__as_stream = require "core:internal/stream_providers/socket" -math.randomseed(time.uptime() * 1536227939) +math.randomseed(time.precise_utc_time()) rules = require "core:internal/rules" time.schedules = {} From f0a407c20a5eab0cb1c81f855a3724e995912273 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 12 Nov 2026 20:53:59 +0300 Subject: [PATCH 12/12] fix build warning --- src/voxels/Pathfinding.cpp | 3 +-- src/voxels/Pathfinding.hpp | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/voxels/Pathfinding.cpp b/src/voxels/Pathfinding.cpp index 7a3285b79..fd53c0e05 100644 --- a/src/voxels/Pathfinding.cpp +++ b/src/voxels/Pathfinding.cpp @@ -296,8 +296,7 @@ private: }; Pathfinding::Pathfinding(const Level& level) - : level(level), - chunks(*level.chunks), + : chunks(*level.chunks), blockDefs(level.content.getIndices()->blocks) { } diff --git a/src/voxels/Pathfinding.hpp b/src/voxels/Pathfinding.hpp index d81b51bee..d03bc2a12 100644 --- a/src/voxels/Pathfinding.hpp +++ b/src/voxels/Pathfinding.hpp @@ -89,7 +89,6 @@ namespace voxels { const std::unordered_map& getAgents() const; private: - const Level& level; const GlobalChunks& chunks; const ContentUnitIndices& blockDefs; std::unordered_map agents;