kubi/kubi-server/src/main.rs

48 lines
958 B
Rust
Raw Normal View History

2023-02-11 23:37:24 +00:00
use shipyard::{World, Workload, IntoWorkload};
use std::{thread, time::Duration};
2023-02-10 21:11:18 +00:00
2023-03-09 02:30:37 +00:00
mod config;
mod server;
mod client;
mod world;
mod auth;
2023-02-10 19:26:03 +00:00
2023-02-11 23:37:24 +00:00
use config::read_config;
2023-03-08 19:26:51 +00:00
use server::{bind_server, update_server, log_server_errors};
2023-03-09 02:30:37 +00:00
use client::init_client_maps;
2023-02-14 03:27:27 +00:00
use auth::authenticate_players;
2023-03-09 02:30:37 +00:00
use world::{update_world, init_world};
2023-02-10 19:36:58 +00:00
fn initialize() -> Workload {
(
2023-02-11 23:37:24 +00:00
read_config,
2023-02-10 19:36:58 +00:00
bind_server,
2023-03-09 02:30:37 +00:00
init_client_maps,
init_world,
2023-02-10 19:36:58 +00:00
).into_workload()
}
fn update() -> Workload {
(
update_server,
2023-03-08 19:26:51 +00:00
(
log_server_errors,
authenticate_players,
2023-03-09 02:30:37 +00:00
update_world,
2023-03-08 19:26:51 +00:00
).into_workload()
).into_sequential_workload()
2023-02-10 19:36:58 +00:00
}
fn main() {
2023-02-10 19:44:34 +00:00
kubi_logging::init();
2023-02-10 19:36:58 +00:00
let world = World::new();
world.add_workload(initialize);
world.add_workload(update);
world.run_workload(initialize).unwrap();
2023-02-10 21:11:18 +00:00
log::info!("The server is now running");
2023-02-10 19:26:03 +00:00
loop {
2023-02-10 19:36:58 +00:00
world.run_workload(update).unwrap();
2023-02-10 21:05:10 +00:00
thread::sleep(Duration::from_millis(16));
2023-02-10 19:26:03 +00:00
}
2023-01-30 00:46:22 +00:00
}