diff --git a/src/lighting/Lightmap.hpp b/src/lighting/Lightmap.hpp index 21b5bce5..d31ace74 100644 --- a/src/lighting/Lightmap.hpp +++ b/src/lighting/Lightmap.hpp @@ -4,6 +4,7 @@ #include "typedefs.hpp" #include +#include inline constexpr int LIGHTMAP_DATA_LEN = CHUNK_VOL/2; @@ -17,6 +18,10 @@ public: void set(const light_t* map); + void clear() { + std::memset(map, 0, sizeof(map)); + } + inline unsigned short get(int x, int y, int z) const { return (map[y*CHUNK_D*CHUNK_W+z*CHUNK_W+x]); } diff --git a/src/logic/scripting/lua/libs/libworld.cpp b/src/logic/scripting/lua/libs/libworld.cpp index 362d08c7..01d1efee 100644 --- a/src/logic/scripting/lua/libs/libworld.cpp +++ b/src/logic/scripting/lua/libs/libworld.cpp @@ -148,12 +148,12 @@ static void integrate_chunk_client(Chunk& chunk) { int x = chunk.x; int z = chunk.z; auto chunksController = controller->getChunksController(); + Lighting& lighting = *chunksController->lighting; chunk.flags.loadedLights = false; chunk.flags.lighted = false; - + chunk.lightmap.clear(); Lighting::prebuildSkyLight(chunk, *indices); - lighting.onChunkLoaded(x, z, true); for (int lz = -1; lz <= 1; lz++) { for (int lx = -1; lx <= 1; lx++) { @@ -162,7 +162,6 @@ static void integrate_chunk_client(Chunk& chunk) { } if (auto other = level->chunks->getChunk(x + lx, z + lz)) { other->flags.modified = true; - lighting.onChunkLoaded(x - 1, z, true); } } }