mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 05:51:51 +00:00
Minor refactor
This commit is contained in:
parent
3101b1b5f8
commit
eaf3f4e7a1
1 changed files with 15 additions and 14 deletions
|
|
@ -39,19 +39,7 @@ void ChunksStorage::remove(int x, int z) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
void verifyLoadedChunk(ContentIndices* indices, Chunk* chunk) {
|
||||||
World* world = level->world;
|
|
||||||
|
|
||||||
auto chunk = std::shared_ptr<Chunk>(new Chunk(x, z));
|
|
||||||
store(chunk);
|
|
||||||
std::unique_ptr<ubyte> data(world->wfile->getChunk(chunk->x, chunk->z));
|
|
||||||
if (data) {
|
|
||||||
chunk->decode(data.get());
|
|
||||||
chunk->setLoaded(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifying and converting data
|
|
||||||
ContentIndices* indices = level->content->indices;
|
|
||||||
for (size_t i = 0; i < CHUNK_VOL; i++) {
|
for (size_t i = 0; i < CHUNK_VOL; i++) {
|
||||||
blockid_t id = chunk->voxels[i].id;
|
blockid_t id = chunk->voxels[i].id;
|
||||||
if (indices->getBlockDef(id) == nullptr) {
|
if (indices->getBlockDef(id) == nullptr) {
|
||||||
|
|
@ -61,6 +49,19 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||||
chunk->voxels[i].id = 11;
|
chunk->voxels[i].id = 11;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||||
|
World* world = level->world;
|
||||||
|
|
||||||
|
auto chunk = std::make_shared<Chunk>(x, z);
|
||||||
|
store(chunk);
|
||||||
|
std::unique_ptr<ubyte[]> data(world->wfile->getChunk(chunk->x, chunk->z));
|
||||||
|
if (data) {
|
||||||
|
chunk->decode(data.get());
|
||||||
|
chunk->setLoaded(true);
|
||||||
|
verifyLoadedChunk(level->content->indices, chunk.get());
|
||||||
|
}
|
||||||
|
|
||||||
light_t* lights = world->wfile->getLights(chunk->x, chunk->z);
|
light_t* lights = world->wfile->getLights(chunk->x, chunk->z);
|
||||||
if (lights) {
|
if (lights) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue