Merge pull request #442 from MihailRis/suspend-players

Suspend players
This commit is contained in:
MihailRis 2025-01-18 04:53:17 +03:00 committed by GitHub
commit 88ed15c6d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -160,13 +160,13 @@ static void integrate_chunk_client(Chunk& chunk) {
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::touserdata<lua::LuaBytearray>(L, 3);
auto buffer = lua::require_bytearray(L, 3);
auto chunk = level->chunks->getChunk(x, z);
if (chunk == nullptr) {
return 0;
return lua::pushboolean(L, false);
}
compressed_chunks::decode(
*chunk, buffer->data().data(), buffer->data().size()
*chunk, buffer.data(), buffer.size()
);
if (controller->getChunksController()->lighting == nullptr) {
return lua::pushboolean(L, true);

View File

@ -133,6 +133,13 @@ dv::value lua::tovalue(State* L, int idx) {
return map;
}
}
case LUA_TUSERDATA: {
if (auto bytes = touserdata<LuaBytearray>(L, idx)) {
const auto& data = bytes->data();
return std::make_shared<dv::objects::Bytes>(data.data(), data.size());
}
[[fallthrough]];
}
default:
throw std::runtime_error(
"lua type " + std::string(lua_typename(L, type)) +