regions related code moved from WorldFiles to WorldRegions
This commit is contained in:
@@ -410,6 +410,7 @@ void Chunks::setCenter(int32_t x, int32_t z) {
|
||||
}
|
||||
|
||||
void Chunks::translate(int32_t dx, int32_t dz) {
|
||||
auto& regions = worldFiles->getRegions();
|
||||
for (uint i = 0; i < volume; i++){
|
||||
chunksSecond[i] = nullptr;
|
||||
}
|
||||
@@ -422,8 +423,9 @@ void Chunks::translate(int32_t dx, int32_t dz) {
|
||||
continue;
|
||||
if (nx < 0 || nz < 0 || nx >= int(w) || nz >= int(d)){
|
||||
events->trigger(EVT_CHUNK_HIDDEN, chunk.get());
|
||||
if (worldFiles)
|
||||
worldFiles->put(chunk.get());
|
||||
if (worldFiles) {
|
||||
regions.put(chunk.get());
|
||||
}
|
||||
chunksCount--;
|
||||
continue;
|
||||
}
|
||||
@@ -482,10 +484,11 @@ bool Chunks::putChunk(std::shared_ptr<Chunk> chunk) {
|
||||
}
|
||||
|
||||
void Chunks::saveAndClear(){
|
||||
auto& regions = worldFiles->getRegions();
|
||||
for (size_t i = 0; i < volume; i++){
|
||||
Chunk* chunk = chunks[i].get();
|
||||
if (chunk) {
|
||||
worldFiles->put(chunk);
|
||||
regions.put(chunk);
|
||||
events->trigger(EVT_CHUNK_HIDDEN, chunk);
|
||||
}
|
||||
chunks[i] = nullptr;
|
||||
|
||||
@@ -51,14 +51,14 @@ static void verifyLoadedChunk(ContentIndices* indices, Chunk* chunk) {
|
||||
|
||||
std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||
World* world = level->getWorld();
|
||||
WorldFiles* wfile = world->wfile.get();
|
||||
auto& regions = world->wfile.get()->getRegions();
|
||||
|
||||
auto chunk = std::make_shared<Chunk>(x, z);
|
||||
store(chunk);
|
||||
auto data = wfile->getChunk(chunk->x, chunk->z);
|
||||
auto data = regions.getChunk(chunk->x, chunk->z);
|
||||
if (data) {
|
||||
chunk->decode(data.get());
|
||||
auto invs = wfile->fetchInventories(chunk->x, chunk->z);
|
||||
auto invs = regions.fetchInventories(chunk->x, chunk->z);
|
||||
chunk->setBlockInventories(std::move(invs));
|
||||
chunk->setLoaded(true);
|
||||
for(auto& entry : chunk->inventories) {
|
||||
@@ -67,7 +67,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||
verifyLoadedChunk(level->content->getIndices(), chunk.get());
|
||||
}
|
||||
|
||||
auto lights = wfile->getLights(chunk->x, chunk->z);
|
||||
auto lights = regions.getLights(chunk->x, chunk->z);
|
||||
if (lights) {
|
||||
chunk->lightmap.set(lights.get());
|
||||
chunk->setLoadedLights(true);
|
||||
|
||||
Reference in New Issue
Block a user