reverting it because voices are not reasom

This reverts commit ecc4c1794e.
This commit is contained in:
MihailRis 2026-11-03 22:08:44 +03:00
parent ecc4c1794e
commit 24718a2993
4 changed files with 16 additions and 39 deletions

View file

@ -1,19 +1,12 @@
content_report = nil content_report = nil
function delete_content() function delete_content()
local blocks = {} local units = {}
local items = {}
for i, entry in ipairs(content_report.content) do for i, entry in ipairs(content_report.content) do
local type = entry.type table.insert(units, entry.name)
if type == "block" then
table.insert(blocks, entry.name)
elseif type == "item" then
table.insert(items, entry.name)
end
end end
local request = { local request = {
blocks = blocks, units = units
items = items
} }
app.delete_world_content(content_report.world, request, true) app.delete_world_content(content_report.world, request, true)
end end

View file

@ -328,34 +328,21 @@ static int l_delete_world(lua::State* L) {
return 0; return 0;
} }
static ContentRemovalRequest parse_content_removal_request( static ContentRemovalRequest parse_content_removal_request(lua::State* L, int idx) {
lua::State* L, int idx
) {
ContentRemovalRequest request; ContentRemovalRequest request;
if (!lua::istable(L, idx)) { if (!lua::istable(L, idx)) {
throw std::runtime_error("table expected as argument"); throw std::runtime_error("table expected as argument");
} }
lua::pushnil(L); if (!lua::getfield(L, "units", idx)) {
while (lua::next(L, idx)) { throw std::runtime_error("table with 'units' field expected");
auto key = lua::require_lstring(L, -2); }
int len = lua::objlen(L, -1); if (!lua::istable(L, -1)) {
throw std::runtime_error("'units' field must be a table");
for (int i = 0; i < len; i++) { }
lua::rawgeti(L, i + 1); int len = lua::objlen(L, -1);
auto value = lua::require_lstring(L, -1); for (int i = 0; i < len; i++) {
lua::rawgeti(L, i + 1);
if (key == "blocks") { request.units.emplace_back(lua::require_lstring(L, -1));
request.blocks.emplace_back(value);
} else if (key == "items") {
request.items.emplace_back(value);
} else {
throw std::runtime_error(
"invalid key in content removal request: " +
std::string(key)
);
}
lua::pop(L);
}
lua::pop(L); lua::pop(L);
} }
return request; return request;

View file

@ -249,10 +249,8 @@ static void replace_all(
void WorldFiles::deleteContent(const ContentRemovalRequest& request) { void WorldFiles::deleteContent(const ContentRemovalRequest& request) {
auto root = io::read_json(getIndicesFile()); auto root = io::read_json(getIndicesFile());
for (const auto& unit : request.blocks) { for (const auto& unit : request.units) {
replace_all(root["blocks"], unit, CORE_AIR); replace_all(root["blocks"], unit, CORE_AIR);
}
for (const auto& unit : request.items) {
replace_all(root["items"], unit, CORE_EMPTY); replace_all(root["items"], unit, CORE_EMPTY);
} }
io::write_json(getIndicesFile(), root); io::write_json(getIndicesFile(), root);

View file

@ -24,8 +24,7 @@ struct WorldInfo;
struct DebugSettings; struct DebugSettings;
struct ContentRemovalRequest { struct ContentRemovalRequest {
std::vector<std::string> blocks; std::vector<std::string> units;
std::vector<std::string> items;
}; };
class WorldFiles { class WorldFiles {