World indices check

This commit is contained in:
MihailRis
2023-12-07 15:16:37 +03:00
parent 551b230b94
commit 636cb0c44c
12 changed files with 197 additions and 40 deletions
+13
View File
@@ -1,6 +1,7 @@
#include "ChunksStorage.h"
#include <assert.h>
#include <iostream>
#include "VoxelsVolume.h"
#include "Chunk.h"
@@ -53,6 +54,18 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
chunk->setLoaded(true);
}
// Verifying and converting data
ContentIndices* indices = level->content->indices;
for (size_t i = 0; i < CHUNK_VOL; i++) {
blockid_t id = chunk->voxels[i].id;
if (indices->getBlockDef(id) == nullptr) {
std::cout << "corruped block detected at " << i << " of chunk ";
std::cout << chunk->x << "x" << chunk->z;
std::cout << " -> " << (int)id << std::endl;
chunk->voxels[i].id = 11;
}
}
light_t* lights = world->wfile->getLights(chunk->x, chunk->z);
if (lights) {
chunk->lightmap->set(lights);