mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
b13f9f37f7
This reverts merge request !547
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
#![deny(unsafe_code)]
|
|
|
|
use common::clock::Clock;
|
|
use heaptrack::track_mem;
|
|
use log::info;
|
|
use server::{Event, Input, Server, ServerSettings};
|
|
use std::time::Duration;
|
|
|
|
track_mem!();
|
|
|
|
const TPS: u64 = 30;
|
|
|
|
fn main() {
|
|
// Init logging
|
|
pretty_env_logger::init();
|
|
|
|
info!("Starting server-cli...");
|
|
|
|
// Set up an fps clock
|
|
let mut clock = Clock::start();
|
|
|
|
// Load settings
|
|
let settings = ServerSettings::load();
|
|
|
|
// Create server
|
|
let mut server = Server::new(settings).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 { entity: _ } => info!("Client connected!"),
|
|
Event::ClientDisconnected { entity: _ } => info!("Client disconnected!"),
|
|
Event::Chat { entity: _, msg } => info!("[Client] {}", msg),
|
|
}
|
|
}
|
|
|
|
// Clean up the server after a tick.
|
|
server.cleanup();
|
|
|
|
// Wait for the next tick.
|
|
clock.tick(Duration::from_millis(1000 / TPS));
|
|
}
|
|
}
|