replace Bytearray with FFI implementation
This commit is contained in:
@@ -144,7 +144,7 @@ static int l_get_chunk_data(lua::State* L) {
|
||||
} else {
|
||||
chunkData = compressed_chunks::encode(*chunk);
|
||||
}
|
||||
return lua::newuserdata<lua::LuaBytearray>(L, std::move(chunkData));
|
||||
return lua::create_bytearray(L, std::move(chunkData));
|
||||
}
|
||||
|
||||
static void integrate_chunk_client(Chunk& chunk) {
|
||||
@@ -175,14 +175,17 @@ static int l_set_chunk_data(lua::State* L) {
|
||||
|
||||
int x = static_cast<int>(lua::tointeger(L, 1));
|
||||
int z = static_cast<int>(lua::tointeger(L, 2));
|
||||
auto buffer = lua::require_bytearray(L, 3);
|
||||
auto buffer = lua::bytearray_as_string(L, 3);
|
||||
|
||||
auto chunk = level->chunks->getChunk(x, z);
|
||||
if (chunk == nullptr) {
|
||||
return lua::pushboolean(L, false);
|
||||
}
|
||||
compressed_chunks::decode(
|
||||
*chunk, buffer.data(), buffer.size(), *content->getIndices()
|
||||
*chunk,
|
||||
reinterpret_cast<const ubyte*>(buffer.data()),
|
||||
buffer.size(),
|
||||
*content->getIndices()
|
||||
);
|
||||
if (controller->getChunksController()->lighting == nullptr) {
|
||||
return lua::pushboolean(L, true);
|
||||
@@ -198,10 +201,16 @@ static int l_save_chunk_data(lua::State* L) {
|
||||
|
||||
int x = static_cast<int>(lua::tointeger(L, 1));
|
||||
int z = static_cast<int>(lua::tointeger(L, 2));
|
||||
auto buffer = lua::require_bytearray(L, 3);
|
||||
auto buffer = lua::bytearray_as_string(L, 3);
|
||||
|
||||
compressed_chunks::save(
|
||||
x, z, std::move(buffer), level->getWorld()->wfile->getRegions()
|
||||
x,
|
||||
z,
|
||||
std::vector(
|
||||
reinterpret_cast<const ubyte*>(buffer.data()),
|
||||
reinterpret_cast<const ubyte*>(buffer.data()) + buffer.size()
|
||||
),
|
||||
level->getWorld()->wfile->getRegions()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user