Sky lights data saving (optimization)
This commit is contained in:
@@ -10,6 +10,7 @@ struct ChunkFlag{
|
||||
static const int LOADED = 0x4;
|
||||
static const int LIGHTED = 0x8;
|
||||
static const int UNSAVED = 0x10;
|
||||
static const int LOADED_LIGHTS = 0x20;
|
||||
};
|
||||
#define CHUNK_DATA_LEN (CHUNK_VOL*2)
|
||||
|
||||
@@ -57,6 +58,8 @@ public:
|
||||
|
||||
inline bool isLoaded() const {return flags & ChunkFlag::LOADED;}
|
||||
|
||||
inline bool isLoadedLights() const {return flags & ChunkFlag::LOADED_LIGHTS;}
|
||||
|
||||
inline bool isReady() const {return flags & ChunkFlag::READY;}
|
||||
|
||||
inline void setUnsaved(bool newState) {SETFLAGS(ChunkFlag::UNSAVED, newState);}
|
||||
@@ -65,6 +68,8 @@ public:
|
||||
|
||||
inline void setLoaded(bool newState) {SETFLAGS(ChunkFlag::LOADED, newState);}
|
||||
|
||||
inline void setLoadedLights(bool newState) {SETFLAGS(ChunkFlag::LOADED_LIGHTS, newState);}
|
||||
|
||||
inline void setLighted(bool newState) {SETFLAGS(ChunkFlag::LIGHTED, newState);}
|
||||
|
||||
inline void setReady(bool newState) {SETFLAGS(ChunkFlag::READY, newState);}
|
||||
|
||||
@@ -50,6 +50,12 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||
chunk->decode(data.get());
|
||||
chunk->setLoaded(true);
|
||||
}
|
||||
|
||||
light_t* lights = level->world->wfile->getLights(chunk->x, chunk->z);
|
||||
if (lights) {
|
||||
chunk->lightmap->set(lights);
|
||||
chunk->setLoadedLights(true);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user