FEAT: World size

This commit is contained in:
2026-05-09 01:45:19 +02:00
parent 43f0d1f75f
commit 1d0264a9c5

View File

@@ -12,6 +12,7 @@
#include "server/ArgumentsSettings.h" #include "server/ArgumentsSettings.h"
#include "platform/time.h" #include "platform/time.h"
#include "SharedConstants.h" #include "SharedConstants.h"
#include "world/level/LevelConstants.h"
#define MAIN_CLASS NinecraftApp #define MAIN_CLASS NinecraftApp
static App* g_app = 0; static App* g_app = 0;
@@ -43,7 +44,6 @@ std::string findStringInConfig(std::string line, std::string config) {
valuePos += 1 + line.size(); valuePos += 1 + line.size();
while (true) { while (true) {
auto sym = config.at(valuePos); auto sym = config.at(valuePos);
@@ -92,6 +92,7 @@ int main(int numArguments, char* pszArgs[]) {
int port = 0; int port = 0;
int gamemode = 0; int gamemode = 0;
int worldSize = 0;
std::string levelDir = ""; std::string levelDir = "";
std::string cachePath = ""; std::string cachePath = "";
@@ -112,6 +113,16 @@ int main(int numArguments, char* pszArgs[]) {
} }
port = std::stoi(findStringInConfig("port", propString)); port = std::stoi(findStringInConfig("port", propString));
worldSize = std::stoi(findStringInConfig("world-size", propString));
if (worldSize < 16 || worldSize > 32) {
throw std::runtime_error("Incorrect world size.");
}
LevelConstants::CHUNK_CACHE_WIDTH = worldSize;
LevelConstants::LEVEL_WIDTH = LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_WIDTH;
LevelConstants::LEVEL_DEPTH = LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_DEPTH;
cachePath = findStringInConfig("level-cachepath", propString); cachePath = findStringInConfig("level-cachepath", propString);
externalPath = findStringInConfig("level-externalpath", propString); externalPath = findStringInConfig("level-externalpath", propString);
levelName = findStringInConfig("level-name", propString); levelName = findStringInConfig("level-name", propString);