diff --git a/common/source/world/ChunkLightmap.cpp b/common/source/world/ChunkLightmap.cpp index 4b8b414b..a02502a0 100644 --- a/common/source/world/ChunkLightmap.cpp +++ b/common/source/world/ChunkLightmap.cpp @@ -90,7 +90,8 @@ void ChunkLightmap::updateTorchlight() { if (getTorchlight(surroundingNode.x, surroundingNode.y, surroundingNode.z) + 2 <= lightLevel) { setTorchlight(surroundingNode.x, surroundingNode.y, surroundingNode.z, lightLevel - 1); - if (!Registry::getInstance().getBlock(m_chunk->getBlock(surroundingNode.x, surroundingNode.y, surroundingNode.z)).isOpaque()) { + u16 block = m_chunk->getBlock(surroundingNode.x, surroundingNode.y, surroundingNode.z); + if (!block || !Registry::getInstance().getBlock(block).isOpaque()) { m_lightBfsQueue.emplace(surroundingNode.x, surroundingNode.y, surroundingNode.z); } } diff --git a/server/include/core/ServerApplication.hpp b/server/include/core/ServerApplication.hpp index a611114d..c6b90210 100644 --- a/server/include/core/ServerApplication.hpp +++ b/server/include/core/ServerApplication.hpp @@ -33,6 +33,8 @@ class ServerApplication : public gk::CoreApplication { ServerWorld m_world; Registry m_registry; + + int m_port = 4242; }; #endif // SERVERAPPLICATION_HPP_ diff --git a/server/source/core/ServerApplication.cpp b/server/source/core/ServerApplication.cpp index 0cb58e1b..67bb09fe 100644 --- a/server/source/core/ServerApplication.cpp +++ b/server/source/core/ServerApplication.cpp @@ -13,7 +13,13 @@ */ #include "ServerApplication.hpp" +using namespace std::literals::string_literals; + ServerApplication::ServerApplication(int argc, char **argv) : gk::CoreApplication(argc, argv) { + if (argc == 3 && argv[1] == "--port"s) { + m_port = std::stoi(argv[2]); + } + m_loadSDL = false; } @@ -22,7 +28,7 @@ void ServerApplication::init() { Registry::setInstance(m_registry); - m_server.init(4242); + m_server.init(m_port); m_server.setRunning(true); m_server.setGameStarted(false);