add chunk 'entities' flag
This commit is contained in:
parent
c8666910ce
commit
f4d3e62b3f
@ -360,7 +360,7 @@ void WorldRegions::put(Chunk* chunk, std::vector<ubyte> entitiesData){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool lightsUnsaved = !chunk->flags.loadedLights && doWriteLights;
|
bool lightsUnsaved = !chunk->flags.loadedLights && doWriteLights;
|
||||||
if (!chunk->flags.unsaved && !lightsUnsaved) {
|
if (!chunk->flags.unsaved && !lightsUnsaved && !chunk->flags.entities) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +441,11 @@ chunk_inventories_map WorldRegions::fetchInventories(int x, int z) {
|
|||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return json::from_binary(data, bytesSize);
|
auto map = json::from_binary(data, bytesSize);
|
||||||
|
if (map->size() == 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldRegions::processRegionVoxels(int x, int z, const regionproc& func) {
|
void WorldRegions::processRegionVoxels(int x, int z, const regionproc& func) {
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public:
|
|||||||
bool lighted: 1;
|
bool lighted: 1;
|
||||||
bool unsaved: 1;
|
bool unsaved: 1;
|
||||||
bool loadedLights: 1;
|
bool loadedLights: 1;
|
||||||
|
bool entities: 1;
|
||||||
} flags {};
|
} flags {};
|
||||||
|
|
||||||
/// @brief Block inventories map where key is index of block in voxels array
|
/// @brief Block inventories map where key is index of block in voxels array
|
||||||
|
|||||||
@ -717,7 +717,7 @@ void Chunks::save(Chunk* chunk) {
|
|||||||
list.put(level->entities->serialize(entity));
|
list.put(level->entities->serialize(entity));
|
||||||
}
|
}
|
||||||
if (!entities.empty()) {
|
if (!entities.empty()) {
|
||||||
chunk->flags.unsaved = true;
|
chunk->flags.entities = true;
|
||||||
}
|
}
|
||||||
worldFiles->getRegions().put(chunk, json::to_binary(root, true));
|
worldFiles->getRegions().put(chunk, json::to_binary(root, true));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
|||||||
|
|
||||||
if (auto map = regions.fetchEntities(chunk->x, chunk->z)) {
|
if (auto map = regions.fetchEntities(chunk->x, chunk->z)) {
|
||||||
level->entities->loadEntities(std::move(map));
|
level->entities->loadEntities(std::move(map));
|
||||||
|
chunk->flags.entities = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk->flags.loaded = true;
|
chunk->flags.loaded = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user