synvael/crates/server/src/main.rs

57 lines
1.7 KiB
Rust

// SPDX-License-Identifier: AGPL-3.0-only
//! Dedicated server for Synvael.
//!
//! The server handles the authoritative game simulation, including world
//! management, physics, and combat.
/// Authoritative chunk storage and generation logic for the server.
pub mod world_server;
use std::fs;
use shared::{
generator::{VoxelGenerator, WorldGenConfig},
world::ChunkPos,
};
use tracing::{debug, info};
fn main() {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("debug")),
)
.init();
info!("Starting Synvael server");
#[allow(clippy::expect_used)]
let config_str = fs::read_to_string("assets/data/worldgen/default.json")
.expect("Failed to read worldgen config");
#[allow(clippy::expect_used)]
let worldgen_config: WorldGenConfig =
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
info!("Successfully loaded world configuration");
debug!("Base height: {}", worldgen_config.base_height);
debug!("Noise scale: {}", worldgen_config.noise_scale);
debug!("Surface block: {}", worldgen_config.surface_block.0);
debug!("Subsurface block: {}", worldgen_config.subsurface_block.0);
debug!("Stone block: {}", worldgen_config.stone_block.0);
let seed = 4_813_530;
let generator = VoxelGenerator::new(worldgen_config, seed);
let mut world = world_server::ServerWorld::new(generator);
let spawn_chunk = world.get_chunk(ChunkPos::new(0, 0, 0));
tracing::info!(
"Spawn chunk generated. Block at (0,0,0) is {}",
spawn_chunk.get(0, 0, 0).0
);
}