diff --git a/flake.nix b/flake.nix index bc9ead2b0..ee1e6baa9 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,7 @@ glew zlib libpng + freetype libvorbis openal luajit @@ -39,7 +40,7 @@ entt mesa freeglut - ]; # libglvnd + ]; packages = with pkgs; [ glfw diff --git a/res/models/block.vec3 b/res/models/block.vec3 index 0b274e755..a438a248a 100644 Binary files a/res/models/block.vec3 and b/res/models/block.vec3 differ diff --git a/src/logic/BlocksController.cpp b/src/logic/BlocksController.cpp index 8ab863927..1e3ad2441 100644 --- a/src/logic/BlocksController.cpp +++ b/src/logic/BlocksController.cpp @@ -186,7 +186,7 @@ void BlocksController::randomTick(int tickid, int parts, uint padding) { continue; } auto& chunk = chunks.getChunks()[index]; - if (chunk == nullptr || !chunk->flags.lighted) { + if (chunk == nullptr || !chunk->flags.ready) { continue; } if (chunk->lastRandomTickId == randomTickId) { diff --git a/src/logic/ChunksController.cpp b/src/logic/ChunksController.cpp index 0c65a8df7..7a460c066 100644 --- a/src/logic/ChunksController.cpp +++ b/src/logic/ChunksController.cpp @@ -33,7 +33,11 @@ ChunksController::ChunksController(Level& level) ChunksController::~ChunksController() = default; void ChunksController::update( - int64_t maxDuration, int loadDistance, uint padding, Player& player + int64_t maxDuration, + int loadDistance, + uint padding, + Player& player, + bool isLocalPlayer ) const { const auto& position = player.getPosition(); int centerX = floordiv(glm::floor(position.x)); @@ -50,7 +54,7 @@ void ChunksController::update( for (uint i = 0; i < MAX_WORK_PER_FRAME; i++) { timeutil::Timer timer; - if (loadVisible(player, padding)) { + if (loadVisible(player, padding, isLocalPlayer)) { int64_t mcs = timer.stop(); if (mcstotal + mcs < maxDuration * 1000) { mcstotal += mcs; @@ -77,7 +81,9 @@ bool ChunksController::isInLoadingZone( return distance < minDistance; } -bool ChunksController::loadVisible(const Player& player, uint padding) const { +bool ChunksController::loadVisible( + const Player& player, uint padding, bool isLocalPlayer +) const { auto& chunks = *player.chunks; int sizeX = chunks.getWidth(); int sizeY = chunks.getHeight(); @@ -113,7 +119,7 @@ bool ChunksController::loadVisible(const Player& player, uint padding) const { auto& chunk = chunks.getChunks()[index]; if (chunk != nullptr) { if (chunk->flags.loaded && !chunk->flags.lighted) { - if (buildLights(player, chunk)) { + if (isLocalPlayer && buildLights(player, chunk)) { return true; } } diff --git a/src/logic/ChunksController.hpp b/src/logic/ChunksController.hpp index e9f367da1..8eaaf7dca 100644 --- a/src/logic/ChunksController.hpp +++ b/src/logic/ChunksController.hpp @@ -18,7 +18,7 @@ private: std::unique_ptr generator; /// @brief Process one chunk: load it or calculate lights for it - bool loadVisible(const Player& player, uint padding) const; + bool loadVisible(const Player& player, uint padding, bool isLocalPlayer) const; bool buildLights(const Player& player, const std::shared_ptr& chunk) const; void createChunk(const Player& player, int x, int y) const; public: @@ -29,7 +29,11 @@ public: /// @param maxDuration milliseconds reserved for chunks loading void update( - int64_t maxDuration, int loadDistance, uint padding, Player& player + int64_t maxDuration, + int loadDistance, + uint padding, + Player& player, + bool isLocalPlayer ) const; bool isInLoadingZone(const Player& player, uint padding, int x, int z) const; diff --git a/src/logic/LevelController.cpp b/src/logic/LevelController.cpp index 02bd6c925..4849df308 100644 --- a/src/logic/LevelController.cpp +++ b/src/logic/LevelController.cpp @@ -29,7 +29,8 @@ LevelController::LevelController( settings(engine.getSettings()), level(std::move(levelPtr)), chunks(std::make_unique(*level)), - playerTickClock(20, 3) { + playerTickClock(20, 3), + clientPlayer(clientPlayer) { level->events->listen(LevelEventType::CHUNK_PRESENT, [](auto, Chunk* chunk) { scripting::on_chunk_present(*chunk, chunk->flags.loaded); @@ -61,7 +62,7 @@ LevelController::LevelController( player->chunks->configure( std::floor(position.x), std::floor(position.z), 1 ); - chunks->update(16, 1, 0, *player); + chunks->update(16, 1, 0, *player, player.get() == clientPlayer); if (player->chunks->get( std::floor(position.x), 0, std::floor(position.z) )) { @@ -91,7 +92,8 @@ void LevelController::update(float delta, bool pause) { settings.chunks.loadSpeed.get(), settings.chunks.loadDistance.get(), settings.chunks.padding.get(), - *player + *player, + player.get() == clientPlayer ); } if (!pause) { diff --git a/src/logic/LevelController.hpp b/src/logic/LevelController.hpp index a73745d14..5fbfde3c5 100644 --- a/src/logic/LevelController.hpp +++ b/src/logic/LevelController.hpp @@ -22,6 +22,8 @@ class LevelController { std::unique_ptr chunks; util::Clock playerTickClock; + + Player* clientPlayer; public: CallbacksSet<> preQuitCallbacks; diff --git a/src/logic/scripting/lua/lua_engine.cpp b/src/logic/scripting/lua/lua_engine.cpp index 2a9eb59cb..5edb24fd9 100644 --- a/src/logic/scripting/lua/lua_engine.cpp +++ b/src/logic/scripting/lua/lua_engine.cpp @@ -194,5 +194,10 @@ State* lua::create_state(const EnginePaths& paths, StateType stateType) { } pop(L); } + + if (stateType == StateType::GENERATOR) { + pushnil(L); + setglobal(L, "ffi"); + } return L; } diff --git a/src/world/files/WorldRegions.cpp b/src/world/files/WorldRegions.cpp index 14139ed37..d96ed46fb 100644 --- a/src/world/files/WorldRegions.cpp +++ b/src/world/files/WorldRegions.cpp @@ -157,7 +157,7 @@ void WorldRegions::put(Chunk* chunk, std::vector entitiesData) { return; } assert(chunk != nullptr); - if (!chunk->flags.lighted) { + if (!chunk->flags.ready) { return; } bool lightsUnsaved = !chunk->flags.loadedLights && doWriteLights;