From 5a0a1cf326e6f3f594ef637c6eaae1a604ac9094 Mon Sep 17 00:00:00 2001 From: Astazium <113135541+Astazium@users.noreply.github.com> Date: Wed, 30 Sep 2026 20:43:43 +0300 Subject: [PATCH 01/43] ui fixes --- src/graphics/ui/elements/InlineFrame.cpp | 11 +++- src/graphics/ui/elements/SplitBox.cpp | 13 +++++ src/graphics/ui/elements/SplitBox.hpp | 1 + src/logic/scripting/scripting_functional.cpp | 54 ++++++++++++++------ 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/src/graphics/ui/elements/InlineFrame.cpp b/src/graphics/ui/elements/InlineFrame.cpp index 8699fd70b..acf00916e 100644 --- a/src/graphics/ui/elements/InlineFrame.cpp +++ b/src/graphics/ui/elements/InlineFrame.cpp @@ -35,8 +35,15 @@ void InlineFrame::setDocument(const std::shared_ptr& document) { root->setSize(size); - gui.postRunnable([this]() { - scripting::on_ui_open(*this->document, {}); + gui.postRunnable([weak = weak_from_this(), document]() { + auto node = weak.lock(); + if (node == nullptr) { + return; + } + if (static_cast(*node).document != document) { + return; + } + scripting::on_ui_open(*document, {}); }); } diff --git a/src/graphics/ui/elements/SplitBox.cpp b/src/graphics/ui/elements/SplitBox.cpp index 247ef7410..c35374529 100644 --- a/src/graphics/ui/elements/SplitBox.cpp +++ b/src/graphics/ui/elements/SplitBox.cpp @@ -82,6 +82,19 @@ void SplitBox::doubleClick(int x, int y) { refresh(); } +std::shared_ptr SplitBox::getAt(const glm::vec2& pos) { + auto hover = Container::getAt(pos); + if (hover.get() != this) { + return hover; + } + for (const auto& node : nodes) { + if (node->isVisible() && node->isInside(pos)) { + return nullptr; + } + } + return hover; +} + void SplitBox::fullRefresh() { refresh(); reposition(); diff --git a/src/graphics/ui/elements/SplitBox.hpp b/src/graphics/ui/elements/SplitBox.hpp index 8482e73ec..1a452c2ff 100644 --- a/src/graphics/ui/elements/SplitBox.hpp +++ b/src/graphics/ui/elements/SplitBox.hpp @@ -11,6 +11,7 @@ namespace gui { virtual void refresh() override; virtual void fullRefresh() override; virtual void doubleClick(int x, int y) override; + virtual std::shared_ptr getAt(const glm::vec2& pos) override; private: float splitPos; }; diff --git a/src/logic/scripting/scripting_functional.cpp b/src/logic/scripting/scripting_functional.cpp index a6ef42a48..c71133ca8 100644 --- a/src/logic/scripting/scripting_functional.cpp +++ b/src/logic/scripting/scripting_functional.cpp @@ -99,14 +99,21 @@ template std::function create_supplier( const scriptenv& env, const std::string& src, const std::string& file ) { - return [=]() { + return [=, errorLogged = false]() mutable { + lua::stackguard guard(lua::get_main_state()); if (auto L = process_callback(env, src, file)) { - if (lua::isfunction(L, -1)) { - lua::call_nothrow(L, 0); + if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) { + return T {}; + } + try { + return tovalueFunc(L, -1); + } catch (const std::exception& err) { + if (!errorLogged) { + logger.error() << "supplier " << util::quote(src) << ": " + << err.what(); + errorLogged = true; + } } - auto str = tovalueFunc(L, -1); - lua::pop(L); - return str; } return T {}; }; @@ -158,16 +165,33 @@ int_array_consumer scripting::create_int_array_consumer( vec2supplier scripting::create_vec2_supplier( const scriptenv& env, const std::string& src, const std::string& file ) { - return [=]() { - if (auto L = process_callback(env, src, file)) { - if (lua::isfunction(L, -1)) { - lua::call_nothrow(L, 0); + return [=, errorLogged = false]() mutable { + auto L = lua::get_main_state(); + lua::stackguard guard(L); + int top = lua::gettop(L); + if (process_callback(env, src, file)) { + if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) { + return glm::vec2(0, 0); + } + if (lua::gettop(L) - top < 2) { + if (!errorLogged) { + logger.error() << "supplier " << util::quote(src) + << ": two numbers expected"; + errorLogged = true; + } + return glm::vec2(0, 0); + } + try { + auto y = lua::tonumber(L, -1); + auto x = lua::tonumber(L, -2); + return glm::vec2(x, y); + } catch (const std::exception& err) { + if (!errorLogged) { + logger.error() << "supplier " << util::quote(src) << ": " + << err.what(); + errorLogged = true; + } } - auto y = lua::tonumber(L, -1); - lua::pop(L); - auto x = lua::tonumber(L, -1); - lua::pop(L); - return glm::vec2(x, y); } return glm::vec2(0, 0); }; From ef85592e21320bbc121d439c919379ba92e97f5e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 21:21:33 +0300 Subject: [PATCH 02/43] fix chunks render limits --- src/graphics/render/ChunksRenderer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/graphics/render/ChunksRenderer.cpp b/src/graphics/render/ChunksRenderer.cpp index 82a7fa6d6..6cccbe3fa 100644 --- a/src/graphics/render/ChunksRenderer.cpp +++ b/src/graphics/render/ChunksRenderer.cpp @@ -22,7 +22,7 @@ static debug::Logger logger("chunks-render"); size_t ChunksRenderer::visibleChunks = 0; -static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 4; +static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 64; class RendererWorker : public util::Worker { BlocksRenderer renderer; @@ -197,8 +197,7 @@ void ChunksRenderer::update() { int loadDistance = settings.chunks.loadDistance.get(); - const int topN = 10; - int top = std::min(meshBuildQueue.size(), topN); + int top = std::min(meshBuildQueue.size(), MAX_CHUNKS_ENQUEUED_IN_FRAME); for (int i = 0; i < top; i++) { glm::ivec2 offset = meshBuildQueue[i]; size_t index = From 3c7755f61bab3e3311a089d8b99024ad081d1c10 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 21:39:18 +0300 Subject: [PATCH 03/43] fix 'selectable' with static entities --- src/objects/Entities.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index c2ce479c6..46746684e 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -328,14 +328,17 @@ void Entities::preparePhysics(float delta) { auto view = registry->view(); for (auto [entity, eid, rigidbody] : view.each()) { auto bodyType = rigidbody.hitbox.type; - if (eid.destroyFlag || !rigidbody.enabled || bodyType == BodyType::STATIC) { + if (eid.destroyFlag || !rigidbody.enabled) { continue; } + rigidbody.hitbox.selectable = rigidbody.selectable; rigidbody.hitbox.mass = bodyType == BodyType::DYNAMIC ? rigidbody.mass : std::numeric_limits::infinity(); rigidbody.hitbox.elasticity = rigidbody.elasticity; - rigidbody.hitbox.selectable = rigidbody.selectable; + if (bodyType == BodyType::STATIC) { + continue; + } hitboxes.emplace_back(&rigidbody.hitbox); if (!eid.def.solid) { continue; From 446b6edd03d0b25e3531160025851fc45248448c Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 21:57:16 +0300 Subject: [PATCH 04/43] update doc/*/scripting/ecs.md --- doc/en/scripting/ecs.md | 6 ++++-- doc/ru/scripting/ecs.md | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/en/scripting/ecs.md b/doc/en/scripting/ecs.md index 0473fc852..0968e2d8d 100644 --- a/doc/en/scripting/ecs.md +++ b/doc/en/scripting/ecs.md @@ -185,9 +185,11 @@ rig:index(name: str) -> int -- or the skeleton if no index is specified rig:is_visible([optional] index: int) -> bool +-- Sets the visibility status of the skeleton +rig:set_visible(status: bool) + -- Sets the visibility status of a bone by index --- or the skeleton if no index is specified -rig:set_visible([optional] index: int, status: bool) +rig:set_visible(index: int, status: bool) -- Returns the color of the entity rig:get_color() -> vec4 diff --git a/doc/ru/scripting/ecs.md b/doc/ru/scripting/ecs.md index d6a823cf0..fb03721c6 100644 --- a/doc/ru/scripting/ecs.md +++ b/doc/ru/scripting/ecs.md @@ -174,9 +174,11 @@ rig:index(name: str) -> int -- или всего скелета, если индекс не указан rig:is_visible([optional] index: int) -> bool +-- Устанавливает статус видимости всего скелета +rig:set_visible(status: bool) + -- Устанавливает статус видимости кости по индексу --- или всего скелета, если индекс не указан -rig:set_visible([optional] index: int, status: bool) +rig:set_visible(index: int, status: bool) -- Возвращает цвет сущности rig:get_color() -> vec4 From 76e5e5b6f847e597d53180802957517701de7b8a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 22:11:21 +0300 Subject: [PATCH 05/43] fix vca 'configure' directive parsing --- res/modules/internal/formats/vca.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 4ecf4c895..c44d28904 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -18,12 +18,12 @@ local curve_to_interp = { local function parse_configure(raw_track, node) if node.fps then - raw_track.fps = node.fps + raw_track.fps = tonumber(node.fps) end if node.frames then - raw_track.duration = node.frames / (node.fps or DEFAULT_FPS) + raw_track.duration = tonumber(node.frames) / (tonumber(raw_track.fps) or DEFAULT_FPS) elseif node.duration then - raw_track.duration = node.duration + raw_track.duration = tonumber(node.duration) end raw_track.rotation_order = string.upper(node["rotation-order"] or "XYZ") end From cdc32173c385ea80419762e69cada1501a7107d2 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 22:26:04 +0300 Subject: [PATCH 06/43] update doc/*/xml-ui-layouts.md --- doc/en/xml-ui-layouts.md | 3 +++ doc/ru/xml-ui-layouts.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/doc/en/xml-ui-layouts.md b/doc/en/xml-ui-layouts.md index 704a0b786..8d04ff4ec 100644 --- a/doc/en/xml-ui-layouts.md +++ b/doc/en/xml-ui-layouts.md @@ -215,6 +215,9 @@ Element is a container. Does not have specific attributes. > [!WARNING] > Inventories position is controlled by the engine and can not be changed by attributes *pos* and *margin* +> [!WARNING] +> Slots not linked to an inventory will not be displayed. "Linked to an inventory" refers to the association between an inventory UI element and an inventory via an ID. This link can be explicitly established using `inventory_ui.inventory = inventory_id`. [(see ui.md)](scripting/ui.md#inventory) + ## *slot* Element must be in direct sub-element of *inventory*. diff --git a/doc/ru/xml-ui-layouts.md b/doc/ru/xml-ui-layouts.md index 9be788e7f..94f396495 100644 --- a/doc/ru/xml-ui-layouts.md +++ b/doc/ru/xml-ui-layouts.md @@ -216,6 +216,9 @@ > [!WARNING] > Расположение инвентарей управляется движком и не может быть изменено свойствами pos, margin и т.д. +> [!WARNING] +> Слоты без привязки к инвентарю не будут отображаться. Под приязкой к инвентарю понимается связь UI элемента inventory с инвентарём по id. Которая может быть явно создана через `inventory_ui.inventory = inventory_id`. [(см ui.md)](scripting/ui.md#инвентарь-inventory) + ## Одиночный слот - *slot* Элемент должен находиться внутри `inventory` элемента, без посредников. From cf35023adfb504cabf3bd825dd2079743f24f46f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 6 Oct 2026 12:53:50 +0300 Subject: [PATCH 07/43] fix 'mouse:' input prefix is not available --- src/delegates.hpp | 2 +- src/logic/scripting/lua/libs/libinput.cpp | 5 ++++- src/logic/scripting/lua/lua_util.cpp | 2 +- src/logic/scripting/lua/lua_util.hpp | 2 +- src/window/detail/GLFWWindow.cpp | 9 ++++++++- src/window/input.hpp | 5 +++-- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/delegates.hpp b/src/delegates.hpp index f583f951d..abd489ca2 100644 --- a/src/delegates.hpp +++ b/src/delegates.hpp @@ -8,7 +8,7 @@ using runnable = std::function; template using supplier = std::function; template using consumer = std::function; -using KeyCallback = std::function; +using InputCallback = std::function; // data sources using wstringsupplier = std::function; diff --git a/src/logic/scripting/lua/libs/libinput.cpp b/src/logic/scripting/lua/libs/libinput.cpp index 68469bb23..352da415a 100644 --- a/src/logic/scripting/lua/libs/libinput.cpp +++ b/src/logic/scripting/lua/libs/libinput.cpp @@ -44,10 +44,13 @@ static int l_add_callback(lua::State* L) { auto& input = engine->getInput(); if (pos != std::string::npos) { - std::string prefix = bindname.substr(0, pos); + auto prefix = std::string_view(bindname).substr(0, pos); if (prefix == "key") { auto key = input_util::keycode_from(bindname.substr(pos + 1)); handler = input.addKeyCallback(key, actual_callback); + } else if (prefix == "mouse") { + auto mouse = input_util::mousecode_from(bindname.substr(pos + 1)); + handler = input.addMouseCallback(mouse, actual_callback); } } diff --git a/src/logic/scripting/lua/lua_util.cpp b/src/logic/scripting/lua/lua_util.cpp index 6457911b0..d1ca02473 100644 --- a/src/logic/scripting/lua/lua_util.cpp +++ b/src/logic/scripting/lua/lua_util.cpp @@ -263,7 +263,7 @@ runnable lua::create_runnable(State* L) { }; } -KeyCallback lua::create_simple_handler(State* L) { +InputCallback lua::create_simple_handler(State* L) { auto funcptr = create_lambda_handler(L); return [=]() -> bool { if (!get_from_registry(L, LAMBDAS_TABLE, *funcptr, false)) { diff --git a/src/logic/scripting/lua/lua_util.hpp b/src/logic/scripting/lua/lua_util.hpp index 61b56cef3..690fcb32d 100644 --- a/src/logic/scripting/lua/lua_util.hpp +++ b/src/logic/scripting/lua/lua_util.hpp @@ -665,7 +665,7 @@ namespace lua { } runnable create_runnable(lua::State*); - KeyCallback create_simple_handler(lua::State*); + InputCallback create_simple_handler(lua::State*); scripting::common_func create_lambda(lua::State*); scripting::common_func create_lambda_nothrow(lua::State*); diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index ca168a064..08b39bd07 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -216,10 +216,17 @@ public: return bindings; } - ObserverHandler addKeyCallback(Keycode key, KeyCallback callback) override { + ObserverHandler addKeyCallback(Keycode key, InputCallback callback) override { return keyCallbacks[key].add(std::move(callback)); } + ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) override { + return addKeyCallback( + static_cast(MOUSE_KEYS_OFFSET + static_cast(button)), + std::move(callback) + ); + } + const std::vector& getPressedKeys() const override { return pressedKeys; } diff --git a/src/window/input.hpp b/src/window/input.hpp index 59d663672..839eeca96 100644 --- a/src/window/input.hpp +++ b/src/window/input.hpp @@ -288,12 +288,13 @@ public: virtual const Bindings& getBindings() const = 0; - virtual ObserverHandler addKeyCallback(Keycode key, KeyCallback callback) = 0; + virtual ObserverHandler addKeyCallback(Keycode key, InputCallback callback) = 0; + virtual ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) = 0; virtual const std::vector& getPressedKeys() const = 0; virtual const std::vector& getCodepoints() const = 0; - ObserverHandler addCallback(const std::string& name, KeyCallback callback) { + ObserverHandler addCallback(const std::string& name, InputCallback callback) { return getBindings().require(name).onactived.add(callback); } }; From d4d6235b2bed7c41b85ea93521222975e6777102 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 6 Oct 2026 20:53:48 +0300 Subject: [PATCH 08/43] start 0.33 development --- doc/en/main-page.md | 4 ++++ doc/ru/main-page.md | 4 ++++ res/content/base/package.json | 2 +- src/constants.hpp | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/en/main-page.md b/doc/en/main-page.md index 1f91efdc5..93e592b62 100644 --- a/doc/en/main-page.md +++ b/doc/en/main-page.md @@ -1,5 +1,9 @@ # Documentation +>![WARNING] +> This branch is used for VoxelCore 0.33 development, API is unstable. +> [Proceed to VoxelCore 0.32 documentation](https://github.com/MihailRis/voxelcore/blob/release-0.32/doc/en/main-page.md) + ## Sections - [Assets preloading](assets-preload.md) diff --git a/doc/ru/main-page.md b/doc/ru/main-page.md index b826d9dfd..66e1b523a 100644 --- a/doc/ru/main-page.md +++ b/doc/ru/main-page.md @@ -1,5 +1,9 @@ # Документация +>![WARNING] +> В этой ветке ведётся разработка VoxelCore 0.33, API нестабилен. +> [Перейти к документации VoxelCore 0.32](https://github.com/MihailRis/voxelcore/blob/release-0.32/doc/ru/main-page.md) + ## Разделы - [XML разметка интерфейса](xml-ui-layouts.md) diff --git a/res/content/base/package.json b/res/content/base/package.json index 71b4dca9f..11eb30f3e 100644 --- a/res/content/base/package.json +++ b/res/content/base/package.json @@ -1,6 +1,6 @@ { "id": "base", "title": "Base", - "version": "0.32", + "version": "0.33", "description": "basic content package" } diff --git a/src/constants.hpp b/src/constants.hpp index 03900b9e3..c9fc60d32 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -6,7 +6,7 @@ #include inline constexpr int ENGINE_VERSION_MAJOR = 0; -inline constexpr int ENGINE_VERSION_MINOR = 32; +inline constexpr int ENGINE_VERSION_MINOR = 33; #ifdef NDEBUG inline constexpr bool ENGINE_DEBUG_BUILD = false; @@ -14,7 +14,7 @@ inline constexpr bool ENGINE_DEBUG_BUILD = false; inline constexpr bool ENGINE_DEBUG_BUILD = true; #endif // NDEBUG -inline const std::string ENGINE_VERSION_STRING = "0.32"; +inline const std::string ENGINE_VERSION_STRING = "0.33"; inline constexpr uint MAX_SUBPROCESSES = 1; inline constexpr uint MAX_SUBPROCESS_DEPTH = 2; From 0b52369ed9e6a3e9c7453292d388c12cdfb7778a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 6 Oct 2026 21:31:02 +0300 Subject: [PATCH 09/43] cleanup --- res/modules/internal/formats/vca.lua | 98 ++++++++++++++-------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index c44d28904..26f4afa8d 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -62,6 +62,54 @@ local function parse_simple_frames(line, node) end end +local function parse_directive(node, raw_track) + local linesets = raw_track.linesets + local tag = node['#'] + if tag == "configure" then + parse_configure(raw_track, node) + return + elseif tag == "curve" then + raw_track.curves[node.name] = node + return + end + + local target_type = nil + if node.bone then + target_type = "bone" + elseif tag == "texture" then + target_type = "texture" + end + local target_name = node.bone or node.name or "" + local lineset = linesets[target_name] + if not lineset then + lineset = { + lines = {}, + target_type = target_type, + target_name = target_name + } + linesets[target_name] = lineset + end + + local channel = action_to_channel[tag] + if not channel then + error("unknown directive " .. tag:escape()) + end + local line = { + axis = node.by and ("xyz"):find(node.by) or "", + channel = channel, + period = node.period or animation.MAX_FRAMES + } + if node.func then + line.expression = node.func + elseif node.curve then + parse_curve(line, node) + else + parse_simple_frames(line, node) + end + + table.insert(lineset.lines, line) +end + local function parse_track(root) local raw_track = { duration = math.huge, @@ -69,56 +117,10 @@ local function parse_track(root) linesets = {}, curves = {}, } - local linesets = raw_track.linesets for i, node in ipairs(root) do - if type(node) == "string" then - goto continue + if type(node) == 'table' then + parse_directive(node, raw_track) end - local tag = node['#'] - if tag == "configure" then - parse_configure(raw_track, node) - goto continue - elseif tag == "curve" then - raw_track.curves[node.name] = node - goto continue - end - - local target_type = nil - if node.bone then - target_type = "bone" - elseif tag == "texture" then - target_type = "texture" - end - local target_name = node.bone or node.name or "" - local lineset = linesets[target_name] - if not lineset then - lineset = { - lines = {}, - target_type = target_type, - target_name = target_name - } - linesets[target_name] = lineset - end - - local channel = action_to_channel[tag] - if not channel then - error("unknown directive " .. tag:escape()) - end - local line = { - axis = node.by and ("xyz"):find(node.by) or "", - channel = channel, - period = node.period or animation.MAX_FRAMES - } - if node.func then - line.expression = node.func - elseif node.curve then - parse_curve(line, node) - else - parse_simple_frames(line, node) - end - - table.insert(lineset.lines, line) - ::continue:: end return raw_track end From fdd62e2e19b7194aa47c67839073bb3672b8b0ba Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 18:20:51 +0300 Subject: [PATCH 10/43] remove unused feature --- res/modules/internal/animation_codegen.lua | 32 ++++++---------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 525240f66..39ba4f20f 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,7 +15,7 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised, mode) +local function process_expression(src, mode) if mode == 'mul' then src = string.format("(%s) * intensity + (1.0 - intensity)", src) elseif mode == "add" then @@ -30,7 +30,6 @@ local function process_expression(src, memoised, mode) for i, pattern in ipairs(patterns) do local pattern_safe = string.pattern_safe(pattern.pattern) if src:find(pattern_safe) then - memoised[pattern.name] = pattern.pattern src = src:gsub(pattern_safe, pattern.name) end end @@ -137,7 +136,7 @@ local is_multiplier = { [animation.CH_ZOOM] = true, } -local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) +local function codegen_track(raw_track, lineset, keysets, use_tsf) local lines = lineset.lines local code = "" local has_tsf = false @@ -147,7 +146,7 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) for i, line in ipairs(lines) do if line.expression then code = code .. "\n local l" .. i .. " = (" .. - process_expression(line.expression, memoised, + process_expression(line.expression, is_multiplier[line.channel] and "mul" or "add") .. ")" elseif line.keys then local target_keysets = keysets[lineset.target_name] @@ -229,8 +228,7 @@ local function codegen_rig_target(raw_track, context) if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then goto continue end - local lineset_code = codegen_track( - raw_track, lineset, context.memoised, context.keysets, true) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) code = code .. string.format("\n local bone_index = target:index(%s)" @@ -252,8 +250,7 @@ local function codegen_object_target(raw_track, context) if not lineset then return "" end - local lineset_code = codegen_track( - raw_track, lineset, context.memoised, context.keysets, true) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) code = code .. "\n do" .. lineset_code .. "\n end\n" .. " set_matrix(target, dst)\n" return code .. " end" @@ -266,8 +263,7 @@ local function codegen_camera_target(raw_track, context) if not lineset then return "" end - local lineset_code = codegen_track( - raw_track, lineset, context.memoised, context.keysets, false) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, false) code = code .. "\n do" .. lineset_code .. "\n end\n" .. " target:set_zoom(zoom)\n" return code .. " end" @@ -277,14 +273,13 @@ end function internals.compile_animation_track(raw_track, track_name) local code = "" local context = { - memoised = {}, keysets = {}, curves = {}, } for name, curve in pairs(raw_track.curves) do context.curves[name] = load(string.format( "return function(kl, kr, t) return %s end", - process_expression(curve.func, context.memoised, "curve") + process_expression(curve.func, "curve") ), "", "t", env)() end @@ -292,17 +287,8 @@ function internals.compile_animation_track(raw_track, track_name) code = code .. codegen_object_target(raw_track, context) code = code .. codegen_camera_target(raw_track, context) - local memoised_code = "" - for name, expression in pairs(context.memoised) do - memoised_code = memoised_code .. "\n local " .. name .. " = " - .. expression - end - - if #memoised_code > 0 then - code = memoised_code .. "\n" .. code - end - - local src = "return function(target, t, intensity, m)\n m = m or 1\n intensity = intensity or 1.0\n" + local src = "return function(target, t, intensity, m)\n" + .. "m = m or 1\n intensity = intensity or 1.0\n" .. code .. "\nend" if animation.TRACE_CODEGEN then From b21f4d4439405838a06491a28d8f8070d741a6ac Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 19:55:19 +0300 Subject: [PATCH 11/43] refactor animation_codegen.lua --- res/modules/internal/animation_codegen.lua | 81 +++++++++++++--------- 1 file changed, 49 insertions(+), 32 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 39ba4f20f..272b6c536 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -136,6 +136,32 @@ local is_multiplier = { [animation.CH_ZOOM] = true, } +local function codegen_line(raw_track, lineset, line, index, keysets) + if line.expression then + return "(" .. process_expression(line.expression, + is_multiplier[line.channel] and "mul" or "add") .. ")" + elseif line.keys then + local target_keysets = keysets[lineset.target_name] + if not target_keysets then + target_keysets = {} + keysets[lineset.target_name] = target_keysets + end + target_keysets[index] = line.keys + + if line.curve_func then + local valueat = string.format("curves[%s]", string.escape(line.curve_func)) + return string.format("value_at_custom(keysets['%s'][%d], t * %s %% %s, %s)", + lineset.target_name, index, raw_track.fps, line.period, valueat) + elseif line.channel == animation.CH_TEXTURE then + return string.format("string_at(keysets['%s'][%d], t * %s %% %s)", + lineset.target_name, index, raw_track.fps, line.period) + else + return string.format("value_at(keysets['%s'][%d], t * %s %% %s, %s)", + lineset.target_name, index, raw_track.fps, line.period, line.interp) + end + end +end + local function codegen_track(raw_track, lineset, keysets, use_tsf) local lines = lineset.lines local code = "" @@ -144,34 +170,8 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf) local rotation = {false, false, false} local scale = {false, false, false} for i, line in ipairs(lines) do - if line.expression then - code = code .. "\n local l" .. i .. " = (" .. - process_expression(line.expression, - is_multiplier[line.channel] and "mul" or "add") .. ")" - elseif line.keys then - local target_keysets = keysets[lineset.target_name] - if not target_keysets then - target_keysets = {} - keysets[lineset.target_name] = target_keysets - end - target_keysets[i] = line.keys - - if line.curve_func then - local valueat = string.format("curves[%s]", string.escape(line.curve_func)) - - code = code .. string.format( - "\n local l%d = value_at_custom(keysets['%s'][%d], t * %s %% %s, %s)", - i, lineset.target_name, i, raw_track.fps, line.period, valueat) - elseif line.channel == animation.CH_TEXTURE then - code = code .. string.format( - "\n local l%d = string_at(keysets['%s'][%d], t * %s %% %s)", - i, lineset.target_name, i, raw_track.fps, line.period) - else - code = code .. string.format( - "\n local l%d = value_at(keysets['%s'][%d], t * %s %% %s, %s)", - i, lineset.target_name, i, raw_track.fps, line.period, line.interp) - end - end + code = code .. string.format("\n local l%d = ", i) + .. codegen_line(raw_track, lineset, line, i, keysets) if line.channel == animation.CH_TRANSLATE then translation[line.axis] = i @@ -185,7 +185,8 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf) elseif line.channel == animation.CH_ZOOM then code = code .. "\n zoom = l" .. i elseif line.channel == animation.CH_TEXTURE then - code = code .. string.format("\n target:set_texture(%s, %s)", lineset.target_name:escape(), "l"..i) + code = code .. string.format("\n target:set_texture(%s, %s)", + lineset.target_name:escape(), "l"..i) end end @@ -270,11 +271,25 @@ local function codegen_camera_target(raw_track, context) end +local function has_transform_directive(raw_track) + for _, lineset in pairs(raw_track.linesets) do + for _, line in ipairs(lineset.lines) do + if line.channel == animation.CH_TRANSLATE or + line.channel == animation.CH_ROTATE or + line.channel == animation.CH_SCALE then + return true + end + end + end + return false +end + function internals.compile_animation_track(raw_track, track_name) local code = "" local context = { keysets = {}, curves = {}, + has_tsf = has_transform_directive(raw_track), } for name, curve in pairs(raw_track.curves) do context.curves[name] = load(string.format( @@ -283,12 +298,14 @@ function internals.compile_animation_track(raw_track, track_name) ), "", "t", env)() end - code = code .. codegen_rig_target(raw_track, context) - code = code .. codegen_object_target(raw_track, context) + if context.has_tsf then + code = code .. codegen_rig_target(raw_track, context) + code = code .. codegen_object_target(raw_track, context) + end code = code .. codegen_camera_target(raw_track, context) local src = "return function(target, t, intensity, m)\n" - .. "m = m or 1\n intensity = intensity or 1.0\n" + .. " m = m or 1\n intensity = intensity or 1.0\n" .. code .. "\nend" if animation.TRACE_CODEGEN then From fed89b64c798ac3e1e121af3247d9ce5c0ea6f89 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 20:51:33 +0300 Subject: [PATCH 12/43] add 'control' VCA directive and 'visible' flag --- res/modules/animation.lua | 13 ++++++----- res/modules/internal/animation_codegen.lua | 26 +++++++++++++--------- res/modules/internal/formats/vca.lua | 17 +++++++++++++- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 0c7bb7741..b2cc56879 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -39,12 +39,13 @@ local function bezier_interpolation(k0, k1, t) return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u) end -local this = { +local M = { CH_TRANSLATE = 1, CH_ROTATE = 2, CH_SCALE = 3, CH_ZOOM = 4, CH_TEXTURE = 5, + CH_CONTROL = 6, INT_CONST = 1, INT_LINEAR = 2, @@ -53,7 +54,7 @@ local this = { MAX_DURATION = 1e9, MAX_FRAMES = 1e9, - TRACE_CODEGEN = false, + TRACE_CODEGEN = true, maths = { bezier_interpolation = bezier_interpolation @@ -67,14 +68,14 @@ function internals.store_animation(name, track) loaded_tracks[name] = track end -function this.get_track(identifier) +function M.get_track(identifier) return loaded_tracks[identifier] end local running_actions = {} local playing_tracks = {} -function this.action(func) +function M.action(func) table.insert(running_actions, coroutine.create(func)) end @@ -98,7 +99,7 @@ local PlayingTrack = { } } -function this.play(name, target) +function M.play(name, target) if target and target.reset_pose then target:reset_pose() end @@ -156,4 +157,4 @@ function internals.restore_animation_backup() loaded_tracks, backup_tracks = backup_tracks, {} end -return this +return M diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 272b6c536..824070a18 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -75,7 +75,7 @@ local env = { return keys[left].value end left = keys[left] - if interp == INT_CONST then + if not interp or interp == INT_CONST then return left.value end right = keys[right] @@ -170,7 +170,7 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf) local rotation = {false, false, false} local scale = {false, false, false} for i, line in ipairs(lines) do - code = code .. string.format("\n local l%d = ", i) + code = code .. string.format("\n local l%d = ", i) .. codegen_line(raw_track, lineset, line, i, keysets) if line.channel == animation.CH_TRANSLATE then @@ -185,8 +185,12 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf) elseif line.channel == animation.CH_ZOOM then code = code .. "\n zoom = l" .. i elseif line.channel == animation.CH_TEXTURE then - code = code .. string.format("\n target:set_texture(%s, %s)", - lineset.target_name:escape(), "l"..i) + code = code .. string.format("\n target:set_texture(%s, l%d)", + lineset.target_name:escape(), i) + elseif line.channel == animation.CH_CONTROL then + if lineset.flag == "visible" then + code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) + end end end @@ -231,11 +235,13 @@ local function codegen_rig_target(raw_track, context) end local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) + code = code .. string.format("\n local bone_index = target:index(%s)", string.escape(bone)) + if context.has_tsf then + code = code .. "\n local dst = target:get_matrix(bone_index)" + end code = code - .. string.format("\n local bone_index = target:index(%s)" - .. "\n local dst = target:get_matrix(bone_index)", string.escape(bone)) .. "\n do" .. lineset_code .. "\n end\n" - if lineset.target_type == "bone" then + if lineset.target_type == "bone" and context.has_tsf then code = code .. " target:set_matrix(bone_index, dst)\n" end @@ -298,10 +304,8 @@ function internals.compile_animation_track(raw_track, track_name) ), "", "t", env)() end - if context.has_tsf then - code = code .. codegen_rig_target(raw_track, context) - code = code .. codegen_object_target(raw_track, context) - end + code = code .. codegen_rig_target(raw_track, context) + code = code .. codegen_object_target(raw_track, context) code = code .. codegen_camera_target(raw_track, context) local src = "return function(target, t, intensity, m)\n" diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 26f4afa8d..d87f5716c 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -8,6 +8,7 @@ local action_to_channel = { scale = animation.CH_SCALE, zoom = animation.CH_ZOOM, texture = animation.CH_TEXTURE, + control = animation.CH_CONTROL, } local curve_to_interp = { @@ -62,6 +63,17 @@ local function parse_simple_frames(line, node) end end +local function parse_boolean_frames(line, node) + line.keys = {} + for j, key_node in ipairs(node) do + local keyframe = { + frame = tonumber(key_node.frame), + value = key_node.value == "on", + } + table.insert(line.keys, keyframe) + end +end + local function parse_directive(node, raw_track) local linesets = raw_track.linesets local tag = node['#'] @@ -85,7 +97,8 @@ local function parse_directive(node, raw_track) lineset = { lines = {}, target_type = target_type, - target_name = target_name + target_name = target_name, + flag = node.flag, } linesets[target_name] = lineset end @@ -103,6 +116,8 @@ local function parse_directive(node, raw_track) line.expression = node.func elseif node.curve then parse_curve(line, node) + elseif node.flag then + parse_boolean_frames(line, node) else parse_simple_frames(line, node) end From 1f2e938d83712a69da27aede140038fa64d01e4f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 22:32:11 +0300 Subject: [PATCH 13/43] feat: control flag visible for whole skeleton support --- res/modules/internal/animation_codegen.lua | 27 +++++++++++++++------- res/modules/internal/formats/vca.lua | 2 ++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 824070a18..169b08163 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -162,13 +162,18 @@ local function codegen_line(raw_track, lineset, line, index, keysets) end end -local function codegen_track(raw_track, lineset, keysets, use_tsf) +local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) + if lineset.target_type ~= target_type then + return "" + end + local lines = lineset.lines local code = "" local has_tsf = false local translation = {false, false, false} local rotation = {false, false, false} local scale = {false, false, false} + for i, line in ipairs(lines) do code = code .. string.format("\n local l%d = ", i) .. codegen_line(raw_track, lineset, line, i, keysets) @@ -189,7 +194,11 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf) lineset.target_name:escape(), i) elseif line.channel == animation.CH_CONTROL then if lineset.flag == "visible" then - code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) + if target_type == "bone" then + code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) + else + code = code .. string.format("\n target:set_visible(l%d)", i) + end end end end @@ -233,7 +242,7 @@ local function codegen_rig_target(raw_track, context) if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then goto continue end - local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, true, "bone") code = code .. string.format("\n local bone_index = target:index(%s)", string.escape(bone)) if context.has_tsf then @@ -251,16 +260,18 @@ local function codegen_rig_target(raw_track, context) end local function codegen_object_target(raw_track, context) - local code = "\n if target.set_pos then\n" - code = code .. " local dst = mat4.idt()\n" + local code = " local dst = mat4.idt()\n" local lineset = raw_track.linesets[""] if not lineset then return "" end local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) code = code .. "\n do" .. lineset_code .. "\n end\n" - .. " set_matrix(target, dst)\n" - return code .. " end" + + if context.has_tsf then + code = code .. " set_matrix(target, dst)\n" + end + return code end local function codegen_camera_target(raw_track, context) @@ -270,7 +281,7 @@ local function codegen_camera_target(raw_track, context) if not lineset then return "" end - local lineset_code = codegen_track(raw_track, lineset, context.keysets, false) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, false, "camera") code = code .. "\n do" .. lineset_code .. "\n end\n" .. " target:set_zoom(zoom)\n" return code .. " end" diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index d87f5716c..9ce4b6230 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -88,6 +88,8 @@ local function parse_directive(node, raw_track) local target_type = nil if node.bone then target_type = "bone" + elseif node.zoom then + target_type = "camera" elseif tag == "texture" then target_type = "texture" end From bbe1873bc71d027976ac5920cc2243b5957447fa Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 22:51:57 +0300 Subject: [PATCH 14/43] update doc/*/vca.md --- doc/en/vca.md | 18 ++++++++++++++++++ doc/ru/vca.md | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/doc/en/vca.md b/doc/en/vca.md index 7b2bda0b5..722432e31 100644 --- a/doc/en/vca.md +++ b/doc/en/vca.md @@ -28,6 +28,7 @@ Two kinds of curve definitions are currently available, each producing a value ` - `@scale` - scales an object/bone (multiplier) - `@zoom` - camera zoom (multiplier) - `@texture` - change of a dynamically assigned texture (see [skeleton:set_texture](scripting/ecs.md#skeleton)) +- `@control` - changing flag values, such as visibility ## Metadata @@ -96,6 +97,23 @@ If you do not wish to limit the animation duration via `configure` but want to l } ``` +Example of using the `control` directive: + +```vcd +# Specific bone +@control bone head flag visible period 20 { + @key frame 0 value on + @key frame 10 value off +} + +# Entire skeleton +@control flag visible period 30 { + @key frame 0 value on + @key frame 10 value off +} + +``` + ## Expression curves The attribute describes a function `f(t) = x`, where t is time in seconds. diff --git a/doc/ru/vca.md b/doc/ru/vca.md index 2cba3c3ab..91c252833 100644 --- a/doc/ru/vca.md +++ b/doc/ru/vca.md @@ -28,6 +28,7 @@ VCA файл состоит из набора директив, порядок - `@scale` - масштабирование объекта/кости (множитель) - `@zoom` - масштаб камеры (множитель) - `@texture` - смена динамически-назначаемой текстуры (см. [skeleton:set_texture](scripting/ecs.md#skeleton)) +- `@control` - изменение значений флагов, таких как видимость ## Мета-информация @@ -96,6 +97,23 @@ VCA файл состоит из набора директив, порядок } ``` +Пример использования директивы `control`: + +```vcd +# Конкретная кость +@control bone head flag visible period 20 { + @key frame 0 value on + @key frame 10 value off +} + +# Весь скелет +@control flag visible period 30 { + @key frame 0 value on + @key frame 10 value off +} + +``` + ## Кривые через выражения Через атрибут описывается функция `f(t) = x` где t - время в секундах. From 5060a8635deca8f8a9867fcd4006988f48a5b432 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 23:09:40 +0300 Subject: [PATCH 15/43] fix locked cursor if world was closed with menu hidden --- src/frontend/screens/MenuScreen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/screens/MenuScreen.cpp b/src/frontend/screens/MenuScreen.cpp index 6472578d9..d9628ceb3 100644 --- a/src/frontend/screens/MenuScreen.cpp +++ b/src/frontend/screens/MenuScreen.cpp @@ -28,7 +28,10 @@ MenuScreen::~MenuScreen() = default; void MenuScreen::onOpen() { engine.getContentControl().resetContent({}); - auto menu = engine.getGUI().getMenu(); + auto& gui = engine.getGUI(); + gui.setActiveFrame(gui::GUI::CORE_MAIN); + + auto menu = gui.getMenu(); menu->reset(); } From 26d09f750b91c1177ca21c1f27788d77cd392780 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 8 Oct 2026 23:24:09 +0300 Subject: [PATCH 16/43] replace control with show for visibility --- res/modules/animation.lua | 2 +- res/modules/internal/animation_codegen.lua | 12 +++++------- res/modules/internal/formats/vca.lua | 8 ++++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index b2cc56879..fd43ac9f9 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -45,7 +45,7 @@ local M = { CH_SCALE = 3, CH_ZOOM = 4, CH_TEXTURE = 5, - CH_CONTROL = 6, + CH_SHOW = 6, INT_CONST = 1, INT_LINEAR = 2, diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 169b08163..eb08c2afb 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -192,13 +192,11 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) elseif line.channel == animation.CH_TEXTURE then code = code .. string.format("\n target:set_texture(%s, l%d)", lineset.target_name:escape(), i) - elseif line.channel == animation.CH_CONTROL then - if lineset.flag == "visible" then - if target_type == "bone" then - code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) - else - code = code .. string.format("\n target:set_visible(l%d)", i) - end + elseif line.channel == animation.CH_SHOW then + if target_type == "bone" then + code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) + else + code = code .. string.format("\n target:set_visible(l%d)", i) end end end diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 9ce4b6230..66f1945d7 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -8,7 +8,7 @@ local action_to_channel = { scale = animation.CH_SCALE, zoom = animation.CH_ZOOM, texture = animation.CH_TEXTURE, - control = animation.CH_CONTROL, + show = animation.CH_SHOW, } local curve_to_interp = { @@ -17,6 +17,10 @@ local curve_to_interp = { bezier = animation.INT_BEZIER, } +local boolean_actions = { + show = true +} + local function parse_configure(raw_track, node) if node.fps then raw_track.fps = tonumber(node.fps) @@ -118,7 +122,7 @@ local function parse_directive(node, raw_track) line.expression = node.func elseif node.curve then parse_curve(line, node) - elseif node.flag then + elseif boolean_actions[tag] then parse_boolean_frames(line, node) else parse_simple_frames(line, node) From a036a590aba69ba5b2dcb5e38c1ac4d67bd670d8 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 8 Oct 2026 23:27:45 +0300 Subject: [PATCH 17/43] add 'model' directive --- res/modules/animation.lua | 1 + res/modules/internal/animation_codegen.lua | 2 ++ res/modules/internal/formats/vca.lua | 1 + 3 files changed, 4 insertions(+) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index fd43ac9f9..89a1ae6e2 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -46,6 +46,7 @@ local M = { CH_ZOOM = 4, CH_TEXTURE = 5, CH_SHOW = 6, + CH_MODEL = 7, INT_CONST = 1, INT_LINEAR = 2, diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index eb08c2afb..8230c28dd 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -192,6 +192,8 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) elseif line.channel == animation.CH_TEXTURE then code = code .. string.format("\n target:set_texture(%s, l%d)", lineset.target_name:escape(), i) + elseif line.channel == animation.CH_MODEL then + code = code .. string.format("\n target:set_model(bone_index, l%d)", i) elseif line.channel == animation.CH_SHOW then if target_type == "bone" then code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 66f1945d7..0c72203c7 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -9,6 +9,7 @@ local action_to_channel = { zoom = animation.CH_ZOOM, texture = animation.CH_TEXTURE, show = animation.CH_SHOW, + model = animation.CH_MODEL, } local curve_to_interp = { From ed799233e571f1f13454a9d5750915fa0cd16d56 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 8 Oct 2026 23:32:05 +0300 Subject: [PATCH 18/43] update doc/*/vca.md --- doc/en/vca.md | 8 ++++---- doc/ru/vca.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/en/vca.md b/doc/en/vca.md index 722432e31..16df83cc8 100644 --- a/doc/en/vca.md +++ b/doc/en/vca.md @@ -28,7 +28,7 @@ Two kinds of curve definitions are currently available, each producing a value ` - `@scale` - scales an object/bone (multiplier) - `@zoom` - camera zoom (multiplier) - `@texture` - change of a dynamically assigned texture (see [skeleton:set_texture](scripting/ecs.md#skeleton)) -- `@control` - changing flag values, such as visibility +- `@show` - visibility of a bone or the entire skeleton/object (if no bone is specified) ## Metadata @@ -97,17 +97,17 @@ If you do not wish to limit the animation duration via `configure` but want to l } ``` -Example of using the `control` directive: +Example of using flag directives like `show`: ```vcd # Specific bone -@control bone head flag visible period 20 { +@show bone head period 20 { @key frame 0 value on @key frame 10 value off } # Entire skeleton -@control flag visible period 30 { +@show period 30 { @key frame 0 value on @key frame 10 value off } diff --git a/doc/ru/vca.md b/doc/ru/vca.md index 91c252833..aac88aec8 100644 --- a/doc/ru/vca.md +++ b/doc/ru/vca.md @@ -28,7 +28,7 @@ VCA файл состоит из набора директив, порядок - `@scale` - масштабирование объекта/кости (множитель) - `@zoom` - масштаб камеры (множитель) - `@texture` - смена динамически-назначаемой текстуры (см. [skeleton:set_texture](scripting/ecs.md#skeleton)) -- `@control` - изменение значений флагов, таких как видимость +- `@show` - видимость кости или всего скелета / объекта (если не указана кость) ## Мета-информация @@ -97,17 +97,17 @@ VCA файл состоит из набора директив, порядок } ``` -Пример использования директивы `control`: +Пример использования директив-флагов, таких как `show`: ```vcd # Конкретная кость -@control bone head flag visible period 20 { +@show bone head period 20 { @key frame 0 value on @key frame 10 value off } # Весь скелет -@control flag visible period 30 { +@show period 30 { @key frame 0 value on @key frame 10 value off } From ad56f88e857863b126ee7aff74e54be2d6c49044 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 8 Oct 2026 23:34:04 +0300 Subject: [PATCH 19/43] update doc/*/vca.md --- doc/en/vca.md | 1 + doc/ru/vca.md | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/en/vca.md b/doc/en/vca.md index 16df83cc8..b8be3fe58 100644 --- a/doc/en/vca.md +++ b/doc/en/vca.md @@ -28,6 +28,7 @@ Two kinds of curve definitions are currently available, each producing a value ` - `@scale` - scales an object/bone (multiplier) - `@zoom` - camera zoom (multiplier) - `@texture` - change of a dynamically assigned texture (see [skeleton:set_texture](scripting/ecs.md#skeleton)) +- `@model` - bone model replacement (see [skeleton:set_model](scripting/ecs.md#skeleton)) - `@show` - visibility of a bone or the entire skeleton/object (if no bone is specified) ## Metadata diff --git a/doc/ru/vca.md b/doc/ru/vca.md index aac88aec8..79e9eacb9 100644 --- a/doc/ru/vca.md +++ b/doc/ru/vca.md @@ -28,6 +28,7 @@ VCA файл состоит из набора директив, порядок - `@scale` - масштабирование объекта/кости (множитель) - `@zoom` - масштаб камеры (множитель) - `@texture` - смена динамически-назначаемой текстуры (см. [skeleton:set_texture](scripting/ecs.md#skeleton)) +- `@model` - назначение замены модели кости (см. [skeleton:set_model](scripting/ecs.md#skeleton)) - `@show` - видимость кости или всего скелета / объекта (если не указана кость) ## Мета-информация From e8a83423d8d0c6bbc14f6974b7c05c106801ddbf Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 9 Oct 2026 00:09:48 +0300 Subject: [PATCH 20/43] fix outdated doc/*/scripting/builtins/libgfx-skeletons.md --- doc/en/scripting/builtins/libgfx-skeletons.md | 10 ++++++++-- doc/ru/scripting/builtins/libgfx-skeletons.md | 12 +++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/en/scripting/builtins/libgfx-skeletons.md b/doc/en/scripting/builtins/libgfx-skeletons.md index 4146b4be6..5518cb349 100644 --- a/doc/en/scripting/builtins/libgfx-skeletons.md +++ b/doc/en/scripting/builtins/libgfx-skeletons.md @@ -41,8 +41,14 @@ skeleton:is_visible([optional] index: int) -> bool skeleton:set_visible([optional] index: int, status: bool) -- Returns the color of the entity -skeleton:get_color() -> vec3 +skeleton:get_color() -> vec4 + +-- Returns the color of the bone +skeleton:get_color(index: int) -> vec4 -- Sets the color of the entity -skeleton:set_color(color: vec3) +skeleton:set_color(color: vec4) + +-- Sets the color of the bone +skeleton:set_color(color: vec4, bone: int) ``` diff --git a/doc/ru/scripting/builtins/libgfx-skeletons.md b/doc/ru/scripting/builtins/libgfx-skeletons.md index 2a04d598c..95fa4fe48 100644 --- a/doc/ru/scripting/builtins/libgfx-skeletons.md +++ b/doc/ru/scripting/builtins/libgfx-skeletons.md @@ -42,8 +42,14 @@ skeleton:is_visible([опционально] index: int) -> boolean skeleton:set_visible([опционально] index: int, status: boolean) -- Возвращает цвет сущности -skeleton:get_color() -> vec3 +skeleton:get_color() -> vec4 + +-- Возвращает цвет кости +skeleton:get_color(index: int) -> vec4 -- Устанавливает цвет сущности -skeleton:set_color(color: vec3) -``` \ No newline at end of file +skeleton:set_color(color: vec4) + +-- Устанавливает цвет кости +skeleton:set_color(color: vec4, index: int) +``` From 51c8d78b88fdcc241abfd9cc0b16feb6f84c416b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 9 Oct 2026 00:14:59 +0300 Subject: [PATCH 21/43] add 'color' VCA directive --- res/modules/animation.lua | 1 + res/modules/internal/animation_codegen.lua | 11 +++++++++++ res/modules/internal/formats/vca.lua | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 89a1ae6e2..a4e1f73d9 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -47,6 +47,7 @@ local M = { CH_TEXTURE = 5, CH_SHOW = 6, CH_MODEL = 7, + CH_COLOR = 8, INT_CONST = 1, INT_LINEAR = 2, diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 8230c28dd..5a7c5d8e0 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -173,6 +173,7 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) local translation = {false, false, false} local rotation = {false, false, false} local scale = {false, false, false} + local color = {false, false, false, false} for i, line in ipairs(lines) do code = code .. string.format("\n local l%d = ", i) @@ -200,9 +201,19 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) else code = code .. string.format("\n target:set_visible(l%d)", i) end + elseif line.channel == animation.CH_COLOR then + color[line.axis] = i end end + if color[1] or color[2] or color[3] or color[4] then + code = code .. "\n target:set_color({" .. + (color[1] and ("l" .. color[1]) or '1').. ", " .. + (color[2] and ("l" .. color[2]) or '1').. ", " .. + (color[3] and ("l" .. color[3]) or '1').. ", " .. + (color[4] and ("l" .. color[4]) or '1').. "})" + end + if not has_tsf or not use_tsf then return code end diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 0c72203c7..1ebac16f8 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -10,6 +10,7 @@ local action_to_channel = { texture = animation.CH_TEXTURE, show = animation.CH_SHOW, model = animation.CH_MODEL, + color = animation.CH_COLOR, } local curve_to_interp = { @@ -115,7 +116,7 @@ local function parse_directive(node, raw_track) error("unknown directive " .. tag:escape()) end local line = { - axis = node.by and ("xyz"):find(node.by) or "", + axis = node.by and (("xyz"):find(node.by) or ("rgba"):find(node.by)) or "", channel = channel, period = node.period or animation.MAX_FRAMES } From 08abed324c5790c77b5afae82c45ce23c34b77c7 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 9 Oct 2026 00:19:22 +0300 Subject: [PATCH 22/43] fix 'color' target --- res/modules/internal/animation_codegen.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 5a7c5d8e0..1b637d866 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -207,11 +207,16 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) end if color[1] or color[2] or color[3] or color[4] then - code = code .. "\n target:set_color({" .. + local color_vector = "{" .. (color[1] and ("l" .. color[1]) or '1').. ", " .. (color[2] and ("l" .. color[2]) or '1').. ", " .. (color[3] and ("l" .. color[3]) or '1').. ", " .. - (color[4] and ("l" .. color[4]) or '1').. "})" + (color[4] and ("l" .. color[4]) or '1').. "}" + if target_type == "bone" then + code = code .. "\n target:set_color(" .. color_vector .. ", bone_index)" + else + code = code .. "\n target:set_color(" .. color_vector .. ")" + end end if not has_tsf or not use_tsf then From a382fa2aabc28f0f3b3b8f045d56d3a33fb1fbe8 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 9 Oct 2026 00:19:36 +0300 Subject: [PATCH 23/43] update doc/*/vca.md --- doc/en/vca.md | 1 + doc/ru/vca.md | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/en/vca.md b/doc/en/vca.md index b8be3fe58..1299662f0 100644 --- a/doc/en/vca.md +++ b/doc/en/vca.md @@ -30,6 +30,7 @@ Two kinds of curve definitions are currently available, each producing a value ` - `@texture` - change of a dynamically assigned texture (see [skeleton:set_texture](scripting/ecs.md#skeleton)) - `@model` - bone model replacement (see [skeleton:set_model](scripting/ecs.md#skeleton)) - `@show` - visibility of a bone or the entire skeleton/object (if no bone is specified) +- `@color` - color of a bone or the entire skeleton/object (if no bone is specified) (RGBA) ## Metadata diff --git a/doc/ru/vca.md b/doc/ru/vca.md index 79e9eacb9..41db479b5 100644 --- a/doc/ru/vca.md +++ b/doc/ru/vca.md @@ -30,6 +30,7 @@ VCA файл состоит из набора директив, порядок - `@texture` - смена динамически-назначаемой текстуры (см. [skeleton:set_texture](scripting/ecs.md#skeleton)) - `@model` - назначение замены модели кости (см. [skeleton:set_model](scripting/ecs.md#skeleton)) - `@show` - видимость кости или всего скелета / объекта (если не указана кость) +- `@color` - цвет кости или всего скелета / объекта (если не указана кость) (RGBA) ## Мета-информация From d8017ff99553039e6d0114a033eb9c352076eaee Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 00:52:23 +0300 Subject: [PATCH 24/43] fix reload_module ignoring pack environment reload_module loaded the new module code with the global environment, while require runs modules in their pack environment. After reload, PACK_ID and other pack globals were nil in the module. --- dev/tests/reload_module.lua | 33 +++++++++++++++++++++++++++++++++ res/scripts/stdmin.lua | 16 ++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 dev/tests/reload_module.lua diff --git a/dev/tests/reload_module.lua b/dev/tests/reload_module.lua new file mode 100644 index 000000000..8ee5ab232 --- /dev/null +++ b/dev/tests/reload_module.lua @@ -0,0 +1,33 @@ +-- reload_module must run the module in its pack environment, as require does +local util = require "core:tests_util" +util.create_demo_world() + +-- a pack with a module that uses pack environment (PACK_ID) +local PACK = "world:content/reload_test" +file.mkdirs(PACK .. "/modules") +file.write(PACK .. "/package.json", json.tostring({id="reload_test", title="reload_test"})) + +local function write_module(version) + file.write(PACK .. "/modules/mod.lua", string.format([[ +local this = {} +function this.info() return PACK_ID, %d end +return this +]], version)) +end + +write_module(1) +app.reconfig_packs({"reload_test"}, {}) +app.tick() + +local mod = require "reload_test:mod" +local packid, version = mod.info() +assert(packid == "reload_test" and version == 1) + +write_module(2) +reload_module("reload_test:mod") +packid, version = mod.info() +assert(version == 2, "module is not reloaded") +assert(packid == "reload_test", "reloaded module has no pack environment") + +app.close_world(true) +app.delete_world("demo") diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index e1b735478..9fe297aab 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -183,6 +183,12 @@ function on_deprecated_call(name, alternatives) end end +local __pack_envs = __vc__pack_envs +function __vc_internals.get_pack_env(packid) + return __pack_envs[packid] +end +__vc__pack_envs = nil + function reload_module(name) local prefix, name = parse_path(name) local path = prefix..":modules/"..name..".lua" @@ -196,6 +202,10 @@ function reload_module(name) if script == nil then error(err) end + local env = __pack_envs[prefix] + if env then + script = setfenv(script, env) + end local result = script() if not result then return @@ -270,12 +280,6 @@ function __vc_lock_internal_modules() __internal_locked = true end -local __pack_envs = __vc__pack_envs -function __vc_internals.get_pack_env(packid) - return __pack_envs[packid] -end -__vc__pack_envs = nil - function require(path) if not string.find(path, ':') then local prefix, _ = parse_path(_debug_getinfo(2).source) From a2321e0e28a21dd1abc39db67f727ca7ed728dcc Mon Sep 17 00:00:00 2001 From: DIvan2000 Date: Sat, 10 Oct 2026 05:04:14 +0400 Subject: [PATCH 25/43] fix program filename --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ead09d092..83b5cc955 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ packages.default = voxel-core; apps.default = { type = "app"; - program = "${voxel-core}/bin/VoxelCore"; + program = "${voxel-core}/bin/VoxelEngine"; }; } ); From 8962042627ded0641db85f4a8b6d896d7d7dbbf4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 10:54:36 +0300 Subject: [PATCH 26/43] complete the rename of voxelengine to voxelcore --- .github/workflows/appimage.yml | 6 +++--- .github/workflows/cmake.yml | 6 +++--- .github/workflows/macos.yml | 20 ++++++++++---------- .github/workflows/release.yml | 2 +- .github/workflows/windows-clang.yml | 3 +-- .github/workflows/windows.yml | 3 +-- CMakeLists.txt | 12 ++++++------ Dockerfile | 2 +- README.md | 4 ++-- dev/AppImageBuilder.yml | 2 +- dev/VoxelCore.desktop | 4 ++-- dev/cmake/BuildAppdir.cmake | 2 +- dev/tests/network_http.lua | 2 +- doc/en/scripting/builtins/libnetwork.md | 2 +- doc/ru/scripting/builtins/libnetwork.md | 2 +- doc/specs/binary_json_spec.md | 2 +- flake.nix | 4 ++-- run.sh | 4 ++-- src/CMakeLists.txt | 12 ++++++------ test/CMakeLists.txt | 10 +++++----- test/network/curltest.cpp | 2 +- 21 files changed, 52 insertions(+), 54 deletions(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 5bfebeb4d..7b53b3fbf 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -50,13 +50,13 @@ jobs: - name: Run engine tests timeout-minutes: 5 run: | - chmod +x build/VoxelEngine + chmod +x build/VoxelCore chmod +x AppDir/usr/bin/vctest - AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --memchecker valgrind + AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --memchecker valgrind - name: Build AppImage uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910 env: - UPDATE_INFO: gh-releases-zsync|MihailRis|VoxelEngine-Cpp|latest|*x86_64.AppImage.zsync + UPDATE_INFO: gh-releases-zsync|MihailRis|voxelcore|latest|*x86_64.AppImage.zsync with: recipe: dev/AppImageBuilder.yml - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 52f7b7183..6956a1f3d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -62,7 +62,7 @@ jobs: # Build your program with the given configuration run: | cmake --build ${{github.workspace}}/build --config ${{inputs.build_type}} - mv ${{github.workspace}}/build/VoxelEngine VoxelEngine + mv ${{github.workspace}}/build/VoxelCore VoxelCore - name: Run tests if: ${{ inputs.run_tests }} run: ctest --test-dir ${{github.workspace}}/build @@ -70,7 +70,7 @@ jobs: if: ${{ inputs.upload_artifacts }} uses: actions/upload-artifact@v4 with: - name: VoxelEngine + name: VoxelCore path: | - VoxelEngine + VoxelCore res/* diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b4d9f6328..a446821d8 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -39,7 +39,7 @@ jobs: run: chmod +x dev/fix_dylibs.sh - name: Fix dylibs - run: ./dev/fix_dylibs.sh VoxelEngine Release build + run: ./dev/fix_dylibs.sh VoxelCore Release build - name: Run tests run: ctest --output-on-failure --test-dir build @@ -47,19 +47,19 @@ jobs: - name: Run engine tests timeout-minutes: 5 run: | - chmod +x build/VoxelEngine + chmod +x build/VoxelCore chmod +x AppDir/usr/bin/vctest - AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- " + AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- " - name: Create DMG run: | - mkdir VoxelEngineDmgContent - cp -r build/res VoxelEngineDmgContent/ - cp -r build/VoxelEngine VoxelEngineDmgContent/ - cp -r build/libs VoxelEngineDmgContent/libs - hdiutil create VoxelEngineMacApp.dmg -volname "VoxelEngine" -srcfolder VoxelEngineDmgContent -ov -format UDZO + mkdir VoxelCoreDmgContent + cp -r build/res VoxelCoreDmgContent/ + cp -r build/VoxelCore VoxelCoreDmgContent/ + cp -r build/libs VoxelCoreDmgContent/libs + hdiutil create VoxelCoreMacApp.dmg -volname "VoxelCore" -srcfolder VoxelCoreDmgContent -ov -format UDZO - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: VoxelEngineMacOs - path: VoxelEngineMacApp.dmg + name: VoxelCoreMacOs + path: VoxelCoreMacApp.dmg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a1d17c64..f6b539ba1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: mkdir release mv ./artifacts/AppImage/VoxelCore-latest-x86_64.AppImage \ ./release/voxelcore-${RELEASE_VERSION}_x86-64.AppImage - mv ./artifacts/VoxelEngineMacOs/VoxelEngineMacApp.dmg \ + mv ./artifacts/VoxelCoreMacOs/VoxelCoreMacApp.dmg \ ./release/voxelcore-${RELEASE_VERSION}_macos.dmg (cd ./artifacts/Windows-Build && zip -r ../../release/voxelcore-${RELEASE_VERSION}_win64.zip .) ls -la ./release diff --git a/.github/workflows/windows-clang.yml b/.github/workflows/windows-clang.yml index 5dd91a576..1fe591ac8 100644 --- a/.github/workflows/windows-clang.yml +++ b/.github/workflows/windows-clang.yml @@ -59,11 +59,10 @@ jobs: run: | mkdir packaged mkdir packaged/res - cp build/VoxelEngine.exe packaged/ + cp build/VoxelCore.exe packaged/ cp build/vctest/vctest.exe packaged/ cp build/*.dll packaged/ cp -r build/res/* packaged/res/ - mv packaged/VoxelEngine.exe packaged/VoxelCore.exe - uses: actions/upload-artifact@v4 with: name: Windows-Build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ffcb0c318..ec5322bc0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,7 +37,7 @@ jobs: run: ctest --preset default-vs-msvc-windows - name: Run engine tests run: | - build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelEngine.exe -d dev/tests -u build + build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelCore.exe -d dev/tests -u build timeout-minutes: 5 - name: Package for Windows run: | @@ -45,7 +45,6 @@ jobs: cp -r build/RelWithDebInfo/* packaged/ cp build/vctest/RelWithDebInfo/vctest.exe packaged/ cp C:/Windows/System32/msvcp140.dll packaged/msvcp140.dll - mv packaged/VoxelEngine.exe packaged/VoxelCore.exe working-directory: ${{ github.workspace }} - uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a9d507b..a9ac24a1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(VoxelEngine) +project(VoxelCore) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -27,23 +27,23 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() add_subdirectory(src) -add_executable(VoxelEngine src/main.cpp) +add_executable(VoxelCore src/main.cpp) if(VOXELENGINE_BUILD_APPDIR) include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake) endif() -target_link_libraries(VoxelEngine PRIVATE VoxelEngineSrc +target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc $<$:winmm>) -target_link_options(VoxelEngine PRIVATE $<$:-no-pie>) +target_link_options(VoxelCore PRIVATE $<$:-no-pie>) # Deploy res to build dir add_custom_command( - TARGET VoxelEngine + TARGET VoxelCore POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different - ${CMAKE_CURRENT_SOURCE_DIR}/res $/res) + ${CMAKE_CURRENT_SOURCE_DIR}/res $/res) if(VOXELENGINE_BUILD_TESTS) enable_testing() diff --git a/Dockerfile b/Dockerfile index 3a06d1afc..fb1a628c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Build docker container: docker build -t voxelcore . # Build project: docker run --rm -it -v$(pwd):/project voxelcore bash -c "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -Bbuild && cmake --build build" -# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelEngine +# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelCore FROM debian:bookworm-slim LABEL Description="Docker container for building VoxelCore for Linux" diff --git a/README.md b/README.md index 67788d9fd..d040e7707 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ docker run --rm -it \ -v "$XAUTHORITY:/home/user/.Xauthority:ro" \ -e DISPLAY="$DISPLAY" \ --network=host \ - voxel-engine ./build/VoxelEngine + voxel-engine ./build/VoxelCore ``` ### On Windows @@ -218,5 +218,5 @@ docker run --rm -it -v "${PWD}:/project" voxel-engine bash -c "cmake -DCMAKE_BUI #### Step 4. Run the application ```powershell -docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelEngine +docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelCore ``` diff --git a/dev/AppImageBuilder.yml b/dev/AppImageBuilder.yml index b2c7f09ec..bed1dde47 100644 --- a/dev/AppImageBuilder.yml +++ b/dev/AppImageBuilder.yml @@ -6,7 +6,7 @@ AppDir: name: VoxelCore icon: VoxelCore version: latest - exec: usr/bin/VoxelEngine + exec: usr/bin/VoxelCore exec_args: --dir $HOME/.config/voxelcore --res $APPDIR/usr/share/VoxelCore/res $@ apt: arch: amd64 diff --git a/dev/VoxelCore.desktop b/dev/VoxelCore.desktop index 48809b392..eeaf4be30 100644 --- a/dev/VoxelCore.desktop +++ b/dev/VoxelCore.desktop @@ -3,8 +3,8 @@ Version=1.0 Type=Application Name=VoxelCore Comment=Minecraft-like game engine in C++ with OpenGL -TryExec=VoxelEngine -Exec=VoxelEngine +TryExec=VoxelCore +Exec=VoxelCore Icon=VoxelCore MimeType=image/x-foo; Categories=Game; diff --git a/dev/cmake/BuildAppdir.cmake b/dev/cmake/BuildAppdir.cmake index e3a017e94..7445d1016 100644 --- a/dev/cmake/BuildAppdir.cmake +++ b/dev/cmake/BuildAppdir.cmake @@ -12,4 +12,4 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin) -install(TARGETS VoxelEngine DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin) +install(TARGETS VoxelCore DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin) diff --git a/dev/tests/network_http.lua b/dev/tests/network_http.lua index 12149de09..76fd7f54e 100644 --- a/dev/tests/network_http.lua +++ b/dev/tests/network_http.lua @@ -1,6 +1,6 @@ local response_received = false -network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) +network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s) print(json.parse(s).name) response_received = true end, function (code) diff --git a/doc/en/scripting/builtins/libnetwork.md b/doc/en/scripting/builtins/libnetwork.md index 8893407d4..ecd76bbf3 100644 --- a/doc/en/scripting/builtins/libnetwork.md +++ b/doc/en/scripting/builtins/libnetwork.md @@ -50,7 +50,7 @@ network.get( ) -- Example: -network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) +network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s) print(json.parse(s).name) -- will output the name of the latest engine release end) diff --git a/doc/ru/scripting/builtins/libnetwork.md b/doc/ru/scripting/builtins/libnetwork.md index c60f0f178..2c322405e 100644 --- a/doc/ru/scripting/builtins/libnetwork.md +++ b/doc/ru/scripting/builtins/libnetwork.md @@ -50,7 +50,7 @@ network.get( ) -- Пример: -network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) +network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s) print(json.parse(s).name) -- выведет имя последнего релиза движка end) diff --git a/doc/specs/binary_json_spec.md b/doc/specs/binary_json_spec.md index 46ed868d6..4bed562e4 100644 --- a/doc/specs/binary_json_spec.md +++ b/doc/specs/binary_json_spec.md @@ -2,7 +2,7 @@ Format version: 1.1 -This binary data format is developed for use as binary version of JSON in [VoxelEngine-Cpp](https://github.com/MihailRis/VoxelEngine-Cpp) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences +This binary data format is developed for use as binary version of JSON in [voxelcore](https://github.com/MihailRis/voxelcore) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences ## Basic types diff --git a/flake.nix b/flake.nix index 83b5cc955..cb6bfe6ca 100644 --- a/flake.nix +++ b/flake.nix @@ -56,7 +56,7 @@ installPhase = '' mkdir -p $out/bin - cp VoxelEngine $out/bin/ + cp VoxelCore $out/bin/ ''; }; in @@ -64,7 +64,7 @@ packages.default = voxel-core; apps.default = { type = "app"; - program = "${voxel-core}/bin/VoxelEngine"; + program = "${voxel-core}/bin/VoxelCore"; }; } ); diff --git a/run.sh b/run.sh index 612f06935..40532ad5c 100755 --- a/run.sh +++ b/run.sh @@ -62,5 +62,5 @@ done if [[ $run ]]; then echo "[RUN SCRIPT] Run project" - ./build/VoxelEngine -fi \ No newline at end of file + ./build/VoxelCore +fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 802c06e1a..8eae55c33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,10 @@ -project(VoxelEngineSrc) +project(VoxelCoreSrc) file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) -add_library(VoxelEngineSrc STATIC ${sources} ${headers}) +add_library(VoxelCoreSrc STATIC ${sources} ${headers}) find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) @@ -70,10 +70,10 @@ else() add_library(luajit::luajit ALIAS PkgConfig::luajit) endif() -target_include_directories(VoxelEngineSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(VoxelCoreSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries( - VoxelEngineSrc + VoxelCoreSrc PRIVATE glfw OpenGL::GL GLEW::GLEW @@ -91,7 +91,7 @@ target_link_libraries( ) target_compile_options( - VoxelEngineSrc + VoxelCoreSrc PUBLIC $<$: /utf-8 /MP @@ -129,7 +129,7 @@ target_compile_options( >) target_link_options( - VoxelEngineSrc + VoxelCoreSrc PUBLIC $<$: -no-pie diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e2aae2a74..708fb8da1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,22 +1,22 @@ -project(VoxelEngineTest) +project(VoxelCoreTest) file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) find_package(GTest) -add_executable(VoxelEngineTest ${sources}) +add_executable(VoxelCoreTest ${sources}) -target_link_libraries(VoxelEngineTest PRIVATE VoxelEngineSrc GTest::gtest_main) +target_link_libraries(VoxelCoreTest PRIVATE VoxelCoreSrc GTest::gtest_main) # HACK: copy res to test/ folder for fixing problem compatibility MultiConfig # and non MultiConfig builds. Delete in future and use only root res folder Also # this resolve problem with ctests, because it set cwd to # ${CMAKE_CURRENT_BINARY_DIR} add_custom_command( - TARGET VoxelEngineTest + TARGET VoxelCoreTest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res) include(GoogleTest) -gtest_discover_tests(VoxelEngineTest) +gtest_discover_tests(VoxelCoreTest) diff --git a/test/network/curltest.cpp b/test/network/curltest.cpp index e7fc4840d..44a5bb38e 100644 --- a/test/network/curltest.cpp +++ b/test/network/curltest.cpp @@ -8,7 +8,7 @@ TEST(curltest, curltest) { auto network = network::Network::create(settings); network::HttpRequest request {}; - request.url = "https://raw.githubusercontent.com/MihailRis/VoxelEngine-Cpp/refs/" + request.url = "https://raw.githubusercontent.com/MihailRis/voxelcore/refs/" "heads/curl/res/content/base/blocks/lamp.json"; request.onResponse = [](network::HttpResponse response) { if (response.body.empty()) { From 521ebf43abf971f737bb473f3a3deb4a61772a11 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 11:36:31 +0300 Subject: [PATCH 27/43] remove incorrect fix --- src/graphics/ui/elements/SplitBox.cpp | 13 ------------- src/graphics/ui/elements/SplitBox.hpp | 1 - 2 files changed, 14 deletions(-) diff --git a/src/graphics/ui/elements/SplitBox.cpp b/src/graphics/ui/elements/SplitBox.cpp index c35374529..247ef7410 100644 --- a/src/graphics/ui/elements/SplitBox.cpp +++ b/src/graphics/ui/elements/SplitBox.cpp @@ -82,19 +82,6 @@ void SplitBox::doubleClick(int x, int y) { refresh(); } -std::shared_ptr SplitBox::getAt(const glm::vec2& pos) { - auto hover = Container::getAt(pos); - if (hover.get() != this) { - return hover; - } - for (const auto& node : nodes) { - if (node->isVisible() && node->isInside(pos)) { - return nullptr; - } - } - return hover; -} - void SplitBox::fullRefresh() { refresh(); reposition(); diff --git a/src/graphics/ui/elements/SplitBox.hpp b/src/graphics/ui/elements/SplitBox.hpp index 1a452c2ff..8482e73ec 100644 --- a/src/graphics/ui/elements/SplitBox.hpp +++ b/src/graphics/ui/elements/SplitBox.hpp @@ -11,7 +11,6 @@ namespace gui { virtual void refresh() override; virtual void fullRefresh() override; virtual void doubleClick(int x, int y) override; - virtual std::shared_ptr getAt(const glm::vec2& pos) override; private: float splitPos; }; From 8ce3b6dc23010ccdd6009a52060fb960251d08e1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 15:45:56 +0300 Subject: [PATCH 28/43] add '--test' to run.sh --- run.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/run.sh b/run.sh index 40532ad5c..13b824d3c 100755 --- a/run.sh +++ b/run.sh @@ -31,6 +31,17 @@ function norun { } +function test { + echo "[RUN SCRIPT] Run tests" + cd build + rm -rf ./vctest-run + mkdir ./vctest-run + ./vctest/vctest --exe ./VoxelEngine --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind + cd .. + run= +} + + function help { echo "[RUN SCRIPT] Usage: ./run [ARGUMENT]..." echo "[RUN SCRIPT] Arguments:" @@ -38,6 +49,7 @@ function help { echo "[RUN SCRIPT] -b, --build Build project" echo "[RUN SCRIPT] -r, --rebuild Rebuild project" echo "[RUN SCRIPT] -R, --norun Build without run" + echo "[RUN SCRIPT] -t, --test Run tests (without run)" echo "[RUN SCRIPT] -h, --help Print this page" } @@ -48,6 +60,7 @@ while [ -n "$1" ]; do -b | --build) build ;; -r | --rebuild) rebuild ;; -R | --norun) norun ;; + -t | --test) test ;; -h | --help) help norun break ;; From fa5466f675a381861e20dcbb8c2e7ba33288f557 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 15:54:28 +0300 Subject: [PATCH 29/43] fix zip archives paths and add zip files test - create_zip from a subdirectory wrote entry names with a leading '/', so the mounted archive looked empty - memory_ostream did not support tellp(), so create_zip into a memory device wrote invalid offsets (-1) to the archive - ZipFileDevice added missing parent directories for the first entry only - ZipFileDevice::exists returned false for the archive root - MemoryDevice::mkdirs recreated existing directories, dropping their content (mkdir("a/b") cleared "a"); overwriting a file duplicated its name in the directory listing Added dev/tests/zip_files.lua: builds archives with file.create_zip from memory device root, subdirectories and the real filesystem, mounts them and checks reading, listing and read-only access. memory_filesystem.lua got checks for the MemoryDevice issues. Closes #544 --- dev/tests/memory_filesystem.lua | 11 +++ dev/tests/zip_files.lua | 118 +++++++++++++++++++++++++++++++ src/io/devices/MemoryDevice.cpp | 13 ++++ src/io/devices/ZipFileDevice.cpp | 18 ++++- src/io/memory_ostream.hpp | 13 ++++ 5 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 dev/tests/zip_files.lua diff --git a/dev/tests/memory_filesystem.lua b/dev/tests/memory_filesystem.lua index e246279a7..20d8e9700 100644 --- a/dev/tests/memory_filesystem.lua +++ b/dev/tests/memory_filesystem.lua @@ -41,6 +41,17 @@ assert(entries[1] == "memtest:dir/subdir/a.txt") assert(entries[2] == "memtest:dir/subdir/b.txt") assert(entries[3] == "memtest:dir/subdir/other") +debug.log("create sibling directory") +file.mkdir("memtest:dir/subdir/sibling") +assert(file.isfile("memtest:dir/subdir/a.txt")) +assert(file.isdir("memtest:dir/subdir/other")) +asserts.equals(4, #file.list("memtest:dir/subdir")) + +debug.log("overwrite file") +file.write("memtest:dir/subdir/a.txt", "overwritten") +asserts.equals("overwritten", file.read("memtest:dir/subdir/a.txt")) +asserts.equals(4, #file.list("memtest:dir/subdir")) + debug.log("remove tree") file.remove_tree("memtest:dir") assert(not file.isdir("memtest:dir")) diff --git a/dev/tests/zip_files.lua b/dev/tests/zip_files.lua new file mode 100644 index 000000000..ad5f4e7e0 --- /dev/null +++ b/dev/tests/zip_files.lua @@ -0,0 +1,118 @@ +local function sorted_list(path) + local entries = file.list(path) + table.sort(entries) + return entries +end + +local function check_list(expected, path) + local entries = sorted_list(path) + asserts.equals(#expected, #entries) + for i, name in ipairs(expected) do + asserts.equals(name, entries[i]) + end +end + +local function join(root, name) + if root:sub(-1) == ":" then + return root..name + end + return root.."/"..name +end + +local bytes = {0xDE, 0xAD, 0x00, 0xC0, 0xDE} + +local function create_tree(root) + file.mkdirs(join(root, "sub/deep")) + file.mkdir(join(root, "empty")) + file.write(join(root, "root.txt"), "root file") + file.write(join(root, "sub/a.txt"), "example, пример") + file.write_bytes(join(root, "sub/deep/binary"), bytes) +end + +local function check_tree(m) + debug.log("check directories") + assert(file.exists(m..":")) + assert(file.isdir(m..":")) + assert(file.isdir(m..":sub")) + assert(file.isdir(m..":sub/deep")) + assert(file.isdir(m..":empty")) + assert(not file.isfile(m..":sub")) + + debug.log("check files") + assert(file.isfile(m..":root.txt")) + assert(file.isfile(m..":sub/a.txt")) + assert(not file.isdir(m..":sub/a.txt")) + assert(not file.exists(m..":missing.txt")) + assert(not file.exists(m..":sub/missing.txt")) + + debug.log("read files") + asserts.equals("root file", file.read(m..":root.txt")) + asserts.equals("example, пример", file.read(m..":sub/a.txt")) + asserts.equals(#"root file", file.length(m..":root.txt")) + + local rbytes = file.read_bytes(m..":sub/deep/binary") + asserts.equals(#bytes, #rbytes) + for i, b in ipairs(bytes) do + asserts.equals(b, rbytes[i]) + end + + debug.log("read file with io_stream") + local stream = file.open(m..":root.txt", "r") + asserts.equals("root file", stream:read_line()) + stream:close() + + debug.log("list directories") + check_list({m..":empty", m..":root.txt", m..":sub"}, m..":") + check_list({m..":sub/a.txt", m..":sub/deep"}, m..":sub") + check_list({m..":sub/deep/binary"}, m..":sub/deep") + check_list({}, m..":empty") + + debug.log("check read-only") + assert(not file.is_writeable(m..":")) + assert(not pcall(file.write, m..":new.txt", "text")) + local ok, created = pcall(file.mkdir, m..":newdir") + assert(not (ok and created)) + assert(not file.exists(m..":newdir")) +end + +local function check_zip(src, zipfile) + debug.log("create zip "..zipfile.." from "..src) + file.create_zip(src, zipfile) + assert(file.isfile(zipfile)) + + debug.log("mount "..zipfile) + local m = file.mount(zipfile) + check_tree(m) + + debug.log("unmount "..m) + file.unmount(m) + assert(not pcall(file.read, m..":root.txt")) + assert(not pcall(file.unmount, m)) +end + +local mem = file.create_memory_device() +local out = file.create_memory_device() + +debug.log("zip memory device root") +create_tree(mem..":") +check_zip(mem..":", out..":root.zip") + +debug.log("zip memory device subdirectory") +create_tree(mem..":pack") +check_zip(mem..":pack", out..":pack.zip") + +debug.log("zip nested subdirectory") +create_tree(mem..":a/b/pack") +check_zip(mem..":a/b/pack", out..":nested.zip") + +debug.log("zip real filesystem directory") +if file.exists("config:ziptest") then + file.remove_tree("config:ziptest") +end +create_tree("config:ziptest/pack") +check_zip("config:ziptest/pack", "config:ziptest/pack.zip") +file.remove_tree("config:ziptest") + +debug.log("mount non-zip file") +file.write(out..":text.txt", "not an archive") +assert(not pcall(file.mount, out..":text.txt")) diff --git a/src/io/devices/MemoryDevice.cpp b/src/io/devices/MemoryDevice.cpp index f9f4760ee..8cf440c4e 100644 --- a/src/io/devices/MemoryDevice.cpp +++ b/src/io/devices/MemoryDevice.cpp @@ -180,6 +180,10 @@ std::unique_ptr io::MemoryDevice::list(std::string_view path } io::MemoryDevice::Dir* io::MemoryDevice::createDir(std::string path) { + const auto& found = nodes.find(path); + if (found != nodes.end()) { + return found->second.get_if(); + } io::path filePath = path; io::path parent = filePath.parent(); auto parentDir = getDir(parent.string()); @@ -195,6 +199,15 @@ io::MemoryDevice::Dir* io::MemoryDevice::createDir(std::string path) { io::MemoryDevice::Node* io::MemoryDevice::createFile( std::string path, util::Buffer&& content ) { + const auto& found = nodes.find(path); + if (found != nodes.end()) { + auto& node = found->second; + if (!node.holds_alternative()) { + return nullptr; + } + node.data = File {std::move(content)}; + return &node; + } io::path filePath = path; io::path parent = filePath.parent(); auto dir = getDir(parent.string()); diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index dce053887..2c52439ae 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -173,7 +173,13 @@ ZipFileDevice::ZipFileDevice( entries[entry.fileName] = std::move(entry); } - for (auto& [name, _] : entries) { + // Add missing parent directories entries + std::vector names; + names.reserve(entries.size()); + for (const auto& [name, _] : entries) { + names.push_back(name); + } + for (const auto& name : names) { io::path path = name; while (!(path = path.parent()).pathPart().empty()) { @@ -184,7 +190,6 @@ ZipFileDevice::ZipFileDevice( entry.isDirectory = true; entries[path.pathPart()] = entry; } - break; } for (auto& [_, entry] : entries) { @@ -253,6 +258,9 @@ file_time_type ZipFileDevice::lastWriteTime(std::string_view path) { } bool ZipFileDevice::exists(std::string_view path) { + if (path.empty()) { + return true; + } return entries.find(std::string(path)) != entries.end(); } @@ -441,7 +449,11 @@ static size_t write_zip( void io::write_zip(const path& folder, const path& file) { ByteBuilder central_dir; auto out = io::write(file); - size_t entries = write_zip(folder.pathPart(), folder, *out, central_dir); + auto root = folder.pathPart(); + if (!root.empty() && root.back() != '/') { + root += '/'; + } + size_t entries = write_zip(root, folder, *out, central_dir); size_t central_dir_offset = out->tellp(); out->write(reinterpret_cast(central_dir.data()), central_dir.size()); diff --git a/src/io/memory_ostream.hpp b/src/io/memory_ostream.hpp index 3ff14a994..329277aff 100644 --- a/src/io/memory_ostream.hpp +++ b/src/io/memory_ostream.hpp @@ -50,6 +50,19 @@ protected: return c; } + pos_type seekoff( + off_type off, + std::ios_base::seekdir way, + std::ios_base::openmode mode = std::ios_base::out + ) override { + // only position query (tellp) is supported + if (off == 0 && way == std::ios_base::cur && + (mode & std::ios_base::out)) { + return pos_type(off_type(size())); + } + return pos_type(off_type(-1)); + } + std::streamsize xsputn(const char* s, std::streamsize count) override { const std::streamsize avail = epptr() - pptr(); From ec51848447727860d100b8b4b080093a519bb562 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:31:36 +0300 Subject: [PATCH 30/43] update memory_ostream --- src/io/memory_ostream.hpp | 133 ++++++++++++++++++++++++------------- test/io/memory_ostream.cpp | 22 ++++++ 2 files changed, 110 insertions(+), 45 deletions(-) create mode 100644 test/io/memory_ostream.cpp diff --git a/src/io/memory_ostream.hpp b/src/io/memory_ostream.hpp index 3ff14a994..7568b8934 100644 --- a/src/io/memory_ostream.hpp +++ b/src/io/memory_ostream.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include @@ -13,81 +15,118 @@ public: explicit memory_buffer(size_t initial_size = 64) : buffer(std::make_unique(initial_size)), capacity(initial_size) { - setp(buffer.get(), buffer.get() + initial_size); + setp(buffer.get(), buffer.get() + capacity); } std::string_view view() const { - return std::string_view(pbase(), pptr() - pbase()); + return std::string_view(pbase(), size()); } util::Buffer release() { - return {std::move(buffer), size()}; + size_t n = size(); + return {std::move(buffer), n}; } size_t size() const { - return pptr() - pbase(); + return std::max(length, position()); + } + + void set_sync_callback(std::function callback) { + on_sync = std::move(callback); } protected: int_type overflow(int_type c) override { if (c == traits_type::eof()) return traits_type::eof(); - const size_t data_size = pptr() - pbase(); - const size_t new_capacity = std::max(capacity * 2, data_size + 1); - auto new_buffer = std::make_unique(new_capacity); - - std::memcpy(new_buffer.get(), pbase(), data_size); - - buffer = std::move(new_buffer); - capacity = new_capacity; - - setp(buffer.get(), buffer.get() + new_capacity); - pbump(data_size); - + reserve(position() + 1); *pptr() = traits_type::to_char_type(c); pbump(1); - return c; } std::streamsize xsputn(const char* s, std::streamsize count) override { - const std::streamsize avail = epptr() - pptr(); + reserve(position() + count); + std::memcpy(pptr(), s, count); + advance(count); + return count; + } - if (avail >= count) { - std::memcpy(pptr(), s, count); - pbump(count); - return count; + pos_type seekoff( + off_type off, + std::ios_base::seekdir dir, + std::ios_base::openmode which + ) override { + if (!(which & std::ios_base::out)) { + return pos_type(off_type(-1)); + } + length = size(); + + off_type base; + switch (dir) { + case std::ios_base::beg: base = 0; break; + case std::ios_base::cur: base = position(); break; + case std::ios_base::end: base = length; break; + default: return pos_type(off_type(-1)); } - std::streamsize written = 0; - if (avail > 0) { - std::memcpy(pptr(), s, avail); - written += avail; - s += avail; - count -= avail; - pbump(avail); + off_type target = base + off; + if (target < 0 || target > static_cast(length)) { + return pos_type(off_type(-1)); } + set_position(target); + return pos_type(target); + } - const size_t data_size = pptr() - pbase(); - const size_t required_capacity = data_size + count; - const size_t new_capacity = std::max(capacity * 2, required_capacity); - auto new_buffer = std::make_unique(new_capacity); - - std::memcpy(new_buffer.get(), pbase(), data_size); - std::memcpy(new_buffer.get() + data_size, s, count); - - buffer = std::move(new_buffer); - capacity = new_capacity; - - setp(buffer.get(), buffer.get() + new_capacity); - pbump(data_size + count); - written += count; - - return written; + pos_type seekpos(pos_type pos, std::ios_base::openmode which) override { + return seekoff(off_type(pos), std::ios_base::beg, which); } private: std::unique_ptr buffer; size_t capacity; + size_t length = 0; + + size_t position() const { + return pptr() - pbase(); + } + + void advance(size_t n) { + while (n > 0) { + int step = static_cast(std::min(n, INT_MAX)); + pbump(step); + n -= step; + } + } + + void set_position(size_t pos) { + setp(buffer.get(), buffer.get() + capacity); + advance(pos); + } + + void reserve(size_t required) { + if (required <= capacity) { + return; + } + size_t pos = position(); + length = size(); + + size_t new_capacity = std::max(capacity * 2, required); + auto new_buffer = std::make_unique(new_capacity); + std::memcpy(new_buffer.get(), buffer.get(), length); + + buffer = std::move(new_buffer); + capacity = new_capacity; + set_position(pos); + } + + int sync() override { + if (on_sync) { + on_sync(view()); + } + return 0; + } + + std::function on_sync; }; class memory_ostream : public std::ostream { @@ -102,6 +141,10 @@ public: util::Buffer release() { return buffer.release(); } + + void set_sync_callback(std::function callback) { + buffer.set_sync_callback(std::move(callback)); + } private: memory_buffer buffer; }; diff --git a/test/io/memory_ostream.cpp b/test/io/memory_ostream.cpp new file mode 100644 index 000000000..c1f83e0f8 --- /dev/null +++ b/test/io/memory_ostream.cpp @@ -0,0 +1,22 @@ +#include + +#include "io/memory_ostream.hpp" + +TEST(io, memory_ostream) { + const char data[] = "Hello, world!"; + const int n = std::strlen(data); + + memory_ostream stream; + ASSERT_TRUE(stream.good()); + + stream.write(data, n); + ASSERT_EQ(std::string(stream.view()), std::string(data)); + + stream.seekp(0); + ASSERT_TRUE(stream.good()); + stream.write("Remove", 6); + ASSERT_EQ(std::string(stream.view()), "Remove world!"); + + auto buffer = stream.release(); + ASSERT_EQ(std::string(buffer.data(), buffer.size()), "Remove world!"); +} From 682ca665c9f11741f07f56579e09c41aa0e94d43 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:32:15 +0300 Subject: [PATCH 31/43] make memory device create file on flush --- src/io/devices/MemoryDevice.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/io/devices/MemoryDevice.cpp b/src/io/devices/MemoryDevice.cpp index f9f4760ee..ae08b0da3 100644 --- a/src/io/devices/MemoryDevice.cpp +++ b/src/io/devices/MemoryDevice.cpp @@ -14,8 +14,13 @@ std::filesystem::path io::MemoryDevice::resolve(std::string_view path) { std::unique_ptr io::MemoryDevice::write(std::string_view path) { std::string filePath = std::string(path); + + auto memoryStream = std::make_unique(); + memoryStream->set_sync_callback([this, filePath](std::string_view data) { + createFile(std::move(filePath), util::Buffer(data.data(), data.size())); + }); return std::make_unique( - std::make_unique(), + std::move(memoryStream), [this, filePath](auto ostream) { auto& memoryStream = dynamic_cast(*ostream); createFile(std::move(filePath), memoryStream.release()); From 5fd3ce76da65c5d1f0b7454fbf8078f28afbd692 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:32:33 +0300 Subject: [PATCH 32/43] fix --- src/logic/scripting/lua/libs/libfile.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/logic/scripting/lua/libs/libfile.cpp b/src/logic/scripting/lua/libs/libfile.cpp index 1bcceb6d3..61a7e2191 100644 --- a/src/logic/scripting/lua/libs/libfile.cpp +++ b/src/logic/scripting/lua/libs/libfile.cpp @@ -305,13 +305,14 @@ static int l_read_descriptor(lua::State* L) { int maxlen = lua::tointeger(L, 2); auto& stream = io_descriptors::require_input(descriptor); - if (stream.eof()) { - stream.clear(); - } util::Buffer buffer(maxlen); stream.read(buffer.data(), maxlen); - std::streamsize read_len = stream.gcount(); + std::streamsize read_len = stream.gcount(); + + if (stream.eof()) { + stream.clear(stream.rdstate() & std::ios::badbit); + } return lua::create_bytearray(L, buffer.data(), read_len); } From a56158b78e3ffcb7be7af2951375adb5dc4ac2e0 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 16:39:20 +0300 Subject: [PATCH 33/43] fix crash in create_zip for files without modification time MemoryDevice::lastWriteTime returns file_time_type::min(). Converting it to the system clock overflows, and on Windows std::localtime returns nullptr for the resulting time, which was dereferenced (access violation in zip_files test on MSVC). Unknown or out of range time is now written as 1980-01-01 00:00, the earliest MS-DOS date. --- src/io/devices/ZipFileDevice.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index 2c52439ae..025c1c335 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -58,11 +58,22 @@ namespace { } uint32_t to_ms_dos_timestamp(const file_time_type& fileTime) { + // 1980-01-01 00:00, the earliest MS-DOS date; used for unknown time + // (devices without timestamps return file_time_type::min()) + constexpr uint32_t DOS_EPOCH = (0 << 9 | 1 << 5 | 1) << 16; + if (fileTime == file_time_type::min()) { + return DOS_EPOCH; + } auto timePoint = time_point_cast( fileTime - file_time_type::clock::now() + system_clock::now() ); std::time_t timeT = system_clock::to_time_t(timePoint); - std::tm tm = *std::localtime(&timeT); + // localtime returns nullptr for out of range time on Windows + const std::tm* tmPtr = std::localtime(&timeT); + if (tmPtr == nullptr || tmPtr->tm_year < 80) { + return DOS_EPOCH; + } + const std::tm& tm = *tmPtr; uint16_t date = (tm.tm_year - 80) << 9 | (tm.tm_mon + 1) << 5 | tm.tm_mday; uint16_t time = (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec / 2); return (date << 16) | time; From bf98174e1531b70ff0d4be523e6f71195d1c595e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:48:04 +0300 Subject: [PATCH 34/43] fix shader info log is truncated --- src/graphics/core/Shader.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/graphics/core/Shader.cpp b/src/graphics/core/Shader.cpp index 1c752ef5a..463151f3a 100644 --- a/src/graphics/core/Shader.cpp +++ b/src/graphics/core/Shader.cpp @@ -125,12 +125,14 @@ glshader compile_shader(GLenum type, const GLchar* source, const std::string& fi glCompileShader(shader); glGetShaderiv(shader, GL_COMPILE_STATUS, &success); if (!success) { - GLchar infoLog[GL_LOG_LEN]; - glGetShaderInfoLog(shader, GL_LOG_LEN, nullptr, infoLog); + GLint infoLogLength; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); + auto infoLog = std::make_unique(infoLogLength); + glGetShaderInfoLog(shader, infoLogLength, nullptr, infoLog.get()); glDeleteShader(shader); throw std::runtime_error( "vertex shader compilation failed (" + file + "):\n" + - std::string(infoLog) + std::string(infoLog.get(), infoLogLength) ); } return glshader(new GLuint(shader), shader_deleter); //-V508 @@ -172,10 +174,14 @@ static GLuint compile_program( glGetProgramiv(program, GL_LINK_STATUS, &success); if (!success) { - GLchar infoLog[GL_LOG_LEN]; - glGetProgramInfoLog(program, GL_LOG_LEN, nullptr, infoLog); + GLint infoLogLength; + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); + auto infoLog = std::make_unique(infoLogLength); + glGetProgramInfoLog(program, infoLogLength, nullptr, infoLog.get()); + glDeleteProgram(program); throw std::runtime_error( - "shader program linking failed:\n" + std::string(infoLog) + "shader program linking failed:\n" + + std::string(infoLog.get(), infoLogLength) ); } return program; From 28e85a336f3ceed5dd130e976e2e172891c42d0d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:50:44 +0300 Subject: [PATCH 35/43] oh --- src/graphics/core/Shader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/graphics/core/Shader.cpp b/src/graphics/core/Shader.cpp index 463151f3a..9dc574fa0 100644 --- a/src/graphics/core/Shader.cpp +++ b/src/graphics/core/Shader.cpp @@ -113,8 +113,6 @@ static inline auto shader_deleter = [](GLuint* shader) { delete shader; }; -inline const uint GL_LOG_LEN = 512; - // shader should be deleted after shader program linking using glshader = std::unique_ptr; From 48680d975fc70bb7554b16819bcebd1df5bdc2fe Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 17:05:03 +0300 Subject: [PATCH 36/43] fix missing include --- src/io/memory_ostream.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/io/memory_ostream.hpp b/src/io/memory_ostream.hpp index 7568b8934..a4752e251 100644 --- a/src/io/memory_ostream.hpp +++ b/src/io/memory_ostream.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include From 3617e01d21f26d181762b01df2a4124ff3b5aa4f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 17:24:17 +0300 Subject: [PATCH 37/43] refactor: split io_stream --- res/modules/internal/stream/binary.lua | 72 ++++ res/modules/internal/stream/blocking.lua | 19 + res/modules/internal/stream/buffered.lua | 90 +++++ res/modules/internal/stream/raw.lua | 49 +++ res/modules/internal/stream/text.lua | 102 +++++ res/modules/internal/stream/wrapper.lua | 26 ++ res/modules/io_stream.lua | 476 ++++------------------- 7 files changed, 428 insertions(+), 406 deletions(-) create mode 100644 res/modules/internal/stream/binary.lua create mode 100644 res/modules/internal/stream/blocking.lua create mode 100644 res/modules/internal/stream/buffered.lua create mode 100644 res/modules/internal/stream/raw.lua create mode 100644 res/modules/internal/stream/text.lua create mode 100644 res/modules/internal/stream/wrapper.lua diff --git a/res/modules/internal/stream/binary.lua b/res/modules/internal/stream/binary.lua new file mode 100644 index 000000000..9d38f3b9b --- /dev/null +++ b/res/modules/internal/stream/binary.lua @@ -0,0 +1,72 @@ +local binary = {} +binary.__index = binary + +local DEFAULT_CHUNK = 8192 + +function binary.new(stream) + return setmetatable({ stream = stream }, binary) +end + +local function to_table(bytes) + local t = {} + for i = 1, #bytes do + t[i] = bytes[i] + end + return t +end + +function binary.read_all(stream) + local result = Bytearray() + local avail = stream:available() + local chunk = avail > 0 and avail or DEFAULT_CHUNK + + while true do + local part = stream:read_some(chunk) + if #part == 0 then break end + result:append(part) + end + + return result +end + +function binary:read(arg, as_table) + local t = type(arg) + + if t == "number" then + local bytes = self.stream:read(arg) + return as_table and to_table(bytes) or bytes + elseif t == "string" then + local size = byteutil.get_size(arg) + local bytes = self.stream:read(size) + if #bytes < size then + error(string.format( + "unexpected end of stream: format %q needs %d bytes, got %d", + arg, size, #bytes), 2) + end + return byteutil.unpack(arg, bytes) + elseif t == "nil" then + error("in binary mode the first argument must be a byteutil format string" + .. " or the number of bytes to read") + else + error("unknown argument type: " .. t) + end +end + +function binary:write(arg, ...) + local t = type(arg) + + if t == "string" then + self.stream:write(byteutil.pack(arg, ...)) + elseif t == "table" then + self.stream:write(Bytearray(arg)) + else + self.stream:write(arg) + end +end + +function binary:read_fully(as_table) + local bytes = binary.read_all(self.stream) + return as_table and to_table(bytes) or bytes +end + +return binary diff --git a/res/modules/internal/stream/blocking.lua b/res/modules/internal/stream/blocking.lua new file mode 100644 index 000000000..a722a733e --- /dev/null +++ b/res/modules/internal/stream/blocking.lua @@ -0,0 +1,19 @@ +local wrapper = require "internal/stream/wrapper" + +local blocking = wrapper.extend({}) + +function blocking.new(inner) + return setmetatable({ inner = inner }, blocking) +end + +function blocking:read(n) + local result = self.inner:read(n) + while #result < n do + coroutine.yield() + if not self.inner:is_alive() then break end + result:append(self.inner:read(n - #result)) + end + return result +end + +return blocking diff --git a/res/modules/internal/stream/buffered.lua b/res/modules/internal/stream/buffered.lua new file mode 100644 index 000000000..621e78ebd --- /dev/null +++ b/res/modules/internal/stream/buffered.lua @@ -0,0 +1,90 @@ +local wrapper = require "internal/stream/wrapper" + +local buffered = wrapper.extend({}) + +buffered.DEFAULT_SIZE = 8192 + +function buffered.new(inner, size, flush_inner) + return setmetatable({ + inner = inner, + size = size or buffered.DEFAULT_SIZE, + flush_inner = flush_inner ~= false, + rbuf = Bytearray(), + wbuf = Bytearray(), + }, buffered) +end + +function buffered:_take(n) + local buf = self.rbuf + if n >= #buf then + self.rbuf = Bytearray() + return buf + end + local part = buf:slice(1, n) + buf:remove(1, n) + return part +end + +function buffered:flush_buffer() + if #self.wbuf > 0 then + local data = self.wbuf + self.wbuf = Bytearray() + self.inner:write(data) + end +end + +function buffered:read(n) + local have = #self.rbuf + if have < n then + if have == 0 and n >= self.size then + return self.inner:read(n) + end + self.rbuf:append(self.inner:read(self.size - have)) + end + return self:_take(n) +end + +buffered.read_some = buffered.read + +function buffered:write(data) + if #self.wbuf + #data > self.size then + self:flush_buffer() + end + if #data >= self.size then + self.inner:write(data) + else + self.wbuf:append(data) + end +end + +function buffered:flush() + self:flush_buffer() + if self.flush_inner then + self.inner:flush() + end +end + +function buffered:available() + return self.inner:available() + #self.rbuf +end + +function buffered:seek(mode, offset) + self:flush_buffer() + if mode == "c" then + offset = offset - #self.rbuf + end + self.rbuf = Bytearray() + self.inner:seek(mode, offset) +end + +function buffered:tell() + return self.inner:tell() - #self.rbuf + #self.wbuf +end + +function buffered:close() + self:flush_buffer() + self.rbuf = Bytearray() + return self.inner:close() +end + +return buffered diff --git a/res/modules/internal/stream/raw.lua b/res/modules/internal/stream/raw.lua new file mode 100644 index 000000000..b7db77919 --- /dev/null +++ b/res/modules/internal/stream/raw.lua @@ -0,0 +1,49 @@ +local raw = {} +raw.__index = raw + +function raw.new(descriptor, io_lib) + return setmetatable({ descriptor = descriptor, io_lib = io_lib }, raw) +end + +function raw:read(n) + return self.io_lib.read(self.descriptor, n) +end + +raw.read_some = raw.read + +function raw:write(data) + self.io_lib.write(self.descriptor, data) +end + +function raw:flush() + if self.io_lib.flush then + self.io_lib.flush(self.descriptor) + elseif not self:is_alive() then + error("stream is closed") + end +end + +function raw:available() + local f = self.io_lib.available + return f and f(self.descriptor) or 0 +end + +function raw:seek(mode, offset) + if not self.io_lib.seek then error("cannot seek this stream") end + self.io_lib.seek(self.descriptor, mode, offset) +end + +function raw:tell() + if not self.io_lib.tell then error("cannot tell this stream") end + return self.io_lib.tell(self.descriptor) +end + +function raw:is_alive() + return self.io_lib.is_alive(self.descriptor) +end + +function raw:close() + return self.io_lib.close(self.descriptor) +end + +return raw diff --git a/res/modules/internal/stream/text.lua b/res/modules/internal/stream/text.lua new file mode 100644 index 000000000..835340b47 --- /dev/null +++ b/res/modules/internal/stream/text.lua @@ -0,0 +1,102 @@ +local binary = require "internal/stream/binary" + +local text = {} +text.__index = text + +local CR = string.byte('\r') +local LF = string.byte('\n') + +function text.new(stream) + return setmetatable({stream = stream}, text) +end + +function text:_read_byte() + return self.stream:read(1)[1] +end + +function text:read_line() + local line = Bytearray() + local got_any = false + + while true do + local b = self:_read_byte() + if b == nil then break end + got_any = true + + if b == LF then + break + elseif b == CR then + local nb = self:_read_byte() + if nb == LF then break end + line:append(CR) + if nb == nil then break end + line:append(nb) + else + line:append(b) + end + end + + if not got_any then return nil end + return utf8.tostring(line) +end + +local function trim_empty(lines) + while #lines > 0 and lines[#lines] == "" do + lines[#lines] = nil + end + while #lines > 0 and lines[1] == "" do + table.remove(lines, 1) + end +end + +function text:read_lines(count, trim) + if count < 0 then error("count of lines to read must be positive") end + + local lines = {} + for i = 1, count do + local line = self:read_line() + if line == nil then break end + lines[i] = line + end + + if trim ~= false then trim_empty(lines) end + return lines +end + +function text:read(count, trim) + if count == nil then + return self:read_line() + end + return self:read_lines(count, trim) +end + +function text:read_fully(as_lines) + if as_lines then + local lines = {} + for line in self.read_line, self do + lines[#lines + 1] = line + end + return lines + end + return utf8.tostring(binary.read_all(self.stream)) +end + +function text:write_line(str) + self.stream:write(utf8.tobytes(str .. "\n")) +end + +-- write(string) | write({ lines... }) +function text:write(arg) + local t = type(arg) + if t == "string" then + self:write_line(arg) + elseif t == "table" then + for i = 1, #arg do + self:write_line(arg[i]) + end + else + error("unknown argument type: " .. t) + end +end + +return text diff --git a/res/modules/internal/stream/wrapper.lua b/res/modules/internal/stream/wrapper.lua new file mode 100644 index 000000000..c6c838aff --- /dev/null +++ b/res/modules/internal/stream/wrapper.lua @@ -0,0 +1,26 @@ +local wrapper = {} +wrapper.__index = wrapper + +function wrapper.extend(cls) + cls.__index = cls + return setmetatable(cls, { __index = wrapper }) +end +function wrapper:read(n) return self.inner:read(n) end + +function wrapper:read_some(n) return self.inner:read_some(n) end + +function wrapper:write(data) return self.inner:write(data) end + +function wrapper:flush() return self.inner:flush() end + +function wrapper:available() return self.inner:available() end + +function wrapper:seek(mode, off) return self.inner:seek(mode, off) end + +function wrapper:tell() return self.inner:tell() end + +function wrapper:is_alive() return self.inner:is_alive() end + +function wrapper:close() return self.inner:close() end + +return wrapper diff --git a/res/modules/io_stream.lua b/res/modules/io_stream.lua index 8776ca810..cd318c72c 100644 --- a/res/modules/io_stream.lua +++ b/res/modules/io_stream.lua @@ -1,444 +1,108 @@ -local io_stream = { } +local raw = require "internal/stream/raw" +local buffered = require "internal/stream/buffered" +local blocking = require "internal/stream/blocking" +local binary = require "internal/stream/binary" +local text = require "internal/stream/text" +local io_stream = {} io_stream.__index = io_stream -local MAX_BUFFER_SIZE = 8192 - -local DEFAULT_MODE = "default" -local BUFFERED_MODE = "buffered" -local YIELD_MODE = "yield" - -local ALL_MODES = { - DEFAULT_MODE, - BUFFERED_MODE, - YIELD_MODE -} - -local FLUSH_MODE_ALL = "all" -local FLUSH_MODE_ONLY_BUFFER = "buffer" - -local ALL_FLUSH_MODES = { - FLUSH_MODE_ALL, - FLUSH_MODE_ONLY_BUFFER -} - -local CR = string.byte('\r') -local LF = string.byte('\n') - -local function read_fully(result, read_func) - local isTable = type(result) == "table" - - local buf - - repeat - buf = read_func(MAX_BUFFER_SIZE) - - if isTable then - for i = 1, #buf do - result[#result + 1] = buf[i] - end - else result:append(buf) end - until #buf == 0 -end - ---[[ -descriptor - descriptor of stream for provided I/O library -binaryMode - if enabled, most methods will expect bytes instead of strings -ioLib - I/O library. Should include the following functions: - read(descriptor: int, length: int) -> Bytearray - May return bytearray with a smaller size if bytes have not arrived yet or have run out - May throw error if descriptor isn't readable - write(descriptor: int, data: Bytearray) - May throw error if descriptor isn't writeable - [optional] seek(descriptor: int, mode: string, offset: int) - Mode may be 'b' (relative begin), 'c' (relative current), 'e' (relative end + 1) - [optional] tell(descriptor: int) -> int - [optional] flush(descriptor: int) - [optional] available(descriptor: int) -> int - is_alive(descriptor: int) -> bool - close(descriptor: int) ---]] +local MODES = { default = true, buffered = true, yield = true } +local FLUSH_MODES = { all = true, buffer = true } function io_stream.new(descriptor, binary_mode, io_lib, mode, flush_mode) - mode = mode or DEFAULT_MODE - flush_mode = flush_mode or FLUSH_MODE_ALL - - local self = setmetatable({}, io_stream) - - self.descriptor = descriptor - self.binary_mode = binary_mode - self.max_buffer_size = MAX_BUFFER_SIZE - self.io_lib = io_lib - - self:set_mode(mode) - self:set_flush_mode(flush_mode) + local self = setmetatable({ + descriptor = descriptor, + io_lib = io_lib, + binary_mode = binary_mode and true or false, + max_buffer_size = buffered.DEFAULT_SIZE, + }, io_stream) + self:set_flush_mode(flush_mode or "all") + self:set_mode(mode or "default") return self end -function io_stream:is_binary_mode() - return self.binary_mode +function io_stream:_rebuild() + local old = self.stream + if old and old.flush_buffer and old:is_alive() then + old:flush_buffer() + end + + local s = raw.new(self.descriptor, self.io_lib) + if self.mode == "buffered" then + s = buffered.new(s, self.max_buffer_size, self.flush_mode == "all") + elseif self.mode == "yield" then + s = blocking.new(s) + end + + self.stream = s + self.text = text.new(s) + self.binary = binary.new(s) end -function io_stream:set_binary_mode(binary_mode) - self.binary_mode = binary_mode ~= nil +function io_stream:_format() + return self.binary_mode and self.binary or self.text end -function io_stream:get_mode() - return self.mode -end +function io_stream:is_binary_mode() return self.binary_mode end +function io_stream:set_binary_mode(v) self.binary_mode = v and true or false end + +function io_stream:get_mode() return self.mode end function io_stream:set_mode(mode) - if not table.has(ALL_MODES, mode) then - error("invalid stream mode: "..mode) - end - - if self.write_buffer then - self.write_buffer:clear() - self.write_buffer = nil - end - - if self.read_buffer then - self.read_buffer:clear() - self.read_buffer = nil - end - - if mode == BUFFERED_MODE then - self.write_buffer = Bytearray(self.max_buffer_size) - self.read_buffer = Bytearray(self.max_buffer_size) - end - + if not MODES[mode] then error("invalid stream mode: " .. tostring(mode)) end self.mode = mode + self:_rebuild() end -function io_stream:get_flush_mode() - return self.flush_mode -end +function io_stream:get_flush_mode() return self.flush_mode end function io_stream:set_flush_mode(flush_mode) - if not table.has(ALL_FLUSH_MODES, flush_mode) then - error("invalid flush mode: " .. flush_mode) + if not FLUSH_MODES[flush_mode] then + error("invalid flush mode: " .. tostring(flush_mode)) end - self.flush_mode = flush_mode + if self.mode == "buffered" then + self.stream.flush_inner = flush_mode == "all" + end end -function io_stream:get_max_buffer_size() - return self.max_buffer_size +function io_stream:get_max_buffer_size() return self.max_buffer_size end + +function io_stream:set_max_buffer_size(size) + self.max_buffer_size = size + if self.mode == "buffered" then self:_rebuild() end end -function io_stream:set_max_buffer_size(max_buffer_size) - self.max_buffer_size = max_buffer_size +function io_stream:read(arg, use_table) return self:_format():read(arg, use_table) end - self.write_buffer = Bytearray(self.max_buffer_size) - self.read_buffer = Bytearray(self.max_buffer_size) -end +function io_stream:write(arg, ...) return self:_format():write(arg, ...) end + +function io_stream:read_fully(use_table) return self:_format():read_fully(use_table) end + +function io_stream:read_line() return self.text:read_line() end + +function io_stream:write_line(str) return self.text:write_line(str) end function io_stream:available(length) - local available = self.io_lib.available and self.io_lib.available(self.descriptor) or 0 - - if self.mode == BUFFERED_MODE then - available = available + #self.read_buffer - end - - if not length then - return available - else - return available >= length - end + local n = self.stream:available() + if length then return n >= length end + return n end -function io_stream:__read(length, from_read_fully) - if self.mode == YIELD_MODE then - if from_read_fully then - return self.io_lib.read(self.descriptor, length) - end +function io_stream:seek(mode, offset) return self.stream:seek(mode, offset) end - local buffer = Bytearray() +function io_stream:tell() return self.stream:tell() end - while #buffer < length do - buffer:append(self.io_lib.read(self.descriptor, length - #buffer)) +function io_stream:is_alive() return self.stream:is_alive() end - if #buffer < length then coroutine.yield() end - end +function io_stream:is_closed() return not self.stream:is_alive() end - return buffer - elseif self.mode == BUFFERED_MODE then - local buf_len = #self.read_buffer - - if buf_len < length then - self.read_buffer:append( - self.io_lib.read(self.descriptor, self.max_buffer_size - buf_len) - ) - end - - buf_len = #self.read_buffer - - length = math.min(buf_len, length) - - local copy = self.read_buffer:slice(1, length) - - if buf_len == length then - self.read_buffer:clear() - else - self.read_buffer:remove(1, length) - end - - return copy - elseif self.mode == DEFAULT_MODE then - return self.io_lib.read(self.descriptor, length) - end -end - -function io_stream:__write(data) - if self.mode == BUFFERED_MODE then - local data_length = #data - - if #self.write_buffer + data_length > self.max_buffer_size then - self:flush() - end - - if data_length > self.max_buffer_size then - local to_write = math.floor(data_length / self.max_buffer_size) * self.max_buffer_size - local to_save = data_length - to_write - - self.io_lib.write(self.descriptor, data:slice(1, to_write)) - - self:flush() - - self.write_buffer = data:slice(to_write + 1, to_save) - else self.write_buffer:append(data) end - elseif self.mode == DEFAULT_MODE or self.mode == YIELD_MODE then - return self.io_lib.write(self.descriptor, data) - end -end - -function io_stream:read_fully(use_table) - if self.binary_mode then - local result = use_table and { } or Bytearray() - - local avail = self:available() - - if avail == 0 then - avail = self.max_buffer_size - end - - read_fully(result, function() return self:__read(avail, true) end) - - return result - else - if use_table then - local lines = { } - - local line - - repeat - line = self:read_line() - - lines[#lines + 1] = line - until not line - - return lines - else - local result = Bytearray() - - read_fully(result, function() return self:__read(self.max_buffer_size) end) - - return utf8.tostring(result) - end - end -end - -function io_stream:read_line() - local result = Bytearray() - - local first = true - - while true do - local char = self:__read(1) - - if #char == 0 then - if first then return else break end - end - - char = char[1] - - if char == LF then break - elseif char == CR then - char = self:__read(1) - - if char[1] == LF then break - else - result:append(CR) - result:append(char[1]) - end - else result:append(char) end - - first = false - end - - return utf8.tostring(result) -end - -function io_stream:write_line(str) - self:__write(utf8.tobytes(str .. "\n")) -end - -function io_stream:read(arg, use_table) - local arg_type = type(arg) - - if self.binary_mode then - local byte_arr - - if arg_type == "number" then - -- using 'arg' as length - - byte_arr = self:__read(arg) - - if use_table == true then - local t = { } - - for i = 1, #byte_arr do - t[i] = byte_arr[i] - end - - return t - else - return byte_arr - end - elseif arg_type == "string" then - return byteutil.unpack( - arg, - self:__read(byteutil.get_size(arg)) - ) - elseif arg_type == "nil" then - error( - "in binary mode the first argument must be a string data format".. - " for the library \"byteutil\" or the number of bytes to read" - ) - else - error("unknown argument type: "..arg_type) - end - else - if not arg then - return self:read_line() - else - local lines_count = arg - local trim_last_empty_lines = use_table - - if use_table == nil then - trim_last_empty_lines = true - end - - if lines_count < 0 then error "count of lines to read must be positive" end - - local result = { } - - for i = 1, lines_count do - result[i] = self:read_line() - end - - if trim_last_empty_lines then - local i = #result - - while i >= 0 do - local length = utf8.length(result[i]) - - if length > 0 then break - else result[i] = nil end - - i = i - 1 - end - - local i = 1 - - while #result > 0 do - local length = utf8.length(result[i]) - - if length > 0 then break - else table.remove(result, i) end - end - end - - return result - end - end -end - -function io_stream:write(arg, ...) - local arg_type = type(arg) - - if self.binary_mode then - local byte_arr - - if arg_type ~= "string" then - -- using arg as bytes table/bytearray - - if arg_type == "table" then - byte_arr = Bytearray(arg) - else - byte_arr = arg - end - else - byte_arr = byteutil.pack(arg, ...) - end - - self:__write(byte_arr) - else - if arg_type == "string" then - self:write_line(arg) - elseif arg_type == "table" then - for i = 1, #arg do - self:write_line(arg[i]) - end - else error("unknown argument type: "..arg_type) end - end -end - -function io_stream:seek(mode, offset) - if not self.io_lib.seek then - error("cannot seek this stream") - end - - self.io_lib.seek(self.descriptor, mode, offset) -end - -function io_stream:tell() - if not self.io_lib.tell then - error("cannot tell this stream") - end - - return self.io_lib.tell(self.descriptor) -end - -function io_stream:is_alive() - return self.io_lib.is_alive(self.descriptor) -end - -function io_stream:is_closed() - return not self:is_alive() -end - -function io_stream:close() - if self.mode == BUFFERED_MODE then - self.read_buffer:clear() - self.write_buffer:clear() - end - - return self.io_lib.close(self.descriptor) -end +function io_stream:close() return self.stream:close() end function io_stream:flush() - if self.mode == BUFFERED_MODE and #self.write_buffer > 0 then - self.io_lib.write(self.descriptor, self.write_buffer) - self.write_buffer:clear() - end - - if self.flush_mode ~= FLUSH_MODE_ONLY_BUFFER then - if self.io_lib.flush then - self.io_lib.flush(self.descriptor) - elseif self:is_closed() then error("stream is closed") end - end + if self.mode ~= "buffered" and self.flush_mode == "buffer" then return end + self.stream:flush() end - -return io_stream \ No newline at end of file +return io_stream From 2a4feaf1c4b2e4fa02fc582c5ca2942e54be6feb Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 17:35:07 +0300 Subject: [PATCH 38/43] update io_stream lua test --- dev/tests/io_stream.lua | 403 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 377 insertions(+), 26 deletions(-) diff --git a/dev/tests/io_stream.lua b/dev/tests/io_stream.lua index d08c68b0c..da2a2efb0 100644 --- a/dev/tests/io_stream.lua +++ b/dev/tests/io_stream.lua @@ -1,34 +1,385 @@ local device = file.create_memory_device() -file.write(device..":test.txt", "Hello\nWorld") -file.write_bytes(device..":test.bin", Bytearray({20, 30, 100, 200, 255})) -local stream = file.open(device..":test.txt", 'r') +local function path(name) return device .. ":" .. name end -local line1 = stream:read_line() -local line2 = stream:read_line() +local function eq_list(actual, expected, msg) + asserts.equals(#actual, #expected, (msg or "list") .. " length") + for i = 1, #expected do + asserts.equals(actual[i], expected[i], (msg or "list") .. "[" .. i .. "]") + end +end -assert(line1 == "Hello") -assert(line2 == "World") +file.write(path("test.txt"), "Hello\nWorld") +file.write_bytes(path("test.bin"), Bytearray({20, 30, 100, 200, 255})) -local stream2 = file.open(device..":test.bin", 'rb') -local data = stream2:read(5) -assert(data[1] == 20) -assert(data[2] == 30) -assert(data[3] == 100) -assert(data[4] == 200) -assert(data[5] == 255) +do + local stream = file.open(path("test.txt"), 'r') + asserts.equals(stream:read_line(), "Hello") + asserts.equals(stream:read_line(), "World") + stream:close() +end -local stream3 = file.open(device..":test.txt", 'r') -assert(stream3:is_alive()) -stream3:close() -assert(not stream3:is_alive()) +do + local stream = file.open(path("test.bin"), 'rb') + local data = stream:read(5) + asserts.equals(data[1], 20); asserts.equals(data[2], 30); asserts.equals(data[3], 100); asserts.equals(data[4], 200); asserts + .equals(data[5], 255) + stream:close() +end -local stream4 = file.open(device..":test.txt", 'r') -stream4:seek('b', 6) -local line = stream4:read_line() -assert(line == "World") +do + local stream = file.open(path("test.txt"), 'r') + assert(stream:is_alive()) + assert(not stream:is_closed()) + stream:close() + assert(not stream:is_alive()) + assert(stream:is_closed()) +end -local stream5 = file.open(device..":test.txt", 'r') -stream5:seek('e', 0) -local pos = stream5:tell() -assert(pos == 11) +do + local stream = file.open(path("test.txt"), 'r') + stream:seek('b', 6) + asserts.equals(stream:read_line(), "World") + stream:close() +end + +do + local stream = file.open(path("test.txt"), 'r') + stream:seek('e', 0) + asserts.equals(stream:tell(), 11) + stream:close() +end + +------------------------------------------------------------------------------- +-- text: line endings and end of stream +------------------------------------------------------------------------------- + +do + local stream = file.open(path("test.txt"), 'r') + stream:read_line(); stream:read_line() + asserts.equals(stream:read_line(), nil, "after last line") + asserts.equals(stream:read_line(), nil, "after last line, again") + stream:close() +end + +do + file.write(path("empty.txt"), "") + local stream = file.open(path("empty.txt"), 'r') + asserts.equals(stream:read_line(), nil, "empty file") + stream:close() +end + +do + file.write(path("crlf.txt"), "a\r\nb\rc\nd\r") + local stream = file.open(path("crlf.txt"), 'r') + asserts.equals(stream:read_line(), "a", "CRLF") + asserts.equals(stream:read_line(), "b\rc", "lone CR is kept") + asserts.equals(stream:read_line(), "d\r", "CR at end of stream") + asserts.equals(stream:read_line(), nil) + stream:close() +end + +------------------------------------------------------------------------------- +-- text: read(count) and read_fully +------------------------------------------------------------------------------- + +do + file.write(path("blank.txt"), "\n\nA\nB\n\n") + local stream = file.open(path("blank.txt"), 'r') + eq_list(stream:read(10), {"A", "B"}, "trimmed") + stream:close() +end + +do + local stream = file.open(path("blank.txt"), 'r') + eq_list(stream:read(10, false), {"", "", "A", "B", ""}, "untrimmed") + stream:close() +end + +do + file.write(path("only_blank.txt"), "\n\n\n") + local stream = file.open(path("only_blank.txt"), 'r') + eq_list(stream:read(5), {}, "only empty lines") + stream:close() +end + +do + local stream = file.open(path("test.txt"), 'r') + eq_list(stream:read(5), {"Hello", "World"}, "past end of stream") + stream:close() +end + +do + local stream = file.open(path("test.txt"), 'r') + assert(not pcall(stream.read, stream, -1), "negative count must fail") + stream:close() +end + +do + local stream = file.open(path("test.txt"), 'r') + asserts.equals(stream:read(), "Hello") + stream:close() +end + +do + local stream = file.open(path("test.txt"), 'r') + asserts.equals(stream:read_fully(), "Hello\nWorld", "read_fully as string") + stream:close() +end + +do + local stream = file.open(path("test.txt"), 'r') + eq_list(stream:read_fully(true), {"Hello", "World"}, "read_fully as lines") + stream:close() +end + +------------------------------------------------------------------------------- +-- text: writing +------------------------------------------------------------------------------- + +do + local stream = file.open(path("out.txt"), 'w') + stream:write("one") + stream:write({"two", "three"}) + stream:write_line("four") + stream:close() + asserts.equals(file.read(path("out.txt")), "one\ntwo\nthree\nfour\n", "text write") +end + +do + local stream = file.open(path("out.txt"), 'w') + assert(not pcall(stream.write, stream, 42), "writing a number in text mode must fail") + stream:close() +end + +------------------------------------------------------------------------------- +-- binary +------------------------------------------------------------------------------- + +do + local stream = file.open(path("test.bin"), 'rb') + eq_list(stream:read(5, true), {20, 30, 100, 200, 255}, "read as table") + stream:close() +end + +do + local stream = file.open(path("test.bin"), 'rb') + stream:read(3) + asserts.equals(#stream:read(10), 2, "short read") + asserts.equals(#stream:read(10), 0, "read at end of stream") + stream:close() +end + +do + local stream = file.open(path("test.bin"), 'rb') + local data = stream:read_fully() + asserts.equals(#data, 5); asserts.equals(data[1], 20); asserts.equals(data[5], 255) + stream:close() +end + +do + local stream = file.open(path("test.bin"), 'rb') + eq_list(stream:read_fully(true), {20, 30, 100, 200, 255}, "read_fully as table") + stream:close() +end + +do + local stream = file.open(path("out.bin"), 'wb') + stream:write({1, 2, 3}) + stream:write(Bytearray({4, 5})) + stream:close() + + local data = file.read_bytes(path("out.bin")) + asserts.equals(#data, 5, "binary write length") + for i = 1, 5 do asserts.equals(data[i], i, "binary write byte " .. i) end +end + +do + local stream = file.open(path("fmt.bin"), 'wb') + stream:write(" Date: Sat, 10 Oct 2026 17:42:21 +0300 Subject: [PATCH 39/43] fix '--test' run.sh --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 13b824d3c..4cc16d57d 100755 --- a/run.sh +++ b/run.sh @@ -36,7 +36,7 @@ function test { cd build rm -rf ./vctest-run mkdir ./vctest-run - ./vctest/vctest --exe ./VoxelEngine --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind + ./vctest/vctest --exe ./VoxelCore --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind cd .. run= } From 0efabc1883b70deb12cd2de3815e2391e950fceb Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 18:41:37 +0300 Subject: [PATCH 40/43] remove comments only relevant to the PR --- src/io/devices/ZipFileDevice.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index 025c1c335..8420e1e1d 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -58,8 +58,7 @@ namespace { } uint32_t to_ms_dos_timestamp(const file_time_type& fileTime) { - // 1980-01-01 00:00, the earliest MS-DOS date; used for unknown time - // (devices without timestamps return file_time_type::min()) + // 1980-01-01 00:00, the earliest MS-DOS date constexpr uint32_t DOS_EPOCH = (0 << 9 | 1 << 5 | 1) << 16; if (fileTime == file_time_type::min()) { return DOS_EPOCH; @@ -68,7 +67,6 @@ namespace { fileTime - file_time_type::clock::now() + system_clock::now() ); std::time_t timeT = system_clock::to_time_t(timePoint); - // localtime returns nullptr for out of range time on Windows const std::tm* tmPtr = std::localtime(&timeT); if (tmPtr == nullptr || tmPtr->tm_year < 80) { return DOS_EPOCH; From 40db547817c94b1476551053002e2e3455fda57a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 20:42:07 +0300 Subject: [PATCH 41/43] fix: entities frustum-culling not uses hitbox size (it uses entity scale only) --- src/objects/Entities.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index 46746684e..c231a91cd 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -480,15 +480,17 @@ void Entities::render( const Frustum* frustum, entityid_t fpsEntity ) { - auto view = registry->view(); - for (auto [entity, eid, transform, skeleton] : view.each()) { + auto view = registry->view(); + for (auto [entity, eid, transform, skeleton, rigidbody] : view.each()) { if (eid.uid == fpsEntity) { continue; } const auto& def = eid.def; const auto& pos = transform.pos; const auto& size = transform.size; - if (frustum && !frustum->isBoxVisible(pos - size, pos + size)) { + const auto& halfSize = rigidbody.hitbox.getHalfSize(); + // todo: more correct frustum culling + if (frustum && !frustum->isBoxVisible(pos - halfSize, pos + halfSize)) { continue; } From eb2afe822d71d6eeeb13585d85d1dfaf1182fdd1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 11 Oct 2026 13:05:30 +0300 Subject: [PATCH 42/43] cleanup --- dev/tests/zip_files.lua | 1 + src/io/devices/ZipFileDevice.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/zip_files.lua b/dev/tests/zip_files.lua index ad5f4e7e0..e7ed664cb 100644 --- a/dev/tests/zip_files.lua +++ b/dev/tests/zip_files.lua @@ -86,6 +86,7 @@ local function check_zip(src, zipfile) debug.log("unmount "..m) file.unmount(m) + assert(not file.exists(m..":")) assert(not pcall(file.read, m..":root.txt")) assert(not pcall(file.unmount, m)) end diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index 8420e1e1d..f097f77f6 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -182,7 +182,6 @@ ZipFileDevice::ZipFileDevice( entries[entry.fileName] = std::move(entry); } - // Add missing parent directories entries std::vector names; names.reserve(entries.size()); for (const auto& [name, _] : entries) { From e3d514c7665d3e94a023a0451a6cd4ca784b5a82 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 11 Oct 2026 13:07:50 +0300 Subject: [PATCH 43/43] resolve conflict --- src/io/memory_ostream.hpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/io/memory_ostream.hpp b/src/io/memory_ostream.hpp index 3ee853a30..a46043ba8 100644 --- a/src/io/memory_ostream.hpp +++ b/src/io/memory_ostream.hpp @@ -46,26 +46,6 @@ protected: return c; } - pos_type seekoff( - off_type off, - std::ios_base::seekdir way, - std::ios_base::openmode mode = std::ios_base::out - ) override { - // only position query (tellp) is supported - if (off == 0 && way == std::ios_base::cur && - (mode & std::ios_base::out)) { - return pos_type(off_type(size())); - } - return pos_type(off_type(-1)); - } - - std::streamsize xsputn(const char* s, std::streamsize count) override { - reserve(position() + count); - std::memcpy(pptr(), s, count); - advance(count); - return count; - } - pos_type seekoff( off_type off, std::ios_base::seekdir dir,