mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
a8b0039898
Former-commit-id: b81d6e38a74f846d64c092d1422dc402f369100c
40 lines
1.0 KiB
Rust
40 lines
1.0 KiB
Rust
use std::time::Duration;
|
|
use log::info;
|
|
use server::{Input, Event, Server};
|
|
use common::clock::Clock;
|
|
|
|
const TPS: u64 = 20;
|
|
|
|
fn main() {
|
|
// Init logging
|
|
pretty_env_logger::init();
|
|
|
|
info!("Starting server-cli...");
|
|
|
|
// Set up an fps clock
|
|
let mut clock = Clock::new();
|
|
|
|
// Create server
|
|
let mut server = Server::new()
|
|
.expect("Failed to create server instance");
|
|
|
|
loop {
|
|
let events = server.tick(Input::default(), clock.get_last_delta())
|
|
.expect("Failed to tick server");
|
|
|
|
for event in events {
|
|
match event {
|
|
Event::ClientConnected { uid } => info!("Client {} connected!", uid),
|
|
Event::ClientDisconnected { uid } => info!("Client {} disconnected!", uid),
|
|
Event::Chat { uid, msg } => info!("[Client {}] {}", uid, msg),
|
|
}
|
|
}
|
|
|
|
// Clean up the server after a tick
|
|
server.cleanup();
|
|
|
|
// Wait for the next tick
|
|
clock.tick(Duration::from_millis(1000 / TPS));
|
|
}
|
|
}
|