update blocks data lifetime

This commit is contained in:
MihailRis 2024-09-30 21:33:19 +03:00
parent 4f559c1086
commit e84c79839c
2 changed files with 2 additions and 5 deletions

View File

@ -491,7 +491,7 @@ static int l_get_field(lua::State* L) {
}
const ubyte* src = chunk->blocksMetadata.find(voxelIndex);
if (src == nullptr) {
throw std::runtime_error("block data is not allocated");
return 0;
}
return get_field(L, src, *field, index, dataStruct);
}
@ -555,7 +555,7 @@ static int l_set_field(lua::State* L) {
}
ubyte* dst = chunk->blocksMetadata.find(voxelIndex);
if (dst == nullptr) {
throw std::runtime_error("block data is not allocated");
dst = chunk->blocksMetadata.allocate(voxelIndex, dataStruct.size());
}
return set_field(L, dst, *field, index, dataStruct, value);
}

View File

@ -394,9 +394,6 @@ void Chunks::set(
if (!state.segment && newdef.rt.extended) {
repairSegments(newdef, state, gx, y, gz);
}
if (newdef.dataStruct) {
chunk->blocksMetadata.allocate(index, newdef.dataStruct->size());
}
if (y < chunk->bottom)
chunk->bottom = y;