From 2a9507b54e58f852b558d7bc9b2cc88397d37a34 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 10 Oct 2025 19:57:53 +0300 Subject: [PATCH 1/9] fix: byteutil.unpack 'b' is equivalent of 'B' --- src/logic/scripting/lua/libs/libbyteutil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logic/scripting/lua/libs/libbyteutil.cpp b/src/logic/scripting/lua/libs/libbyteutil.cpp index 54485fc1c..429f0feb5 100644 --- a/src/logic/scripting/lua/libs/libbyteutil.cpp +++ b/src/logic/scripting/lua/libs/libbyteutil.cpp @@ -137,7 +137,7 @@ static int l_unpack(lua::State* L) { for (size_t i = 0; format[i]; i++) { switch (format[i]) { case 'b': - lua::pushinteger(L, reader.get()); + lua::pushinteger(L, static_cast(reader.get())); break; case 'B': lua::pushinteger(L, reader.get() & 0xFF); From 5755c616f35cc1c1fc5e94ecbc9c38a5a7f52275 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 13 Oct 2025 12:29:09 +0300 Subject: [PATCH 2/9] fix: missing yaml null literals --- src/coders/yaml.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/coders/yaml.cpp b/src/coders/yaml.cpp index b10d5ce2c..33eab3a5d 100644 --- a/src/coders/yaml.cpp +++ b/src/coders/yaml.cpp @@ -38,7 +38,7 @@ static dv::value perform_literal(std::string_view literal) { literal == "false" || literal == "False") { return literal[0] == 't'; } - if (literal == "null" || literal == "Null") { + if (literal == "null" || literal == "Null" || literal == "~") { return nullptr; } return std::string(literal); @@ -204,8 +204,9 @@ dv::value Parser::parseFullValue(int indent) { skipEmptyLines(); int init_pos = pos; int next_indent = countIndent(); - if (next_indent < indent) { - throw error("indentation error"); + if (next_indent <= indent) { + pos = init_pos; + return nullptr; } if (source[pos] == '-') { pos = init_pos; From 026ae756cf4ad4a4febbef58ce2f007b2a0fc974 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 13 Oct 2025 23:09:24 +0300 Subject: [PATCH 3/9] fix yaml array parsing --- src/coders/BasicParser.inl | 6 +++++- src/coders/yaml.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/coders/BasicParser.inl b/src/coders/BasicParser.inl index 7af27fe58..796205b2a 100644 --- a/src/coders/BasicParser.inl +++ b/src/coders/BasicParser.inl @@ -139,8 +139,12 @@ void BasicParser::skipLine() { template void BasicParser::skipEmptyLines() { + if (!hasNext()) { + return; + } + size_t initpos = pos; skipWhitespace(); - pos = linestart; + pos = std::max(initpos, linestart); } template diff --git a/src/coders/yaml.cpp b/src/coders/yaml.cpp index 33eab3a5d..f400f6673 100644 --- a/src/coders/yaml.cpp +++ b/src/coders/yaml.cpp @@ -270,6 +270,10 @@ dv::value Parser::parseArray(int indent) { dv::value object = dv::object(); object[std::string(name)] = parseFullValue(next_indent); skipEmptyLines(); + if (!hasNext()) { + list.add(std::move(object)); + break; + } next_indent = countIndent(); if (next_indent > indent) { pos = linestart; From f3ed3d26c825ee3d79dd829bc12cabbdfbeb63b4 Mon Sep 17 00:00:00 2001 From: KotIsOff Date: Tue, 14 Oct 2025 20:46:38 +0300 Subject: [PATCH 4/9] typo: greather => greater --- doc/en/scripting/builtins/libblock.md | 2 +- src/content/ContentPack.hpp | 8 ++++---- src/content/ContentPackVersion.hpp | 4 ++-- src/graphics/core/Atlas.hpp | 2 +- src/graphics/render/Decorator.cpp | 2 +- src/graphics/ui/elements/TextBox.hpp | 2 +- src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp | 2 +- src/voxels/Block.hpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/en/scripting/builtins/libblock.md b/doc/en/scripting/builtins/libblock.md index 044555c43..4ad46f14a 100644 --- a/doc/en/scripting/builtins/libblock.md +++ b/doc/en/scripting/builtins/libblock.md @@ -101,7 +101,7 @@ block.set_rotation(x: int, y: int, z: int, rotation: int) ## Extended blocks -Extended blocks are blocks with size greather than 1x1x1 +Extended blocks are blocks with size greater than 1x1x1 ```lua -- Checks whether the block is extended. diff --git a/src/content/ContentPack.hpp b/src/content/ContentPack.hpp index bcc91ecb7..a4548d038 100644 --- a/src/content/ContentPack.hpp +++ b/src/content/ContentPack.hpp @@ -27,15 +27,15 @@ public: }; enum class VersionOperator { - EQUAL, GREATHER, LESS, - GREATHER_OR_EQUAL, LESS_OR_EQUAL + EQUAL, GREATER, LESS, + GREATER_OR_EQUAL, LESS_OR_EQUAL }; VC_ENUM_METADATA(VersionOperator) {"=", VersionOperator::EQUAL}, - {">", VersionOperator::GREATHER}, + {">", VersionOperator::GREATER}, {"<", VersionOperator::LESS}, - {">=", VersionOperator::GREATHER_OR_EQUAL}, + {">=", VersionOperator::GREATER_OR_EQUAL}, {"<=", VersionOperator::LESS_OR_EQUAL}, VC_ENUM_END diff --git a/src/content/ContentPackVersion.hpp b/src/content/ContentPackVersion.hpp index 54deaf3cf..0d8a2ba25 100644 --- a/src/content/ContentPackVersion.hpp +++ b/src/content/ContentPackVersion.hpp @@ -37,13 +37,13 @@ public: switch (op) { case VersionOperator::EQUAL: return *this == other; - case VersionOperator::GREATHER: + case VersionOperator::GREATER: return *this > other; case VersionOperator::LESS: return *this < other; case VersionOperator::LESS_OR_EQUAL: return *this <= other; - case VersionOperator::GREATHER_OR_EQUAL: + case VersionOperator::GREATER_OR_EQUAL: return *this >= other; default: return false; diff --git a/src/graphics/core/Atlas.hpp b/src/graphics/core/Atlas.hpp index 2e563e8a2..af3e47214 100644 --- a/src/graphics/core/Atlas.hpp +++ b/src/graphics/core/Atlas.hpp @@ -54,7 +54,7 @@ public: /// @brief Build atlas from all added images /// @param extrusion textures extrusion pixels - /// (greather is less mip-mapping artifacts) + /// (greater is less mip-mapping artifacts) /// @param prepare generate atlas texture (calls .prepare()) /// @param maxResolution max atlas resolution std::unique_ptr build(uint extrusion, bool prepare=true, uint maxResolution=0); diff --git a/src/graphics/render/Decorator.cpp b/src/graphics/render/Decorator.cpp index 4742b68f7..94b8ee130 100644 --- a/src/graphics/render/Decorator.cpp +++ b/src/graphics/render/Decorator.cpp @@ -25,7 +25,7 @@ namespace fs = std::filesystem; -/// @brief Not greather than 64 for this BIG_PRIME value +/// @brief Not greater than 64 for this BIG_PRIME value inline constexpr int UPDATE_AREA_DIAMETER = 32; /// @brief Number of blocks in the volume inline constexpr int UPDATE_BLOCKS = diff --git a/src/graphics/ui/elements/TextBox.hpp b/src/graphics/ui/elements/TextBox.hpp index c4b88f909..d5b640ac8 100644 --- a/src/graphics/ui/elements/TextBox.hpp +++ b/src/graphics/ui/elements/TextBox.hpp @@ -44,7 +44,7 @@ namespace gui { runnable onDownPressed; /// @brief Is current input valid bool valid = true; - /// @brief Text input pointer, value may be greather than text length + /// @brief Text input pointer, value may be greater than text length size_t caret = 0; /// @brief Actual local (line) position of the caret on vertical move size_t maxLocalCaret = 0; diff --git a/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp b/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp index 290e13456..3e015b72e 100644 --- a/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp +++ b/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp @@ -272,7 +272,7 @@ static int l_meta_meta_call(lua::State* L) { auto width = tointeger(L, 2); auto height = tointeger(L, 3); if (width <= 0 || height <= 0) { - throw std::runtime_error("width and height must be greather than 0"); + throw std::runtime_error("width and height must be greater than 0"); } return newuserdata( L, static_cast(width), static_cast(height) diff --git a/src/voxels/Block.hpp b/src/voxels/Block.hpp index 3dbd1cf0c..59115e84f 100644 --- a/src/voxels/Block.hpp +++ b/src/voxels/Block.hpp @@ -276,7 +276,7 @@ public: /// @brief does the block emit any lights bool emissive = false; - // @brief block size is greather than 1x1x1 + // @brief block size is greater than 1x1x1 bool extended = false; /// @brief set of hitboxes sets with all coord-systems precalculated From f73663dc9c0517d5e1f3945b0327d846e78bf3a3 Mon Sep 17 00:00:00 2001 From: KotIsOff Date: Tue, 14 Oct 2025 21:17:39 +0300 Subject: [PATCH 5/9] refactor Version pseudoclass in content.xml.lua --- res/layouts/pages/content.xml.lua | 37 ++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/res/layouts/pages/content.xml.lua b/res/layouts/pages/content.xml.lua index 611aca635..dc952645d 100644 --- a/res/layouts/pages/content.xml.lua +++ b/res/layouts/pages/content.xml.lua @@ -194,42 +194,49 @@ function Version.__equal(ver1, ver2) return ver1[1] == ver2[1] and ver1[2] == ver2[2] and ver1[3] == ver2[3]; end -function Version.__more(ver1, ver2) +function Version.__greater(ver1, ver2) if ver1[1] ~= ver2[1] then return ver1[1] > ver2[1] end; if ver1[2] ~= ver2[2] then return ver1[2] > ver2[2] end; return ver1[3] > ver2[3]; end function Version.__less(ver1, ver2) - return Version.__more(ver2, ver1); + return Version.__greater(ver2, ver1); end -function Version.__more_or_equal(ver1, ver2) +function Version.__greater_or_equal(ver1, ver2) return not Version.__less(ver1, ver2); end function Version.__less_or_equal(ver1, ver2) - return not Version.__more(ver1, ver2); + return not Version.__greater(ver1, ver2); end +Version.operators = { + ["="] = Version.__equal, + [">"] = Version.__greater, + ["<"] = Version.__less, + [">="] = Version.__greater_or_equal, + ["<="] = Version.__less_or_equal +} + function Version.compare(op, ver1, ver2) ver1 = string.split(ver1, "."); ver2 = string.split(ver2, "."); - if op == "=" then return Version.__equal(ver1, ver2); - elseif op == ">" then return Version.__more(ver1, ver2); - elseif op == "<" then return Version.__less(ver1, ver2); - elseif op == ">=" then return Version.__more_or_equal(ver1, ver2); - elseif op == "<=" then return Version.__less_or_equal(ver1, ver2); - else return false; end + local comparison_func = Version.operators[op]; + + if comparison_func then + return comparison_func(ver1, ver2); + else + return false; + end end -function Version.parse(version) +function Version.parse(version) local op = string.sub(version, 1, 2); - if op == ">=" or op == "=>" then - return ">=", string.sub(version, #op + 1); - elseif op == "<=" or op == "=<" then - return "<=", string.sub(version, #op + 1); + if op == ">=" or op == "<=" then + return op, string.sub(version, #op + 1); end op = string.sub(version, 1, 1); From a1f0c2c2527b91d3a1d4f47eb2c043ebdef60119 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 14 Oct 2025 21:44:14 +0300 Subject: [PATCH 6/9] fix mouse click textbox caret set --- src/graphics/ui/elements/TextBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/ui/elements/TextBox.cpp b/src/graphics/ui/elements/TextBox.cpp index 81732348f..c9afde7f8 100644 --- a/src/graphics/ui/elements/TextBox.cpp +++ b/src/graphics/ui/elements/TextBox.cpp @@ -661,7 +661,7 @@ int TextBox::calcIndexAt(int x, int y) const { line = std::min(line, label->getLinesNumber() - 1); size_t lineLength = getLineLength(line); uint offset = 0; - while (lcoord.x + rawTextCache.metrics.calcWidth(labelText, offset) < x && + while (lcoord.x + rawTextCache.metrics.calcWidth(labelText, 0, offset) < x && offset < lineLength - 1) { offset++; } From 76b54a890c35b6edb6d5018078c865f31e966965 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 14 Oct 2025 22:20:27 +0300 Subject: [PATCH 7/9] fix wrapped textbox selection render --- src/graphics/ui/elements/TextBox.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/graphics/ui/elements/TextBox.cpp b/src/graphics/ui/elements/TextBox.cpp index c9afde7f8..a09a47fa9 100644 --- a/src/graphics/ui/elements/TextBox.cpp +++ b/src/graphics/ui/elements/TextBox.cpp @@ -253,9 +253,10 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) { float time = gui.getWindow().time(); if (editable && static_cast((time - caretLastMove) * 2) % 2 == 0) { - uint line = rawTextCache.getLineByTextIndex(caret); - uint lcaret = caret - rawTextCache.getTextLineOffset(line); + uint line = label->getLineByTextIndex(caret); + uint lcaret = caret - label->getTextLineOffset(line); int width = rawTextCache.metrics.calcWidth(input, 0, lcaret); + batch->rect( lcoord.x + width, lcoord.y + label->getLineYOffset(line), @@ -272,10 +273,10 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) { batch->setColor(glm::vec4(0.8f, 0.9f, 1.0f, 0.25f)); int start = rawTextCache.metrics.calcWidth( - labelText, selectionStart - label->getTextLineOffset(startLine) + labelText, 0, selectionStart - label->getTextLineOffset(startLine) ); int end = rawTextCache.metrics.calcWidth( - labelText, selectionEnd - label->getTextLineOffset(endLine) + labelText, 0, selectionEnd - label->getTextLineOffset(endLine) ); int lineY = label->getLineYOffset(startLine); @@ -1210,8 +1211,8 @@ void TextBox::setCaret(size_t position) { scrolled(-glm::ceil(offset / static_cast(scrollStep) + 0.5f)); } int lcaret = caret - rawTextCache.getTextLineOffset(line); - int realoffset = - rawTextCache.metrics.calcWidth(labelText, 0, lcaret) - static_cast(textOffset) + 2; + int realoffset = rawTextCache.metrics.calcWidth(labelText, 0, lcaret) - + static_cast(textOffset) + 2; if (realoffset - width > 0) { setTextOffset(textOffset + realoffset - width); From ee6f006b797d1a560baa9e333c99ee0181f548b6 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 14 Oct 2025 22:54:23 +0300 Subject: [PATCH 8/9] fix broken dependencies management --- doc/en/scripting/builtins/libpack.md | 2 +- doc/ru/scripting/builtins/libpack.md | 2 +- res/layouts/console.xml | 1 + res/layouts/pages/content.xml.lua | 12 ++++++------ src/content/PacksManager.cpp | 4 +--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/doc/en/scripting/builtins/libpack.md b/doc/en/scripting/builtins/libpack.md index 3a11dc55e..2daab1269 100644 --- a/doc/en/scripting/builtins/libpack.md +++ b/doc/en/scripting/builtins/libpack.md @@ -104,7 +104,7 @@ pack.get_info(packids: table) -> {id={...}, id2={...}, ...} ``` ```lua -pack.assemble(packis: table) -> table +pack.assemble(packids: table) -> table ``` Checks the configuration for correctness and adds dependencies, returning the complete configuration. diff --git a/doc/ru/scripting/builtins/libpack.md b/doc/ru/scripting/builtins/libpack.md index d6f7efaea..91726d72e 100644 --- a/doc/ru/scripting/builtins/libpack.md +++ b/doc/ru/scripting/builtins/libpack.md @@ -92,7 +92,7 @@ pack.get_info(packids: table) -> {id={...}, id2={...}, ...} ``` ```lua -pack.assemble(packis: table) -> table +pack.assemble(packids: table) -> table ``` Проверяет корректность конфигурации и добавляет зависимости, возвращая полную. diff --git a/res/layouts/console.xml b/res/layouts/console.xml index 3772d2402..756459de8 100644 --- a/res/layouts/console.xml +++ b/res/layouts/console.xml @@ -33,4 +33,5 @@ onup="on_history_up()" ondown="on_history_down()"> + diff --git a/res/layouts/pages/content.xml.lua b/res/layouts/pages/content.xml.lua index dc952645d..89c230ed0 100644 --- a/res/layouts/pages/content.xml.lua +++ b/res/layouts/pages/content.xml.lua @@ -347,12 +347,6 @@ function refresh() packs_info[id] = {packinfo.id, packinfo.title} end - for i,id in ipairs(packs_installed) do - if table.has(required, id) then - document["pack_"..id].enabled = false - end - end - if #packs_excluded == 0 then packs_excluded = table.copy(packs_available) end if #packs_included == 0 then packs_included = table.copy(packs_installed) end @@ -372,6 +366,12 @@ function refresh() place_pack(packs_add, packinfo, callback, string.format('reposition_func("%s")', packinfo.id)) end + for i,id in ipairs(packs_installed) do + if table.has(required, id) then + document["pack_"..id].enabled = false + end + end + check_deleted() apply_movements(packs_cur, packs_add) refresh_changes() diff --git a/src/content/PacksManager.cpp b/src/content/PacksManager.cpp index 3cbde0f2c..122767177 100644 --- a/src/content/PacksManager.cpp +++ b/src/content/PacksManager.cpp @@ -108,17 +108,15 @@ static bool resolve_dependencies( continue; } - auto dep_pack = found -> second; + auto dep_pack = found->second; if (Version::matchesPattern(dep.version) && Version::matchesPattern(dep_pack.version) && Version(dep_pack.version) .processOperator(dep.op, Version(dep.version)) ) { // dependency pack version meets the required one - continue; } else if (dep.version == "*" || dep.version == dep_pack.version){ // fallback: dependency pack version also meets required one - continue; } else { throw contentpack_error( dep.id, From ec94abccbc4604e5d945d2bb8d1a63561797092b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 15 Oct 2025 12:17:46 +0300 Subject: [PATCH 9/9] fix assets.parse_model with 'xml' format --- res/layouts/code_editor.xml.lua | 2 +- res/layouts/console.xml | 1 - src/assets/assetload_funcs.cpp | 3 ++- src/coders/vcm.cpp | 6 +++--- src/coders/vcm.hpp | 4 +++- src/logic/scripting/lua/libs/libassets.cpp | 4 +++- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/res/layouts/code_editor.xml.lua b/res/layouts/code_editor.xml.lua index 4e6c68d47..733fa9036 100644 --- a/res/layouts/code_editor.xml.lua +++ b/res/layouts/code_editor.xml.lua @@ -110,7 +110,7 @@ function unlock_access() end local function reload_model(filename, name) - assets.parse_model("xml", document.editor.text, name) + assets.parse_model(file.ext(filename), document.editor.text, name) end function run_current_file() diff --git a/res/layouts/console.xml b/res/layouts/console.xml index 756459de8..3772d2402 100644 --- a/res/layouts/console.xml +++ b/res/layouts/console.xml @@ -33,5 +33,4 @@ onup="on_history_up()" ondown="on_history_down()"> - diff --git a/src/assets/assetload_funcs.cpp b/src/assets/assetload_funcs.cpp index 88dd66bd9..d865cc1ac 100644 --- a/src/assets/assetload_funcs.cpp +++ b/src/assets/assetload_funcs.cpp @@ -381,7 +381,8 @@ assetload::postfunc assetload::model( auto text = io::read_string(path); try { - auto model = vcm::parse(path.string(), text).release(); + auto model = vcm::parse(path.string(), text, path.extension() == ".xml") + .release(); return [=](Assets* assets) { request_textures(loader, *model); assets->store(std::unique_ptr(model), name); diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp index 9b564787c..337d721f1 100644 --- a/src/coders/vcm.cpp +++ b/src/coders/vcm.cpp @@ -163,11 +163,11 @@ static std::unique_ptr load_model(const xmlelement& root) { } std::unique_ptr vcm::parse( - std::string_view file, std::string_view src + std::string_view file, std::string_view src, bool usexml ) { try { - auto doc = io::path(std::string(file)).extension() == ".xml" - ? xml::parse(file, src) : xml::parse_vcm(file, src, "model"); + auto doc = + usexml ? xml::parse(file, src) : xml::parse_vcm(file, src, "model"); const auto& root = *doc->getRoot(); if (root.getTag() != "model") { throw std::runtime_error( diff --git a/src/coders/vcm.hpp b/src/coders/vcm.hpp index 6f2396041..e0629de18 100644 --- a/src/coders/vcm.hpp +++ b/src/coders/vcm.hpp @@ -8,5 +8,7 @@ namespace model { } namespace vcm { - std::unique_ptr parse(std::string_view file, std::string_view src); + std::unique_ptr parse( + std::string_view file, std::string_view src, bool usexml + ); } diff --git a/src/logic/scripting/lua/libs/libassets.cpp b/src/logic/scripting/lua/libs/libassets.cpp index 047b63306..809480ee1 100644 --- a/src/logic/scripting/lua/libs/libassets.cpp +++ b/src/logic/scripting/lua/libs/libassets.cpp @@ -55,7 +55,9 @@ static int l_parse_model(lua::State* L) { auto name = lua::require_string(L, 3); if (format == "xml" || format == "vcm") { - engine->getAssets()->store(vcm::parse(name, string), name); + engine->getAssets()->store( + vcm::parse(name, string, format == "xml"), name + ); } else { throw std::runtime_error("unknown format " + util::quote(std::string(format))); }