delete blocksdata region file if there is no associated voxels region
This commit is contained in:
parent
c7ca7e58b3
commit
9e8a33c411
@ -285,7 +285,8 @@ void WorldRegions::processBlocksData(int x, int z, const BlockDataProc& func) {
|
||||
if (voxRegfile == nullptr) {
|
||||
logger.warning() << "missing voxels region - discard blocks data for "
|
||||
<< x << "_" << z;
|
||||
abort(); // TODO: delete region file
|
||||
deleteRegion(REGION_LAYER_BLOCKS_DATA, x, z);
|
||||
return;
|
||||
}
|
||||
for (uint cz = 0; cz < REGION_SIZE; cz++) {
|
||||
for (uint cx = 0; cx < REGION_SIZE; cx++) {
|
||||
@ -398,6 +399,18 @@ void WorldRegions::writeAll() {
|
||||
}
|
||||
}
|
||||
|
||||
void WorldRegions::deleteRegion(RegionLayerIndex layerid, int x, int z) {
|
||||
auto& layer = layers[layerid];
|
||||
if (layer.getRegFile({x, z}, false)) {
|
||||
throw std::runtime_error("region file is currently in use");
|
||||
}
|
||||
auto file = layer.getRegionFilePath(x, z);
|
||||
if (fs::exists(file)) {
|
||||
logger.info() << "remove region file " << file.u8string();
|
||||
fs::remove(file);
|
||||
}
|
||||
}
|
||||
|
||||
bool WorldRegions::parseRegionFilename(
|
||||
const std::string& name, int& x, int& z
|
||||
) {
|
||||
|
||||
@ -248,6 +248,8 @@ public:
|
||||
/// @brief Write all region layers
|
||||
void writeAll();
|
||||
|
||||
void deleteRegion(RegionLayerIndex layerid, int x, int z);
|
||||
|
||||
/// @brief Extract X and Z from 'X_Z.bin' region file name.
|
||||
/// @param name source region file name
|
||||
/// @param x parsed X destination
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user