diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 88dd54f4..a20f1c96 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -306,6 +306,8 @@ end stdcomp = require "core:internal/stdcomp" entities.get = stdcomp.get_Entity +math.randomseed(time.uptime()*1536227939) + -- Deprecated functions block_index = block.index block_name = block.name diff --git a/src/world/Level.cpp b/src/world/Level.cpp index 72cb5d44..781d244a 100644 --- a/src/world/Level.cpp +++ b/src/world/Level.cpp @@ -15,10 +15,10 @@ #include "../items/Inventories.hpp" Level::Level( - std::unique_ptr world, + std::unique_ptr worldPtr, const Content* content, EngineSettings& settings -) : world(std::move(world)), +) : world(std::move(worldPtr)), content(content), chunksStorage(std::make_unique(this)), physics(std::make_unique(glm::vec3(0, -22.6f, 0))), @@ -26,9 +26,11 @@ Level::Level( entities(std::make_unique(this)), settings(settings) { - entities->setNextID(this->world->nextEntityId); + if (world->nextEntityId) { + entities->setNextID(world->nextEntityId); + } auto inv = std::make_shared( - this->world->getNextInventoryId(), DEF_PLAYER_INVENTORY_SIZE + world->getNextInventoryId(), DEF_PLAYER_INVENTORY_SIZE ); auto player = spawnObject( this, glm::vec3(0, DEF_PLAYER_Y, 0), DEF_PLAYER_SPEED, inv, 0 @@ -39,7 +41,7 @@ Level::Level( settings.chunks.padding.get() ) * 2; chunks = std::make_unique( - matrixSize, matrixSize, 0, 0, this->world->wfile.get(), this + matrixSize, matrixSize, 0, 0, world->wfile.get(), this ); lighting = std::make_unique(content, chunks.get());