MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / init

Method init

source/game/StarWorldServer.cpp:1363–1469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363void WorldServer::init(bool firstTime) {
1364 auto& root = Root::singleton();
1365 auto assets = root.assets();
1366 auto liquidsDatabase = root.liquidsDatabase();
1367
1368 m_serverConfig = assets->json("/worldserver.config");
1369 setFidelity(WorldServerFidelity::Medium);
1370
1371 m_worldStorage->setFloatingDungeonWorld(isFloatingDungeonWorld());
1372
1373 m_currentTime = 0;
1374 m_currentStep = 0;
1375 m_generatingDungeon = false;
1376 m_geometry = WorldGeometry(m_worldTemplate->size());
1377 m_entityMap = m_worldStorage->entityMap();
1378 m_tileArray = m_worldStorage->tileArray();
1379 m_tileGetterFunction = [&](Vec2I pos) -> ServerTile const& { return m_tileArray->tile(pos); };
1380 m_damageManager = make_shared<DamageManager>(this, ServerConnectionId);
1381 m_wireProcessor = make_shared<WireProcessor>(m_worldStorage);
1382 m_luaRoot = make_shared<LuaRoot>();
1383 m_luaRoot->luaEngine().setNullTerminated(false);
1384 m_luaRoot->tuneAutoGarbageCollection(m_serverConfig.getFloat("luaGcPause"), m_serverConfig.getFloat("luaGcStepMultiplier"));
1385
1386 m_sky = make_shared<Sky>(m_worldTemplate->skyParameters(), false);
1387
1388 m_lightIntensityCalculator.setParameters(assets->json("/lighting.config:intensity"));
1389
1390 m_entityMessageResponses = {};
1391
1392 m_collisionGenerator.init([=](int x, int y) {
1393 return m_tileArray->tile({x, y}).getCollision();
1394 });
1395
1396 m_entityUpdateTimer = GameTimer(m_serverConfig.query("interpolationSettings.normal").getFloat("entityUpdateDelta") / 60.f);
1397 m_tileEntityBreakCheckTimer = GameTimer(m_serverConfig.getFloat("tileEntityBreakCheckInterval"));
1398
1399 m_liquidEngine = make_shared<LiquidCellEngine<LiquidId>>(liquidsDatabase->liquidEngineParameters(), make_shared<LiquidWorld>(this));
1400 for (auto liquidSettings : liquidsDatabase->allLiquidSettings())
1401 m_liquidEngine->setLiquidTickDelta(liquidSettings->id, liquidSettings->tickDelta);
1402
1403 m_fallingBlocksAgent = make_shared<FallingBlocksAgent>(make_shared<FallingBlocksWorld>(this));
1404
1405 setupForceRegions();
1406
1407 setTileProtection(ProtectedZeroGDungeonId, true);
1408
1409 try {
1410 m_spawner.init(make_shared<SpawnerWorld>(this));
1411
1412 RandomSource rnd = RandomSource(m_worldTemplate->worldSeed());
1413
1414 if (firstTime) {
1415 m_generatingDungeon = true;
1416 DungeonId currentDungeonId = 0;
1417
1418 for (auto const& dungeon : m_worldTemplate->dungeons()) {
1419 Logger::info("Placing dungeon {}", dungeon.dungeon);
1420 int retryCounter = m_serverConfig.getInt("spawnDungeonRetries");

Callers 3

initLuaMethod · 0.45
handleIncomingPacketsMethod · 0.45
addEntityMethod · 0.45

Calls 15

singletonClass · 0.85
WorldGeometryClass · 0.85
GameTimerClass · 0.85
RandomSourceClass · 0.85
isRealMaterialFunction · 0.85
assetsMethod · 0.80
liquidsDatabaseMethod · 0.80
jsonMethod · 0.80
setNullTerminatedMethod · 0.80
getFloatMethod · 0.80

Tested by

no test coverage detected