Merge branch 'main' into update-file-subsystem
This commit is contained in:
commit
28caec6aa0
@ -419,8 +419,9 @@ end
|
|||||||
|
|
||||||
function start_coroutine(chunk, name)
|
function start_coroutine(chunk, name)
|
||||||
local co = coroutine.create(function()
|
local co = coroutine.create(function()
|
||||||
local status, error = xpcall(chunk, function(...)
|
local status, error = xpcall(chunk, function(err)
|
||||||
gui.alert(debug.traceback(), function()
|
local fullmsg = "error: "..string.match(err, ": (.+)").."\n"..debug.traceback()
|
||||||
|
gui.alert(fullmsg, function()
|
||||||
if world.is_open() then
|
if world.is_open() then
|
||||||
__vc_app.close_world()
|
__vc_app.close_world()
|
||||||
else
|
else
|
||||||
@ -429,7 +430,7 @@ function start_coroutine(chunk, name)
|
|||||||
menu.page = "main"
|
menu.page = "main"
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
return ...
|
return fullmsg
|
||||||
end)
|
end)
|
||||||
if not status then
|
if not status then
|
||||||
debug.error(error)
|
debug.error(error)
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "util/listutil.hpp"
|
#include "util/listutil.hpp"
|
||||||
|
|
||||||
@ -124,7 +125,9 @@ std::vector<std::string> PacksManager::assemble(
|
|||||||
std::queue<const ContentPack*> queue;
|
std::queue<const ContentPack*> queue;
|
||||||
std::queue<const ContentPack*> queue2;
|
std::queue<const ContentPack*> queue2;
|
||||||
|
|
||||||
for (auto& name : names) {
|
std::sort(allNames.begin(), allNames.end());
|
||||||
|
|
||||||
|
for (auto& name : allNames) {
|
||||||
auto found = packs.find(name);
|
auto found = packs.find(name);
|
||||||
if (found == packs.end()) {
|
if (found == packs.end()) {
|
||||||
throw contentpack_error(name, io::path(), "pack not found");
|
throw contentpack_error(name, io::path(), "pack not found");
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "api_lua.hpp"
|
#include "api_lua.hpp"
|
||||||
#include "assets/AssetsLoader.hpp"
|
#include "assets/AssetsLoader.hpp"
|
||||||
#include "coders/json.hpp"
|
#include "coders/json.hpp"
|
||||||
|
#include "content/Content.hpp"
|
||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
#include "world/files/WorldFiles.hpp"
|
#include "world/files/WorldFiles.hpp"
|
||||||
#include "io/engine_paths.hpp"
|
#include "io/engine_paths.hpp"
|
||||||
@ -181,7 +182,7 @@ static int l_set_chunk_data(lua::State* L) {
|
|||||||
return lua::pushboolean(L, false);
|
return lua::pushboolean(L, false);
|
||||||
}
|
}
|
||||||
compressed_chunks::decode(
|
compressed_chunks::decode(
|
||||||
*chunk, buffer.data(), buffer.size()
|
*chunk, buffer.data(), buffer.size(), *content->getIndices()
|
||||||
);
|
);
|
||||||
if (controller->getChunksController()->lighting == nullptr) {
|
if (controller->getChunksController()->lighting == nullptr) {
|
||||||
return lua::pushboolean(L, true);
|
return lua::pushboolean(L, true);
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "coders/gzip.hpp"
|
#include "coders/gzip.hpp"
|
||||||
|
|
||||||
#include "world/files/WorldFiles.hpp"
|
#include "world/files/WorldFiles.hpp"
|
||||||
|
#include "content/Content.hpp"
|
||||||
|
|
||||||
inline constexpr int HAS_VOXELS = 0x1;
|
inline constexpr int HAS_VOXELS = 0x1;
|
||||||
inline constexpr int HAS_METADATA = 0x2;
|
inline constexpr int HAS_METADATA = 0x2;
|
||||||
@ -48,7 +49,9 @@ static void read_voxel_data(ByteReader& reader, util::Buffer<ubyte>& dst) {
|
|||||||
extrle::decode16(rleData.data(), rleData.size(), dst.data());
|
extrle::decode16(rleData.data(), rleData.size(), dst.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void compressed_chunks::decode(Chunk& chunk, const ubyte* src, size_t size) {
|
void compressed_chunks::decode(
|
||||||
|
Chunk& chunk, const ubyte* src, size_t size, const ContentIndices& indices
|
||||||
|
) {
|
||||||
ByteReader reader(src, size);
|
ByteReader reader(src, size);
|
||||||
|
|
||||||
ubyte flags = reader.get();
|
ubyte flags = reader.get();
|
||||||
@ -58,6 +61,18 @@ void compressed_chunks::decode(Chunk& chunk, const ubyte* src, size_t size) {
|
|||||||
/// world.get_chunk_data is only available in the main Lua state
|
/// world.get_chunk_data is only available in the main Lua state
|
||||||
static util::Buffer<ubyte> voxelData (CHUNK_DATA_LEN);
|
static util::Buffer<ubyte> voxelData (CHUNK_DATA_LEN);
|
||||||
read_voxel_data(reader, voxelData);
|
read_voxel_data(reader, voxelData);
|
||||||
|
// TODO: move somewhere in Chunk
|
||||||
|
auto src = reinterpret_cast<const uint16_t*>(voxelData.data());
|
||||||
|
for (size_t i = 0; i < CHUNK_VOL; i++) {
|
||||||
|
blockid_t id = dataio::le2h(src[i]);;
|
||||||
|
if (indices.blocks.get(id) == nullptr) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"block data corruption (chunk: " + std::to_string(chunk.x) +
|
||||||
|
", " + std::to_string(chunk.z) + ") at " +
|
||||||
|
std::to_string(i) + " id: " + std::to_string(id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
chunk.decode(voxelData.data());
|
chunk.decode(voxelData.data());
|
||||||
chunk.updateHeights();
|
chunk.updateHeights();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class ContentIndices;
|
||||||
class WorldRegions;
|
class WorldRegions;
|
||||||
|
|
||||||
namespace compressed_chunks {
|
namespace compressed_chunks {
|
||||||
@ -15,6 +16,11 @@ namespace compressed_chunks {
|
|||||||
util::Buffer<ubyte>& rleBuffer
|
util::Buffer<ubyte>& rleBuffer
|
||||||
);
|
);
|
||||||
std::vector<ubyte> encode(const Chunk& chunk);
|
std::vector<ubyte> encode(const Chunk& chunk);
|
||||||
void decode(Chunk& chunk, const ubyte* src, size_t size);
|
void decode(
|
||||||
|
Chunk& chunk,
|
||||||
|
const ubyte* src,
|
||||||
|
size_t size,
|
||||||
|
const ContentIndices& indices
|
||||||
|
);
|
||||||
void save(int x, int z, std::vector<ubyte> bytes, WorldRegions& regions);
|
void save(int x, int z, std::vector<ubyte> bytes, WorldRegions& regions);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user