mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
regions related code moved from WorldFiles to WorldRegions
This commit is contained in:
parent
d2a2f0e8ae
commit
3ebd8f3062
8 changed files with 641 additions and 576 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue