| 377 | |
| 378 | |
| 379 | void cWorld::InitializeSpawn(void) |
| 380 | { |
| 381 | if (!m_IsSpawnExplicitlySet) // Check if spawn position was already explicitly set or not |
| 382 | { |
| 383 | GenerateRandomSpawn(); // Generate random solid-land coordinate and then write it to the world configuration |
| 384 | |
| 385 | cIniFile IniFile; |
| 386 | IniFile.ReadFile(m_IniFileName); |
| 387 | |
| 388 | IniFile.SetValueF("SpawnPosition", "X", m_SpawnX); |
| 389 | IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY); |
| 390 | IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ); |
| 391 | |
| 392 | IniFile.WriteFile(m_IniFileName); |
| 393 | } |
| 394 | |
| 395 | int ChunkX = 0, ChunkY = 0, ChunkZ = 0; |
| 396 | BlockToChunk((int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ); |
| 397 | |
| 398 | // For the debugging builds, don't make the server build too much world upon start: |
| 399 | #if defined(_DEBUG) || defined(ANDROID_NDK) |
| 400 | int ViewDist = 9; |
| 401 | #else |
| 402 | int ViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is |
| 403 | #endif // _DEBUG |
| 404 | |
| 405 | LOG("Preparing spawn area in world \"%s\"...", m_WorldName.c_str()); |
| 406 | for (int x = 0; x < ViewDist; x++) |
| 407 | { |
| 408 | for (int z = 0; z < ViewDist; z++) |
| 409 | { |
| 410 | m_ChunkMap->TouchChunk(x + ChunkX-(ViewDist - 1) / 2, ZERO_CHUNK_Y, z + ChunkZ-(ViewDist - 1) / 2); // Queue the chunk in the generator / loader |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | { |
| 415 | // Display progress during this process: |
| 416 | cWorldLoadProgress Progress(this); |
| 417 | |
| 418 | // Wait for the loader to finish loading |
| 419 | m_Storage.WaitForLoadQueueEmpty(); |
| 420 | |
| 421 | // Wait for the generator to finish generating |
| 422 | m_Generator.WaitForQueueEmpty(); |
| 423 | |
| 424 | // Wait for the loader to finish saving |
| 425 | m_Storage.WaitForSaveQueueEmpty(); |
| 426 | |
| 427 | Progress.Stop(); |
| 428 | } |
| 429 | |
| 430 | // Light all chunks that have been newly generated: |
| 431 | LOG("Lighting spawn area in world \"%s\"...", m_WorldName.c_str()); |
| 432 | |
| 433 | for (int x = 0; x < ViewDist; x++) |
| 434 | { |
| 435 | int ChX = x + ChunkX-(ViewDist - 1) / 2; |
| 436 | for (int z = 0; z < ViewDist; z++) |
no test coverage detected