From 33c76e7d704c047d259e924d4b45f99c42ca9ce3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 18 Dec 2024 19:54:47 +0300 Subject: [PATCH 1/5] add 'heightmap-inputs' to world-generator docs --- doc/en/world-generator.md | 1 + doc/ru/world-generator.md | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/en/world-generator.md b/doc/en/world-generator.md index 2112bce21..b0ab265c9 100644 --- a/doc/en/world-generator.md +++ b/doc/en/world-generator.md @@ -52,6 +52,7 @@ The main properties described in the configuration file: - **biomes-bpd** - number of blocks per point of the biome selection parameter map. Default: 4. - **heights-bpd** - number of blocks per point of the height map. Default: 4. - **wide-structs-chunks-radius** - maximum radius for placing 'wide' structures, measured in chunks. +- **heightmap-inputs** - an array of parameter map numbers that will be passed by the inputs table to the height map generation function. ## Global variables diff --git a/doc/ru/world-generator.md b/doc/ru/world-generator.md index 1523f94ad..5c1c6e6e9 100644 --- a/doc/ru/world-generator.md +++ b/doc/ru/world-generator.md @@ -52,6 +52,7 @@ - **biomes-bpd** - количество блоков на точку карты параметра выбора биомов. По-умолчанию: 4. - **heights-bpd** - количество блоков на точку карты высот. По-умолчанию: 4. - **wide-structs-chunks-radius** - масимальный радиус размещения 'широких' структур, измеряемый в чанках. +- **heightmap-inputs** - массив номеров карт параметров, которые будут переданы таблицей inputs в функцию генерации карты высот. ## Глобальные переменные From babb6a6d8da270e42155dfd63451399046e11ea2 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 18 Dec 2024 23:49:39 +0300 Subject: [PATCH 2/5] update doc/*/audio.md --- doc/en/audio.md | 6 +++--- doc/ru/audio.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/en/audio.md b/doc/en/audio.md index 9322583fd..cacd71074 100644 --- a/doc/en/audio.md +++ b/doc/en/audio.md @@ -60,7 +60,7 @@ Library **audio** contains available Audio API in Lua scripts. ```lua audio.play_stream( - -- audio file location + -- audio file location (without entry point, but with extension included) name: string, -- audio source world position x: number, y: number, z: number, @@ -79,7 +79,7 @@ Plays streaming audio from the specified file at the specified world position. R ```lua audio.play_stream_2d( - -- audio file location + -- audio file location (without entry point, but with extension included) name: string, -- audio gain (0.0 - 1.0) volume: number @@ -202,4 +202,4 @@ audio.count_speakers() -> integer -- get current number of playing streams audio.count_streams() -> integer -``` \ No newline at end of file +``` diff --git a/doc/ru/audio.md b/doc/ru/audio.md index b560b7392..1fce6c358 100644 --- a/doc/ru/audio.md +++ b/doc/ru/audio.md @@ -61,7 +61,7 @@ ```lua audio.play_stream( - -- путь к аудио-файлу + -- путь к аудио-файлу (без точки входа, но с указанием расширения) name: string, -- позиция источника аудио в мире x: number, y: number, z: number, @@ -80,7 +80,7 @@ audio.play_stream( ```lua audio.play_stream_2d( - -- путь к аудио-файлу + -- путь к аудио-файлу (без точки входа, но с указанием расширения) name: string, -- громкость аудио (от 0.0 до 1.0) volume: number From 61741a5cc898272627491b4cd8d5404048169df1 Mon Sep 17 00:00:00 2001 From: Richard Try Date: Thu, 19 Dec 2024 01:37:34 +0300 Subject: [PATCH 3/5] Copy metatable in table.deepcopy Copy metatable as well during deep copying --- res/scripts/stdmin.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index 13934e066..76df31e2a 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -74,7 +74,7 @@ function table.deep_copy(t) end end - return copied + return setmetatable(copied, getmetatable(t)) end function table.count_pairs(t) From 2787f2fc5495004f6029644ed5221f3abfc0c68f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 19 Dec 2024 22:44:54 +0300 Subject: [PATCH 4/5] fix: grabbed item is deleted on inventory close --- src/frontend/hud.cpp | 28 ++++++++++++++++++++++++++++ src/frontend/hud.hpp | 3 +++ 2 files changed, 31 insertions(+) diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 21111e187..01252c4c3 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -47,6 +47,7 @@ #include "window/Window.hpp" #include "world/Level.hpp" #include "world/World.hpp" +#include "debug/Logger.hpp" #include #include @@ -56,6 +57,8 @@ using namespace gui; +static debug::Logger logger("hud"); + bool Hud::showGeneratorMinimap = false; // implemented in debug_panel.cpp @@ -485,7 +488,32 @@ void Hud::openPermanent(UiDocument* doc) { add(HudElement(hud_element_mode::permanent, doc, doc->getRoot(), false)); } +void Hud::dropExchangeSlot() { + auto slotView = std::dynamic_pointer_cast( + gui->get(SlotView::EXCHANGE_SLOT_NAME) + ); + if (slotView == nullptr) { + return; + } + ItemStack& stack = slotView->getStack(); + + auto indices = frontend.getLevel().content->getIndices(); + if (auto invView = std::dynamic_pointer_cast(blockUI)) { + invView->getInventory()->move(stack, indices); + } + if (stack.isEmpty()) { + return; + } + player->getInventory()->move(stack, indices); + if (!stack.isEmpty()) { + logger.warning() << "discard item [" << stack.getItemId() << ":" + << stack.getCount(); + stack.clear(); + } +} + void Hud::closeInventory() { + dropExchangeSlot(); gui->remove(SlotView::EXCHANGE_SLOT_NAME); exchangeSlot = nullptr; exchangeSlotInv = nullptr; diff --git a/src/frontend/hud.hpp b/src/frontend/hud.hpp index 5594664ac..ad834955a 100644 --- a/src/frontend/hud.hpp +++ b/src/frontend/hud.hpp @@ -128,6 +128,9 @@ class Hud : public util::ObjectsKeeper { void updateHotbarControl(); void cleanup(); + /// @brief Perform exchange slot removal when it's not empty. + void dropExchangeSlot(); + void showExchangeSlot(); void updateWorldGenDebugVisualization(); public: From cda34e3975a42696ea31a1b0018731e746cd13bb Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 19 Dec 2024 22:54:54 +0300 Subject: [PATCH 5/5] fix block overriding --- src/content/ContentLoader.cpp | 8 +++----- src/voxels/Block.hpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index 1e954a557..fee559e4f 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -220,11 +220,11 @@ void ContentLoader::loadBlock( } // block model - std::string modelTypeName; + std::string modelTypeName = to_string(def.model); root.at("model").get(modelTypeName); root.at("model-name").get(def.modelName); if (auto model = BlockModel_from(modelTypeName)) { - if (*model == BlockModel::custom) { + if (*model == BlockModel::custom && def.customModelRaw == nullptr) { if (root.has("model-primitives")) { def.customModelRaw = root["model-primitives"]; } else if (def.modelName.empty()) { @@ -246,7 +246,7 @@ void ContentLoader::loadBlock( root.at("material").get(def.material); // rotation profile - std::string profile = "none"; + std::string profile = def.rotations.name; root.at("rotation").get(profile); def.rotatable = profile != "none"; @@ -285,8 +285,6 @@ void ContentLoader::loadBlock( ); aabb.b += aabb.a; def.hitboxes = {aabb}; - } else { - def.hitboxes = {AABB()}; } // block light emission [r, g, b] where r,g,b in range [0..15] diff --git a/src/voxels/Block.hpp b/src/voxels/Block.hpp index e7fb182cf..557bf04cb 100644 --- a/src/voxels/Block.hpp +++ b/src/voxels/Block.hpp @@ -181,7 +181,7 @@ class Block { bool translucent = false; /// @brief Set of block physical hitboxes - std::vector hitboxes; + std::vector hitboxes {AABB()}; /// @brief Set of available block rotations (coord-systems) BlockRotProfile rotations = BlockRotProfile::NONE;